Using SNMP Notifications With JAMS

Follow

SNMP notifications can be used with JAMS to create alerts for the status of Jobs and Setups. An SNMP notification can be sent in the event that a Job or Setup completed successfully, failed, stalled, was short, or became runaway.

In order to use SNMP notifications with JAMS it is necessary to have an SNMP trap sender. An SNMP trap sender enables a JAMS notification job to send a notification across a network to the SNMP receiver.

A trap generator can be downloaded here:
http://trapgen.trapreceiver.com/

After installing this utility it is also necessary to download the JAMS MIB file. The MIB file allows a SNMP Trap receiver to understand the data context of the information being sent to it by the trap sender.

The JAMS MIB file can be downloaded from the following link.

 

The next step is to open JAMS and create a new SNMP notification job. In this example we will create a new job definition and use PowerShell as the execution method. The Job created below is also available in the Sample Library within the JAMS Client:

 

param($JAMS_NOTIFY_JAMS_ENTRY, $JAMS_NOTIFY_REASON, $JAMS_NOTIFY_JOB_NAME)
write-host "$JAMS_NOTIFY_REASON for entry $JAMS_NOTIFY_JAMS_ENTRY, $JAMS_NOTIFY_JOB_NAME"
Add-PSSnapin MVPSI.JAMS -erroraction SilentlyContinue
#
#  Get the JAMS CurrentJob object information
#
$entry = Get-JAMSEntry $JAMS_NOTIFY_JAMS_ENTRY
$runawayElapsed = $entry.RunawayElapsed
$submittedBy = $entry.SubmittedBy
$entryNum = $entry.JAMSEntry
$jobName = $entry.JobName
$finalSeverity = $entry.FinalSeverity
$finalStatusCode = $entry.FinalStatusCode
$statusText = $entry.FinalStatus
$folderName = $entry.FolderName
$holdTime = $entry.HoldTime

#
#  Output the JAMS CurrentJob object
#
$entry | fl | out-default

#
#  Send an SNMP Trap
#
cd \
cd users\phils\desktop\trapgen291

#
# Get the FolderName from the Job/Setup
#
if($entry.JobID -ne 0)
{
	$folderName = $entry.Job.ParentFolderName
}
elseif($entry.SetupID -ne 0)
{
	$folderName = $entry.Setup.ParentFolderName
}

if(!$folderName)
{
	$folderName = " "
}

 

Users may have noticed that the job has three parameters defined at the top of the script. These parameters do not need to be defined in the parameter tab of the job definition, however they do need to be specified in the source tab as shown above. It is also important to notice that we are navigating to the directory where the trap sender has been installed. This file path will depend on the location where the trap sender (TrapGen) was installed.


The first portion of the source is simply getting information about the job or setup that we want to create a notification for. The next snippet will show how to define the notifications that you want to send:

 

#
# send a Trap Indicating that a job failed
#
if( $JAMS_NOTIFY_REASON -eq "FAILED")
{
./trapgen -d 192.168.12.133 `
 -o .1.3.6.1.4.1.11020 `
 -v .1.3.6.1.4.1.11020.5.12 STRING "Failure Notification" `
 -v .1.3.6.1.4.1.11020.5.1.1.1 STRING "Job Failed" `
 -v .1.3.6.1.4.1.11020.5.1.1.4 INTEGER "$entryNum" `
 -v .1.3.6.1.4.1.11020.5.1.1.2 STRING "$jobName" `
 -v .1.3.6.1.4.1.11020.5.1.1.3 STRING "$folderName" `
 -v .1.3.6.1.4.1.11020.5.1.1.5  STRING "$submittedBy" `
 -v .1.3.6.1.4.1.11020.5.3.0 INTEGER "$finalStatusCode" `
 -v .1.3.6.1.4.1.11020.5.6.0 STRING "$statusText" `
 -v .1.3.6.1.4.1.11020.5.9.0 STRING "$finalSeverity"
}
#
#send a Trap Indicating that was runaway
#
if( $JAMS_NOTIFY_REASON -eq "RUNAWAY")
{
./trapgen -d 192.168.12.133 `
 -o .1.3.6.1.4.1.11020 `
 -v .1.3.6.1.4.1.11020.5.12 STRING "Runaway Notification" `
 -v .1.3.6.1.4.1.11020.5.1.1.1 STRING "Job was a runaway" `
 -v .1.3.6.1.4.1.11020.5.1.1.4 INTEGER "$entryNum" `
 -v .1.3.6.1.4.1.11020.5.1.1.2 STRING "$jobName" `
 -v .1.3.6.1.4.1.11020.5.1.1.3 STRING "$folderName" `
 -v .1.3.6.1.4.1.11020.5.1.1.5  STRING "$submittedBy" `
 -v .1.3.6.1.4.1.11020.5.5.0 STRING "$runawayElapsed"
}
#
#send a Trap Indicating that has completed
#
if( $JAMS_NOTIFY_REASON -eq "COMPLETED")
{
./trapgen -d 192.168.12.133 `
 -o .1.3.6.1.4.1.11020 `
 -v .1.3.6.1.4.1.11020.5.12 STRING "Completion Notification" `
 -v .1.3.6.1.4.1.11020.5.1.1.1 STRING "Job Completed" `
 -v .1.3.6.1.4.1.11020.5.1.1.4 INTEGER "$entryNum" `
 -v .1.3.6.1.4.1.11020.5.1.1.2 STRING "$jobName" `
 -v .1.3.6.1.4.1.11020.5.1.1.3 STRING "$folderName" `
 -v .1.3.6.1.4.1.11020.5.1.1.5  STRING "$submittedBy" `
 -v .1.3.6.1.4.1.11020.5.3.0 INTEGER "$finalStatusCode" `
 -v .1.3.6.1.4.1.11020.5.6.0 STRING "$statusText" `
 -v .1.3.6.1.4.1.11020.5.9.0 STRING "$finalSeverity"
}

 

 

