![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Diff b/n kill and kill -9 | ammu | UNIX for Advanced & Expert Users | 2 | 07-18-2007 06:29 PM |
| kill(0,-9) don't kill the process | umen | High Level Programming | 9 | 06-19-2007 07:09 AM |
| not able to kill find with kill -9 | Amardeep | UNIX for Dummies Questions & Answers | 5 | 01-04-2007 05:49 PM |
| KILL PID, intern should kill another PID. | rkrgarlapati | Shell Programming and Scripting | 4 | 10-17-2006 08:47 AM |
| When kill doesnt work, how to kill a process ? | VijayHegde | UNIX for Advanced & Expert Users | 3 | 05-12-2006 05:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
awk, grep and kill
Hi there folks,
I'm newbie here and need some help from the gurus in this forum, pls excuse me as my english is not very good. WARNING long post!! I have a simple script running on my box which basically polls every 5mins to check the utilization of certain iplanet SOP application processes, if the process exceed > 80% it gets killed and the application will automatically respawn a new process but running at lower cpu. while true do rm -f /tmp/HIGH_SOP_CPU.* ps -edf -o user,pcpu,pid | grep -i sopias | awk '$2 > 80.0 { print }' >> /tmp/HIGH_SOP_CPU.`date +%d%m%y%H%M` if (test -s /tmp/HIGH_SOP_CPU.`date +%d%m%y%H%M`) then kill -9 `ps -edf -o user,pcpu,pid | grep -i sopias | awk '$2 > 80.0 { print $3 } '` fi sleep 300 done However the problem is this script only checks for a single process > 80%, if there are more than 1 or a few sopias process running concurrently and all of them under 80% utilization but collectively contribute to taking > 80% of system cpu resources it goes undetected by the script until the users complain then it needs to be killed manually. I'm trying to either expand the current script or write a seperate one which greps all the sopias processes, find the total utilization and if > 80%, find the largest utilized process and kill it. Of course it's easier said than done and I'm still trying to find out how to do it. I'm trying to find out how I can couple these 2 awk statements together without using flatfiles. awk '{for (i=1; i<=NF; i++) s=s+$i}; END {print s}'` `ps -edf -o user,pcpu,pid | grep -i sopias | awk '{ print $2}'` basically the ps statement greps a list of all the utilization and pipes to the for-loop which does the calculations, if I use a flatfile for the `ps` it works fine. any ideas how not to do it with a flatfile? And maybe a sample awk script that can show me how to find the largest number from a range of numbers. thx in advance Last edited by sparcguy; 11-27-2006 at 04:33 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|