Using snmptraps are good stuff...
You could:
1. configure your autouser to send snmp traps on localhost
SnmpManagerHosts=127.0.0.1
SnmpCommunity=scheduler
install snmptrapd and configure snmptrapd.conf like this :
authCommunity log,execute,net scheduler
# trapJobFailure
traphandle .1.3.6.1.4.1.791.3.2.1.0.503 /usr/bin/perl /path/to/my/autosys_trap_hook_script.pl
(hook only for trapJobFailure)
And script an api rest call to create a case in servicenow (snow works well with Soap::lite, or even with something like https://metacpan.org/pod/ServiceNow::SOAP).
The mib of autosys in $AUTOSYS/snmp/CA.my.
Here are the information you could push into your ticket..
trapJobFailure TRAP-TYPE
ENTERPRISE autosys
VARIABLES { trapMessage, trapDate, alarmName, alarmJobName,
alarmText, alarmCode, alarmExitCode, alarmMachineName,
alarmBoxName, alarmApplicationName, alarmGroupName,
alarmRunNum, alarmNtry, alarmInstanceName}
DESCRIPTION
"Trap to indicate a job has failed"
::= 503
Here is a start for a hook script in snmptrapd, which loads the mib and translates OIDs in proper names...
#!/bin/env perl -W
use strict;
use warnings;
use utf8;
use English qw( -no_match_vars );
use Carp;
use Data::Dumper;
use SNMP;
my $SNMPv2_SMI_enterprises_CA_id;
my $SNMPv2_SMI_enterprises;
my $SNMPv2_ID;
my $autosys_mib;
my $verbose = "INFO";
my %trapdata;
my $trapoid;
my $trapname;
BEGIN {
$SNMP::save_descriptions = 1;
$SNMPv2_SMI_enterprises_CA_id = ".791";
$SNMPv2_SMI_enterprises = ".1.3.6.1.4.1";
$SNMPv2_ID = sprintf("%s%s", $SNMPv2_SMI_enterprises, $SNMPv2_SMI_enterprises_CA_id);
$autosys_mib = {};
my $CA_match = qr/^$SNMPv2_ID/;
SNMP::addMibDirs("/usr/share/snmp/mibs/");
SNMP::addMibFiles("/opt/CA/autosys/snmp/CA.my");
SNMP::initMib();
foreach my $mib (keys %SNMP::MIB) {
# skip non autosys objects
next if $mib !~ $CA_match;
$autosys_mib->{$mib} = $SNMP::MIB{$mib};
#print $mib, " - ", $SNMP::MIB{$mib}->{label},"\n";
}
}
my $oo = <>; # skip line, useless
my $bo = <>; # skip line, useless
print "A new trap happened\n" if grep (/$verbose/,("DEBUG", "INFO"));
# translation
while (my $line = <>) {
chomp $line;
next if $line eq "";
$line =~ s/SNMPv2-SMI::enterprises/$SNMPv2_SMI_enterprises/;
print $line,"\n" if grep (/$verbose/, ("DEBUG"));
my ($oid, @v) = split(/\s+/, $line);
if ($oid eq "SNMPv2-MIB::snmpTrapOID.0") {
$trapoid = $v[0];
$trapname = $autosys_mib->{$trapoid}->{label};
$trapdata{"description"} = $autosys_mib->{$trapoid}->{description};
print "Trap: $trapname - $trapdata{'description'}\n" if grep(/$verbose/,("DEBUG", "INFO", "WARNING", "ERROR", "FATAL"));
} else {
if ($oid =~ /$SNMPv2_ID/) {
my $label = $autosys_mib->{$oid}->{label};
my $v = join(" ", @v);
$v =~ s/(\A"|"\Z)//g; # remove leading and trailing double quote...
$trapdata{$label} = $v;
}
}
}
# do whatever you want from now...
my $trap = $class->new(%trapdata);
This will display a much better info in /var/log/snmptrapd.log
------------------------------
[JobTitle]
[CompanyName]
------------------------------
Original Message:
Sent: Nov 23, 2022 10:59 AM
From: Craig Hanson
Subject: Autosys and ServiceNow
Has anyone integrated Autosys to ServiceNow to automatically create incidents on job failures, if so how? Splunk? I know you can use snmp, but your limited on customization then.