Specifications
158 DOMINION SX INSTALLATION AND OPERATIONS MANUAL
initEvents
#Main loop starts here...
while { 1>0 } {
cpuUtil $ports
ampdelay $intr
set rval [ListenCmds]
if { $rval == 1} {
delEvents
unset $ports
unset $noOfPorts
unset $thr
unset $intr
unset $mailid
break
}
incr ports 1
if { $ports > $noOfPorts } {
set ports 1
}
}
Script Function Description:
It is required to monitor CPU usage of user process running on several HP-UX machines through RS232
console connections. This TCL script will monitor the use through the well-known vmstat functionality
given by HP-UX. When CPU utilization has surpassed the given limit, this script will trigger an event that
notifies the subscribed users via e-mail. The user is allowed to input the threshold limit or the frequency
through his/her own commands (This example use THR and INTR respectively).
Key programming points:
• Use ampclear to remove all history information for a port
• Use ampread with “\n” as terminator since the script has to read each line to find out the user process
utilization that is on the 10
th
line.
• Use amptriggerevent to trigger a user-defined event event.alarm.cpu. The event may not begin with
“amp,” as that namespace is reserved for system-generated events. A user may subscribe to events
related only to one server by designating which server they are interested in. For example, a user may
subscribe to event.alarm.cpu.2 to receive a notification when cpu utilization on server 2 is measuring
above 10 %.
• The event will be sent only if the user who requests the notification is properly subscribed in the
Notification subscription list.
• In the subscription option, the User must type in the EXACT event shown previously: event.alarm.cpu.
• Delay 10 seconds so the script does not overflow the e-mail system. This is configurable using the
command INTR while this script is running using the amplisten facility.