APPENDIX H: TCL PROGRAMMING G UIDE 139Generating a User EventTCL scripts are a powerful tool for performing true device management, in the form of customer-definedmonitoring and notification of events. A sample script is shown below:#This script performs the monitoring of HTTP servers.proc pstat {procname port_num} {set psef [concat "ps -ef | grep " $procname | grep -v "grep" | wc -l]ampexec "stty -echo\r" 5 "#" $port_numset output [ampexec "$psef\r" 10 "#" $port_num]ampexec "stty echo\r" 5 "#" $port_numreturn [lindex $output 0]}# add subscription to an event here.ampaddsubscription event.user.httpProcess “xyz@xyz.com”# Run through 4 different servers to find out if HTTP service is running# on each one of them and trigger an event appropriately.for {set port_num 0} {$port_num < 4} {incr port_num +1} {ampclear $port_numamplock $port_numset output [pstat httpd $port_num]ampunlock $port_numif {$output > 0} {puts "HTTP_SERVER_OK $port_num"amptriggerevent event.user.httpProcess “HTTP service is up and running on$port_num”} else {puts " HTTP_SERVER_ERROR $port_num"amptriggerevent event.user.httpProcess “HTTP service down on $port_num”}}In the Notification tab of the unit, the user can subscribe to either of the following:event.user or event.user.httpProcess to get this message: “HTTP service is up and running on 1”. Tosubscribe to user-defined events (defined in the TCL script), the event name must be specified.Note: This Event Name must match EXACTLY with the event name the user generated using the TCLscript. event.user will send out an notification whenever this event is triggered. event.user.httpProcess willbe sent out only when this specific event occurs. The entry must be entered in the notification tab exactly asit appears in the script.