Specifications

156 DOMINION SX INSTALLATION AND OPERATIONS MANUAL
Basic CPU Utilization Monitoring Example
#Description: This TCL script checks the CPU utilization for each port connected
# to a HP-UX server. It alerts the subscribed user that the threshold
# limit has reached through e-mail notification. This TCL script uses
# vmstat to find out the CPU usage of the user process and checks with
# given threshold limit. During the process user can input the threshold
# limit or the interval through the following commands:
# THR <threshold> - Input of threshold
# INTR <interval> - Interval at which the TCL script has to do checking.
# To quit out of the script type QUIT and hit enter
#Default threshold is 2 %
set thr 2
#Default interval is 10 seconds
set intr 10
#change this mail id to your own
set mailid "mailto://xyz@xyz.com"
#initalize events
proc initEvents { } {
global mailid
#add subscriptions to events.
ampaddsubscription event.alarm.cpu $mailid
#save subscription
ampsave
}
#delete events. Called during QUIT
proc delEvents { } {
global mailid
#delete subscriptions to events
amprmsubscription event.alarm.cpu $mailid
#save configuration
ampsave
}
#Retrive cpu utilization for user process,
#check if it has reached the threshold and trigger an event
proc cpuUtil { port } {
global thr
set us 0
set sy 0
set id 0
#lock the console
amplock $port