The code snippet above shows how to create a notification for a job that has failed, runaway or was completed successfully. 
 
To get a better idea of what is going on in these notifications we will use the Failed notification as an example. Line 6 tells the trap generator where to send the notification on the network. This IP address should correspond to where a user will have the SNMP trap receiver. Lines 7-16 reference objects from the JAMS MIB file and do not require any changes to get notifications working. 
 
Any of the lines that begin with "-v" can be re-ordered or removed to suit your notification requirements.

The last snippet shows the remaining source of the notification job and demonstrates how to create additional notifications:

 

#
#send a Trap Indicating that a job was short
#
if( $JAMS_NOTIFY_REASON -eq "SHORT")
{
./trapgen -d 192.168.12.133 `
 -o .1.3.6.1.4.1.11020 `
 -v .1.3.6.1.4.1.11020.5.12 STRING "Short Job Notification" `
 -v .1.3.6.1.4.1.11020.5.1.1.1 STRING "Job was short" `
 -v .1.3.6.1.4.1.11020.5.1.1.4 INTEGER "$entryNum" `
 -v .1.3.6.1.4.1.11020.5.1.1.2 STRING "$jobName" `
 -v .1.3.6.1.4.1.11020.5.1.1.3 STRING "$folderName" `
 -v .1.3.6.1.4.1.11020.5.1.1.5  STRING "$submittedBy"
}
#
#send a Trap Indicating that a job stalled
#
if( $JAMS_NOTIFY_REASON -eq "STALLED")
{
./trapgen -d 192.168.12.133 `
 -o .1.3.6.1.4.1.11020 `
 -v .1.3.6.1.4.1.11020.5.12 STRING "Stalled Job Notification" `
 -v .1.3.6.1.4.1.11020.5.1.1.1 STRING "Job Stalled" `
 -v .1.3.6.1.4.1.11020.5.1.1.4 INTEGER "$entryNum" `
 -v .1.3.6.1.4.1.11020.5.1.1.2 STRING "$jobName" `
 -v .1.3.6.1.4.1.11020.5.1.1.3 STRING "$folderName" `
 -v .1.3.6.1.4.1.11020.5.1.1.5  STRING "$submittedBy" `
 -v .1.3.6.1.4.1.11020.5.15.0  STRING "$holdTime" 
}

 

 

This job can now be specified as the notification job of any JAMS job or setup under the "Notify Names" tab of a job definition.

In order to receive notifications, users must specify the location of the JAMS MIB file in the SNMP Trap receiver. The receiver should then be able to receive notifications from JAMS.
Have more questions? Submit a request

Comments

  • Avatar
    TAB Financials

    At this point it's very unclear in what we have to do with the MIB file. Do I need to install this into Jams? Place it somewhere?

  • Avatar
    Devon Lawler

    Hello,

    Generally the MIB file is going to be shared by both the Trap Generator and the Receiver itself. Naturally it will vary how these reference the MIB file itself; the receiver should have a way to load the MIB file to know what kind of messages it should expect. The Sender primarily needs to send valid messages based on what the MIB file defines, but doesn't necessarily have a hard reference to the MIB file itself.

    Thank you,

    Devon