- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need scripts to generate the alterts if CPU utiliz...
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
06-21-2006 06:15 PM
06-21-2006 06:15 PM
does anybody can help me regarding this:
I need to generate the alterts if CPU utilization goes above 90%, does any body has any script?
please suggest
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2006 06:17 PM
06-21-2006 06:17 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
Try this.
perl -e 'alarm 360;while (1) {}'
while :
do
:
done
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2006 06:27 PM
06-21-2006 06:27 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
echo "High CPU Utilization" | mailx -s 'subject' praveen@domain.com
fi
Note: You want to read %idle less then 10%.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2006 06:41 PM
06-21-2006 06:41 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
sar -u 1 10 |awk '{print $5}' | if [ "$5" -le 10 ]; then
echo "High CPU Utilization" | mailx -s 'subject' praveen@domain.com
fi
:wq!
#chmod 777 cpu_alert.sh
#./cpu_alert.sh
will it mail to me if cpu utilization goes over 90%?
what will be crontab entry to run this script after 15 mins regularly?
please suggest
thankx in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2006 08:01 PM
06-21-2006 08:01 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
Check out this script to maintain a log for cpu and memory usage:
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2006 10:27 PM
06-21-2006 10:27 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
I have created two files in /home/cpumem directory.
#cd /home/cpumem
#ll
-rw-r--r-- 1 root sys 1462 Jun 22 03:59 cpumem.log
-rwxrwxrwx 1 root sys 1282 Jun 22 03:52 cpumem.sh
-rwxrwxrwx 1 root sys 114 Jun 22 03:53 cpumem.syn
# more cpumem.sh
#File name : cpumem.sh
###########################################################################
# script for capturing CPU and Memory usuage over a period. 24 hours. #
# File Name: cpumem.sh By: Raj.D. #
# can be run throguh cron or script with nohup . #
# Files required: 1. cpumem.sh 2. cpumem.syn #
###########################################################################
cd /home/cpumem
touch cpumem.log
echo "----------------------------------------------------------------------------------" >> cpumem.log
echo " Date: Time: (%)CPU Used: (%)Memory Used: " >> cpumem.log
echo "----------------------------------------------------------------------------------" >> cpumem.log
cd /home/cpumem
/opt/perf/bin/glance -adviser_only -j 15 -iterations 5760 -syntax /home/cpumem/cpumem.syn >> cpumem.log
echo " " >> cpumem.log
echo "----------------------------------------------------------------------------------" >> cpumem.log
echo "Monitoring of CPU and Memory done at `date` . " >> cpumem.log
echo "UPTIME= `uptime ` " >> cpumem.log
echo "----------------------------------------------------------------------------------" >> cpumem.log
# more cpumem.syn
print gbl_statdate, " ", gbl_stattime, " ", gbl_cpu_total_util, " ", gbl_mem_util
#./cpumem.sh
Welcome to GlancePlus
::::
:::
it is a continous process, i need to kill it using
can i kill it in scripts and how can i email logs to my email id?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 05:03 PM
06-22-2006 05:03 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
The script made to run for 24 hours once it has been executed , also you can interrupt by [ ctrl+c ].
check:
" -j 15 -iterations 5760 ", ie (15*5760 sec /3600 = 24 hr. ). You can customize as per need.
You can add a cron entry to run the script every day at 2am by:
###################################
00 2 * * * /home/cpumem/cpumem.sh
###################################
------------------------------------------
For emailing you can add this line to the end of the script of cpumem.sh .
########################################
# moving log file to todays log file name.
mv cpumem.log cpumem.`date +%m%d%y`.log
#--------------------------------------------
# Emailing the log file :
uuencode cpumem.`date +%m%d%y`.log cpumem.`date +%m%d%y`.log | mailx -s "CPU/MEM LOG for last 24 hours , Dated: `date` " your_email@domain.com
echo "Email sent ....with the attachment with cpumem log file "
########################################
Hope this will help ,
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 05:06 PM
06-22-2006 05:06 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
The log file will looks like as below:
#cat cpumem.log
----------------------------------------------------------------------------------
Date: Time: (%)CPU Used: (%)Memory Used:
----------------------------------------------------------------------------------
06/23/06 01:00:10 11.0 26.9
06/23/06 01:00:40 3.0 26.9
06/23/06 01:01:10 3.7 26.9
06/23/06 01:01:40 2.6 26.9
06/23/06 01:02:10 2.9 26.9
06/23/06 01:02:40 3.0 26.9
06/23/06 01:03:10 3.2 26.9
06/23/06 01:03:40 5.4 26.9
06/23/06 01:04:10 2.6 26.9
06/23/06 01:04:40 3.1 26.9
06/23/06 01:05:10 7.6 27.1
06/23/06 01:05:40 7.2 27.0
-----------------------------------------
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 05:12 PM
06-22-2006 05:12 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
hth,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 08:55 PM
06-22-2006 08:55 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
thanks for you help,
please let me know as this script is generating the logs of after every 15 secs.
i need to generate the logs after 10 mins for 24 hours.
what will be entry in place of 15 & 5760?
thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 09:05 PM
06-22-2006 09:05 PM
SolutionPraveen ,
Good question,
what will be entry in place of 15 & 5760?
( 15, 5760 this will give the cpu/mem usuage after every 15 seconds)
You can just put 600 & 144 to get usuage after every 10 min interval, for total 24 hours.
And can be run through cron , once in everyday , as this covers 24 hours.
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 09:22 PM
06-22-2006 09:22 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
thanks a lot for my help.
please let me know
when i use this command, i am not getting any mail. (I have created this file cpumem.`date +%m%d%y`.log)
#uuencode cpumem.`date +%m%d%y`.log cpumem.`date +%m%d%y`.log | mailx -s "CPU/MEM LOG for last 24 hours , Dated: `date` " your_email@domain.com
but when i use this command, i am getting the desired output:
#cat cpumem.`date +%m%d%y`.log | mailx -s "CPU/MEM LOG for last 24 hours , Dated: `date` " your_email@domain.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 09:38 PM
06-22-2006 09:38 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
uuencode gives problem with some email clients, if with cat command it is working fine, you can use the cat command .
Basically uuencode is used with mailx to attach any file with the email. As it is a text file , cat command will do the same tricks ,
cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2006 10:53 PM
06-22-2006 10:53 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
If you persist in this as I've advised against, email your results as followes:
Route your report to a text file.
Use:
http://www.hpux.ws/mailfile2
To send the report as an attachment.
Its production code all over the world now, based on code I found with an itrc search.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2006 03:40 AM
06-29-2006 03:40 AM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
is that the instantaneous cpu usage at that time or the average cpu utilization over the 10 minute period?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 06:00 PM
06-30-2006 06:00 PM
Re: Need scripts to generate the alterts if CPU utilization goes above 90%
is that the instantaneous cpu usage at that time or the average cpu utilization over the 10 minute period?