We started with the idea to generate alerts from Splunk that would forward to IBM Tivoli Netcool. This can be used with any SNMP aggregator, and can be customized to send any data that is needed. This article can be used in conjunction with Splunk Rules for Netcool to integrate Splunk with Netcool. This assumes you are running Splunk on *nix.
Here is our trap.pl file:
#!/usr/bin/perl -w $Dest = "XXX.XXX.XXX.XXX:162"; # SNMP Destination Host and Port
$TrapCmd = "/usr/bin/snmptrap"; # Path to snmptrap executable, from http://www.net-snmp.org
$TrapOID = "220.127.116.11.4.1.27389.1.2"; # Object ID for traps/notifications, Splunk Enterprise OID is 27389
<div id='ndzm'><a href='http://www.bissglobal.com/24-hour-home-loan-approval' rel='nofollow'>24 hour home loan approval</a></div>
$OID = "18.104.22.168.4.1.27389.1.1"; # Object ID for objects, Splunk Enterprise OID is 27389
# Parameters are passed from Splunk in the form of environment variables during the .pl call.
# $1-$9 is the positional parameter list. $ARGV starts at $1 in Perl.
$searchCount = $ARGV; # $1 - Number of events returned
$searchTerms = $ARGV; # $2 - Search terms
$searchQuery = $ARGV; # $3 - Fully qualified query string
$searchName = $ARGV; # $4 - Name of saved search
$searchReason = $ARGV; # $5 - Reason saved search triggered
$searchURL = $ARGV; # $6 - URL/Permalink of saved search
$searchPath = $ARGV; # $8 - Path to raw saved results in Splunk instance (advanced)
# You can put logic in to decide severity on this end. For this example we will hard code it on the Netcool end.
# Build the command using the variables defined above.
$cmd = qq/$snmpTrapCmd -v 2c -c <Community String> $Dest '' $TrapOID $OID.1 i $searchCount $OID.2 s "$searchTerms" $OID.3 s "$searchQuery" $OID.4 s "$searchName" $OID.5 s "$searchReason" $OID.6 s "$searchURL" $OID.8 s "$searchPath"/;
#Run the command
Modify the variables to match your environment and drop it in $SPLUNK_HOME/bin/scripts. In the Splunk GUI, configure an alert and tell it to run a script. In our case, we called the script trap.pl, so simply enter trap.pl in the script box.
Guarding your IT Experience!