- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- A script about TOP
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2006 07:41 PM
12-17-2006 07:41 PM
A script about TOP
PID USERNAME PRI NICE SIZE RES STATE TIME CPU COMMAND
91847 prodmgr 44 0 57M 18M sleep 240:02 99.00% f60webmx
-----------------
Because we have 10 CPU in the server, so we can't detect this process by total CPU loading.
Can you tell me how to write a sciprt to detect a process (CPU > 99%, Run Time > 240)?
Thanks
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2006 08:07 PM
12-17-2006 08:07 PM
Re: A script about TOP
Try this one.
# echo " %CPU PID RUSER COMMAND" ;UNIX95= ps -ef -o 'pcpu pid ruser args'|sort -nr|head -10
top 10 cpu
# UNIX95= ps -e -o "user,pcpu,cpu,vsz,pid,ppid,args" | sort -rnk2 | head -10
Regards,
Robert-Jan
Ps.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=4177
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 01:08 AM
12-18-2006 01:08 AM
Re: A script about TOP
Give this quasi-tested script a shot (adjust THRESHOLD_CPU and THRESHOLD_RT accordingly):
#!/usr/bin/sh
typeset -i THRESHOLD_CPU=99
typeset -i THRESHOLD_RT=240
top -d 1 -n 30 -f /tmp/top.$$.1
awk -v T_CPU=${THRESHOLD_CPU} -v T_RT=${THRESHOLD_RT} 'NR>15{ sub(/:../,"",$10); if ($11 > T_CPU && $10 > T_RT) print}' < /tmp/top.$$.1 > /tmp/top.$$.2
if [[ -s /tmp/top.$$.2 ]]
then
mailx -m -s "Process(es) Hogging CPU!" your@email.addr < /tmp/top.$$.2
fi
rm -f /tmp/top.$$.[12]
exit 0
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 06:41 PM
12-18-2006 06:41 PM
Re: A script about TOP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 07:39 PM
12-18-2006 07:39 PM
Re: A script about TOP
some note about your script:
you use NR>15 to skip the header line in TOP output till the first line after CPU but this is not fixed. It depends on teh number of CPU you have in my case is 27:
24
25 Memory: 11548788K (5845412K) real, 14852188K (8039792K) virtual, 16883816K free Page# 1/42
26
27 CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
28 11 ? 25893 oracle 149 22 1136M 51436K sleep 53:37 40.19 40.12 oracleGPWK01CS
in awk simply use:
/tmp/top.$$.1
instead of < /tmp/top.$$.1
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 09:45 PM
12-18-2006 09:45 PM
Re: A script about TOP
ps aux |tail +2 |sort -rn -k 3,3 |more