1748172 Members
4160 Online
108758 Solutions
New Discussion юеВ

Re: shell programing

 
TOMAS BERNABEU
Frequent Advisor

shell programing

As it could detect pid of a process that is called "myprocess" of the user "myuser", who takes more than 24 hours in march and that consumes more of 80% of CPU during 60 minutes?

Thanks !!
4 REPLIES 4
Olav Baadsvik
Esteemed Contributor

Re: shell programing


Hi,

Not quite clear to me what you are after.
I think you will have to explain a bit
more what your problem is.

Regards
Olav
Peter Kloetgen
Esteemed Contributor

Re: shell programing

Hi Tomas,

Your description sounds like you need simply a software product which allready exists:

lsof

You can download it here:

javascript:openExternal('http://gatekeep.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.61/')

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping
Shahul
Esteemed Contributor

Re: shell programing

Hi

What I understood from ur question is, U wnat to get PID and user of the processes which are using more 80% of the CPU...Right?
The following script will list the processes which are using above 80% CPU. U can shrink or customize as per ur requirement.

ps -ef |sed '1d'>pall;awk '{print $4}'pcpu
for i in `cat pcpu`
do
if [ "$i" -gt 80 ];then
line fi;sed '1d' pall>pallout;mv pallout pall
done


Best of luck
Shahul
David Totsch
Valued Contributor

Re: shell programing

Tomas:

MeasureWare is great for alarming on misbehaving processes. If you have the MeasureWare collection daemon scopeux running, you could place an alarm in /var/opt/perf/alarmdef that can run a progam when a process exceeds the thresholds you write into the alarm. You can find examples in /opt/perf/examples. You can loop through per-process data scanning for processes that have PROC_CPU_TOTAL_UTIL greater than 80% for 60 minutes. If you do not have GlancePlus Pak, you can install trial software from your application CDs to give it a whirl.

Just keep in mind that alarming on a process running for more than 24 hours may be a little difficult (you would have to specify accumulated CPU time instead of linear start/stop times). Maybe PROC_CPU_TOTAL_TIME_CUM greater than 86400 seconds (24hours of execute time -- you might want a smaller number).

-dlt-