wahab
1
Hi,
I am using below command to get the High CPU Utilization.
top -l 1| awk �/CPU usage/ {print $12, $13}�
I am getting below error.
ksh: 1: parameter not set
top: illegal option -- l
Usage: top [-u] [-w] [-q] [-P] [-dx] [-sx] [-p pset_id] [-n number] [-f filename]
Usage: awk [-F fs][-v Assignment][-f Progfile|Program][Assignment|File] ...
Could you please suggest the appropriate solution.
Thanks.
Hi wahab,
There is no "-l" command line option in "top" and why do you want to use awk when there are sufficient options for the output you desire try
man top
.
wahab
3
Hi ,
Thanks Mayur for your inputs..
I need a PID of the highest CPU consuming process.
#!/usr/bin/ksh
cpu_usage_limit=60 #In percentage
host=`hostname`
top -l 1| awk �/CPU usage/ {print $3, $12}� >> $host_top_output.txt
usage=`grep "^ *$1 " $host_top_output.txt | awk '{print $2}' | sed 's/%//'`
PID=`grep "^ *$1 " $host_top_output.txt | awk '{print $1}'`
if [[ $usage -gt $cpu_usage_limit ]] then
SQL_Statement to get the SQL code of high CPU consuming process by using the above PID.
Is there any other way to grep CPU & PID using TOP command in HP-UX system?
Try this:
top -n1 -b -H | egrep -A1 PID | tail -1 | awk '{print $1}'