sar -u 1 | awk '{print $9}'
so this will give me "CPU Idle" value every second. I'd like to get email in this case the value goes to "0" 10 times in a row?
What would be the appropriate way to do it?
I found a preliminary solution
sar -u 1 | awk '{ if (int($9)==0) {
i=i+1; {
print i, $9
}
}
if (int($9)>=0) {
i=0
}
if (i>=10) print "sending email"
}'
but in last line where I print "sending email" I can't put call to mutt, like this
sar -u 1 | awk '{ if (int($9)==0) {
i=i+1; {
print i, $9
}
}
if (int($9)>=0) {
i=0
}
if (i>=10) mutt -s "VPNC Problem" test@test.com < /home/semenov/strace.output
}'
the problem is that it says "syntax" error in mutt command call. Any ideas?
I put debug & strace on the process and I simply want to catch the moment it happens first time. Otherwise I'm missing high CPU utilization and server suffer from it. It's not about micromanagement :) - just to help SERVER breath :)
– DmitrySemenov Sep 27 '12 at 19:03sarevery second and logging the time / value. If you still want to do it via email you can wrap my template below in awhile [ true ]; do . . . sleep 1 ; doneand runsaras a one-shot each time to get the value. Beware of inbox overload: It will kick out a mail any time the condition is met. You could quickly regret asking for such behavior :-) – voretaq7 Sep 27 '12 at 19:08