wahab
July 17, 2011, 2:00pm
1
Guys,
I want to get the high CPU utilization from top.
I am using below code :
top -d2 >> /home/dba_monitoring/host_top_output.txt
echo "Script started `date`" > $runlog
usage=`grep "^ *$1" /home/dba_monitoring/host_top_output.txt | awk '{print $12}' | sed 's/%//'`
And getting below error message.
./cpu_consuming_queries.sh
awk: Input line Cannot be longer than 3,000 bytes.
The input line number is 1.
The source line number is 1.
Can anyone suggest please.
Thanks:)
in Solaris, use nawk or /usr/xpg4/bin/awk
You can also roll the bits done by grep and sed commands into your awk script:
usage=$(nawk -v N="$1" '$0 ~ "^ *"N { sub(/%/, "", $12); print $12 }' /home/dba_monitoring/host_top_output.txt)
wahab
July 18, 2011, 11:49am
4
Hi
nawk is not working as this is HP-UX.
I am getting below error :
awk: Input line
annot be longer than 3,000 bytes.
The input line number is 1. The file is /home/dba_monitoring/host_top_output.txt.
The source line number is 1.
Do you have gawk, I think it's available on HP-UX 11 and shouldn't have the 3,000 character limit.
top has a -f option that will automatically append output to a user specified logfile...so consider using that instead of >>
wahab
July 20, 2011, 12:42pm
7
Hi,
I tried using gawk but getting below error.
: gawk: not found
Could you install it, then?