-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
David,
I appologize you are correct the script I sent you is a version of the same script that I am working on for an AIX machine. Attached is an unencrypted version of the script for System V: BSD/Linux machines.
This is the error it is giving me and I'm not sure why I am getting this error? ######################################################################## [EMAIL PROTECTED] sys_admin]$ ./swap_mon.ksh~ \nSwap Space Report for redgate.ath.cx\n Sun Aug 8 00:03:48 EDT 2004 (standard_in) 3: illegal character: O (standard_in) 3: parse error (standard_in) 3: illegal character: O (standard_in) 3: parse error \nTotal Amount of Swap Space:\t494MB Total KB of Swap Space Used:\t23MB Total KB of Swap Space Free:\t471MB \nPercent of Swap Space Used:\t4.6500% \nPercent of Swap Space Free:\t95.3400% \n ######################################################################### I need some help figuring out why bc is giving me such a hard time. I'm almost positive my syntax is correct. This is where I think the problem begins (and possibly ends) in the script: ######################################################################### do # Use the bc utility in a here document to calculate the percentage of # free and used swap space
PERCENT_USED=$(bc <<EOF scale=4 ($SW_USED / $SW_TOTAL) * 100 EOF )
PERCENT_FREE=$(bc <<EOF scale=4 ($SW_FREE / $SW_TOTAL) * 100 EOF ) ##########################################################################
Thanks for your help in advance.
HZS
David Fleck wrote: | Unfortunately, I think the script you attached has been mangled in some | way or other; it appears to be missing the end of the 'paging_mon' | function, as well as whatever code invokes that function (and the | swap_mon function as well). If I try to run it, I get: | | dcf>$ ./swap_mon.ksh | \nSwap Space Report for grond.sourballs.org\n | Sun Aug 8 07:31:26 CDT 2004 | ./swap_mon.ksh: line 85: funtion: command not found | ./swap_mon.ksh: line 135: syntax error: unexpected end of file | | if I fix the typo (funtion -> function) I just get the 'unexpected EOF' | error. | | Both my 4.9 and 5.2.1 systems have /usr/bin/bc, so I assume it is part | of the base install. However, neither system has 'lsps', which appears | to be an AIX command. | | | -- | David Fleck | [EMAIL PROTECTED] | | _______________________________________________ | [EMAIL PROTECTED] mailing list | http://lists.freebsd.org/mailman/listinfo/freebsd-questions | To unsubscribe, send any mail to | "[EMAIL PROTECTED]" | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBFkiclT9WV6TztkoRAngzAJ4jtRcnE5ZkANyZOM9ORxb+scnMNACeJFVf JzNrpFMIjSw0NfpxOgyT13U= =sXLe -----END PGP SIGNATURE-----
############################################################################## #! /usr/bin/ksh ############################################################################### # CREATED_BY: Hakim Z. Singhji ############################################################################### # SCRIPT: swap_mon.zsh ############################################################################### # DATE: 8/4/04 ############################################################################### # VERSION: 0.1 ############################################################################### # PLATFORM: Linux Only ############################################################################### # PURPOSE: This shell script is used to produce a report of the system's swap # space statistics including: Total paging space in MB, MB of free # paging space, MB of used pagine space, % of paging space used and # % of paging space free ############################################################################### # REV LIST:
# set -x # Uncomment to debug this shell script # set -n # Uncomment to check command syntax without any execution ############################################################################### ############################# DEFINE VARIABLES HERE ########################### THISHOST=$(hostname) # Host name of this machine PC_LIMIT=65 # Upper limit of Swap space percentage before # notification ############################################################################### ############################# INITIALIZE THE REPORT ########################### echo "\nSwap Space Report for $THISHOST\n" date ############################################################################### ############################# CAPTURE AND PROCESS DATE ######################## free -m | grep -i swap | while read junk SW_TOTAL SW_USED SW_FREE do # Use the bc utility in a here document to calculate the percentage of # free and used swap space PERCENT_USED=$(bc<<EOF scale=4 ($SW_USED / $SW_TOTAL) * 100 EOF ) PERCENT_FREE=$(bc<<EOF ($SW_FREE / $SW_TOTAL) * 100 EOF ) # Produce the rest of the paging space report: echo "\nTotal Amount of Swap Space:\t${SW_TOTAL}MB" echo "Total KB of Swap Space Used:\t${SW_USED}MB" echo "Total KB of Swap Space Free:\t${SW_FREE}MB" echo "\nPercent of Swap Space Used:\t${PERCENT_USED}%" echo "\nPercent of Swap Space Free:\t${PERCENT_FREE}%" # Grab the integer portion of the percent used to test for # the over limit threshold INT_PERCENT_USED=$(echo $PERCENT_USED | cut -d. -f1) if (( PC_LIMIT <= INT_PERCENT_USED )) then # Swap space limit has exceeded th threshold, send # notification tput smso # TURN ON REVERSE VIDEO!!!!!!!!! echo "\n\nWARNING: Paging Space has Exceeded the ${PC_LIMIT}% Upper Limit!\n" tput rmso # TURN OFF REVERSE VIDEO!!!!!!!!!!!!!! fi done echo "\n" ############################################################################### #BELOW SEE THE ERROR MESSAGE DUE TO SHELL CONVERSION PROBLEMS # [EMAIL PROTECTED] scripts]$ ./swap_mon.ksh # \nSwap Space Report for redgate.ath.cx\n # Fri Aug 6 00:04:14 EDT 2004 # ./swap_mon.ksh: line 1: bc: command not found # ./swap_mon.ksh: line 1: bc: command not found # \nTotal Amount of Swap Space:\t494MB # Total KB of Swap Space Used:\t0MB # Total KB of Swap Space Free:\t494MB # \nPercent of Swap Space Used:\t% # \nPercent of Swap Space Free:\t% # \n ############################################################################### ############################# END OF FILE #####################################
smime.p7s
Description: S/MIME Cryptographic Signature