[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] 24x7 Script Archive


Paging/notifying system administrators

The 24x7 Scheduler allows you to setup a job that can send page or email a message to one recipient at a time. Sometimes it is necessary to notify more than one person in the event of a job failure. Using JAL you can add this option virtually to any job. One way to do this – is to setup the "file type" notification action for the main job of "program" or "database" type. In the event of a failure this job creates a semaphore file (for example: job.err). Another job of 24x7 script type instantly checks presence of the specified semaphore file. As soon as the file detected it deletes the file and sends pages or email messages to the specified recipients. Note that the second job needs to be scheduled as a "file watch". The following example shows how to use JAL email statements to send multiple messages.

// Note: List of recipients can be hard-coded to simplify scripting.
// To make this script reusable we decided to read recipients from file.
// This allows changing recipients without changing this job definition.

Dim file_number, number
Dim recipient, string
Dim end_of_file, boolean

// Open recipients file for reading line by line
FileOpen( "mail.lst", "LineMode", "Read", "", file_number )

// check end-of-file
EOF( file_number, end_of_file )

// Read the file line by line until the end of file.
// Each recipient must be on a separate line
LoopUntil end_of_file, ENDLOOP
   FileRead( file_number, recipient )
   // Send email
   MailSend( "Exchange Settings", "syspassword", recipient, "any subject", "any message" )
   // check end-of-file
   EOF( file_number, end_of_file )
ENDLOOP:

// Done
FileClose( file_number )