1752571 Members
4968 Online
108788 Solutions
New Discussion

Re: glance process shell

 
chin hyeon jung
Advisor

glance process shell

I want to make script for some process util. first ask me the number of process or name. If it exists print utilization per 5minutes .If not exist print echo "Not exist"
here is some scripts
#!/usr/bin/sh
echo "pid= \c"
read my_pid

for PID in `ps -ef|sed 's/^ *//g'|grep -v \^UID|awk '{print $2}'`
do
if [ $my_pid -eq $PID ]
then
echo $PID>./tmp_pid
echo "WE FOUND $my_pid IS $PID"
glance -adviser_only -syntax adv_cpu >>./result 2>>error
fi
done

----
print "---------", gbl_stattime
print "process pid util"
print "-------------------------------------------------------"
process loop {
if (proc_proc_id == $`{tail ./tmp_pid}` ) then
print proc_proc_name|12, " ", proc_proc_id, " ", proc_cpu_total_util, " "}
print " "
#
1 REPLY 1
Steve Steel
Honored Contributor

Re: glance process shell

Hi

You can find a few examples in /opt/perf/examples/adviser.
Documentation is /opt/perf/paperdocs/gp/C.

Just to see cpu you can also use top with the
-f option which is undocumented but writes to a file.

Or ps as

UNIX95= ps -e -o pcpu -o ruser -o vsz -opid -o args|head -n1
UNIX95= ps -e -o pcpu -o ruser -o vsz -opid -o args|grep -v %CPU| sort -nr|tail
-n +2|head -n 20



steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)