![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ksh scripting help | praveenbvarrier | Shell Programming and Scripting | 1 | 04-15-2008 07:19 AM |
| sql scripting help | sam786 | Shell Programming and Scripting | 3 | 12-10-2007 09:31 AM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 05:12 AM |
| scripting guru's pls help me with scripting on AIX | thatiprashant | Shell Programming and Scripting | 1 | 01-20-2006 04:58 PM |
| Scripting? | woofie | What's on Your Mind? | 1 | 03-09-2005 04:03 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi i need some help of u big guys who is expert in scripting ..! I want a script that check the swap space every 10/15 sec and if it finds swap being utilised to 80%, should raise an alert to the root..! any one of you if can put some light on this i will be very glad ..? looking for some positive replies
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
#!/bin/sh
while true
do
sleep 15
x=`swap -s | sed 's/k//g' | awk '{print ( $9 * 100 )/( $9 + $11 )}'`
if [ $x -gt 80 ];
then echo "SWAP at $x" | mailx -s 'SWAP ALERT' root
fi
done
should work |
|
#3
|
|||
|
|||
|
reply
Thanks for your time and effort I need to check this work and let u know, but its quite diffcult to understand the script , i need to learn more on it can u tell me this site i can get better document to under this ...??? But anywaz thanks for your script..
|
|
#4
|
|||
|
|||
|
need help again
Hi Tytalus,
thanks its working ..i tried tht but need some more of ur help I need to add few more line to get the total no of process running "echo no of process" and one process say proces x if ecxeed no of process say 4 shoould also be shown in the same mail.. i try out some my junk scripting technique please check and verify also edit the same if it is wrong #!/bin/sh while true do sleep 15 x=`swap -s | sed 's/k//g' | awk '{print ( $9 * 100 )/( $9 + $11 )}'` if [ $x -gt 40 ] && [ $x > 40 ]; then echo "SWAP at $x do y='ps -ef|wc -l echo "No of process $y c= pgrep rational | wc -l if [$c > 4 ]|mailx -s SWAP ALERT -very high root fi done please dont lauge at my poor skill in scripting but appriceate my spirit in scripting, and help me getting this script done.. thanking you in advance.. |
|
#5
|
|||
|
|||
|
use nawk in Solaris
Code:
#!/bin/sh
ps -ef | awk 'BEGIN{
cmd="swap -s"
cmd | getline line
close(cmd)
split(line,array)
percent = (array[9]/(array[9]+array[11])) * 100
}
END{
if ( percent > 40) {
email="mailx -s \047subject\047 root"
s= s "Number of processes : "NR"\n"
s= s "Swap at " percent
print s | email
close(email)
}
} '
|
|
#6
|
|||
|
|||
|
Hi ghostdog,
i try to run the script but getting some error in line 3 and line 11 , well just check this script i just done its giving error "unexpected end of line done" ,if possible please fix it.. #!/bin/sh while true do sleep 15 y='ps -ef |wc -l then echo "No of Process at $y" >> swap.alert z='pgrep rational| wc -l | sed s/k//g' /awk '{print ($8)}' if [ $z > 4 ]; then echo "Rational process at $z" >> swap.alert x=`swap -s | sed 's/k//g' | awk '{print ( $9 * 100 )/( $9 + $11 )}'` if [ $x -gt 80 ]; then echo "SWAP at $x" >> swap.alert | cat swap.alert |mailx -s 'SWAP ALERT' root fi done |
|
#7
|
|||
|
|||
|
you have not read my reply's first sentence.
|
|||
| Google The UNIX and Linux Forums |