Operating System - Linux
1755605 Members
5020 Online
108836 Solutions
New Discussion юеВ

Re: Script Help-System Peformance

 
SOLVED
Go to solution
Karthick K S
Frequent Advisor

Script Help-System Peformance

Hi all,

Need Help for Script

What my script will do

Script will collect CPU Performance for every one minute(Thro'Schedule) if the CPU Perf. will go above 40%,it will send username,pid and hostname details to admin mail id

Pleas anyone help for this
13 REPLIES 13
RAC_1
Honored Contributor

Re: Script Help-System Peformance

Crude and dirty.

Put following in cron. Run it as you want.

UNIX95= ps -ef -o pid,ruser,pcpu,args|tr -d "%" |awk '{if($4>=90) print $0}' | mailx -s "processes takig more than 90% cpu in last scheduling interval" abc@xyz.com

The better method would be configuring a correct alarm in /var/opt/perf/alarmdef file. This would email you when thresholds are crossed. Check the examples in /opt/perf/examples/adviser directory.
There is no substitute to HARDWORK
Karthick K S
Frequent Advisor

Re: Script Help-System Peformance

Thanks a lot,

If any script to send alert mail like which user using more cpu util...above 60% and from which IP or Hostname
RAC_1
Honored Contributor

Re: Script Help-System Peformance

Change 90 to 60. It will show user name and processes name also. What hostname is going to be difficult, beacuse it depends upon what king of a process it is. Like sql, oracle listener processes come from network, while some are started on host itself.

May be if you can exaplain what you are trying to do, we may be able to help you better.
There is no substitute to HARDWORK
Karthick K S
Frequent Advisor

Re: Script Help-System Peformance

Sometimes CPU Utilzation is going 100% ,and we dont have any alert mail for this so
i think thro' script by schedule every minutes to check the cpu perf..
and if cpu utilization going beyond 40% send a mail alert to adminid with username and hostname details(which user using more
cpu utilization)

pls....
RAC_1
Honored Contributor

Re: Script Help-System Peformance

I have been using this for some time now to take a quick galnce at what is happening.

UNIX95= ps -ef -o pcpu="CPU %" -o ruser=USER -o pid,args|awk '{if($1>=40)print $0}'|sort -rk1|head -16
There is no substitute to HARDWORK
Mark Nieuwboer
Esteemed Contributor

Re: Script Help-System Peformance

Hi,

Question what's the problem that a system has sometimes 100% CPU utilisation.
It's better to have a cpu runninig between the 70 en 90% then lower. If it hit sometimes the 100% it's only working. When also the swapspace en threads are filling up it's usefull to get an alert.
In the mean time with glance you can look wich process had needed the 100 % cpu.

grtz. Mark
Mark Nieuwboer
Esteemed Contributor

Re: Script Help-System Peformance

Hi,

Question what's the problem that a system has sometimes 100% CPU utilisation.
It's better to have a cpu runninig between the 70 en 90% then lower. If it hit sometimes the 100% it's only working. When also the swapspace and threads are filling up it's usefull to get an alert.
In the mean time with glance you can look wich process had needed the 100 % cpu.

grtz. Mark
Steven E. Protter
Exalted Contributor

Re: Script Help-System Peformance

Shalom KArthick,

Background:
http://www.hpux.ws/system.perf.sh

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Arturo Galbiati
Esteemed Contributor

Re: Script Help-System Peformance

Hi,
I've a script that by Glance collects the % of use for CPU, DISK, MEM and SWAP and notify me when 2 of them are over a threshold.
Let me know if you are interested in this and I'll provide you. (I'd like to avoid to post unnecessary script).
HTH,
Art