cancel
Showing results for 
Search instead for 
Did you mean: 

CPU Usage Script

 
SOLVED
Go to solution
Highlighted
Sial_1
Frequent Advisor

CPU Usage Script

Hi,

can someone help me to find the script which will help me to monitor cpu usage for HP-UX 11.31 & 11.23, and if the usages go above 80% I will get a email atomically.

Thanks in advance.
11 REPLIES 11
Highlighted
Dennis Handly
Acclaimed Contributor

Re: CPU Usage Script

What tool is going to measure the CPU usage, top? And you only want the average of all N CPUs?
Highlighted
Sial_1
Frequent Advisor

Re: CPU Usage Script

Yes we can use top, and average of all CPUs.
Highlighted
Dennis Handly
Acclaimed Contributor

Re: CPU Usage Script

You can start with:
$ top -f /var/tmp/top.out -n 100 -d 1
$ awk '/^avg/ { print 100 - $6; exit}' /var/tmp/top.out

This prints the average % CPU utilization.
Highlighted
Sial_1
Frequent Advisor

Re: CPU Usage Script

Dennis

Need script that sends me an email if CPUs average usage goes above 80%.
Highlighted
Raj D.
Honored Contributor

Re: CPU Usage Script

Sial,
Check this out: cpumem.sh

http://forums13.itrc.hp.com/service/forums/questionanswer.do?&threadId=1037077

I havce a latest version of it also , for v2 and v3, just try that out. It works with glance ,and keeps a log of cpu/mem/diskio ..,

How ever if you have implemented OVO , that will send cpu threshold alert.

Hth,
Raj.

" If u think u can , If u think u cannot , - You are always Right . "
Highlighted
Sial_1
Frequent Advisor

Re: CPU Usage Script

Thanks Raj, cpumem.sh only creates log file that has cpu and mem average%. But I need script that sends me an email if my systemâ s CPUs usage average touches 70%.

Rgd,
Highlighted
Elmar P. Kolkman
Honored Contributor

Re: CPU Usage Script

Why not use sar for information collection and running a script from cron that checks if the CPU usage gets too high ?
Every problem has at least one solution. Only some solutions are harder to find.
Highlighted
Raj D.
Honored Contributor

Re: CPU Usage Script

Sial,

from sar output you can get email alert if cpu usage is more than 80% , you need have a script with loop, or may be using cron ,

# sar -u 5 20
- grep the cpu usage field
- using awk '{ if ( $NF > 80 ) print $0 }' >> logfile, analyse the log file again with a condition and if it is greater than 80 for sometime then send email, else OK.

That logic could be use ,

Hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Highlighted
Sial_1
Frequent Advisor

Re: CPU Usage Script

Ok, can you help me to write a script using sar?