Just in case anyones ever interested, I ended up writing a script to pull the trap description from the mib file. You need to tell the script the mib file beforehand, in the one below it is for compaq server traps, and the passive monitor is set to listen for any HP enterprise traps.The script works by reading in the trap minor number, searching the mib file, then pulling off the description and wrapping it up in an email. Hope this is of use to anyone.
Dim objFile, objFSO, objMessage
Dim strMIBFile, strInputFile, strTrapPayload, strTrapMinor, strTrapSearch
Dim strDescription, strSearchString, strTemp
Dim intFileLine, intDescLine, i, j, intCounter
Dim strSubject, strFrom, strTo, strTextBody, strServer
On error resume next
'MIB file
strMIBFile = "cpqhlth.mib"
strInputFile = "C:\Program Files\Ipswitch\WhatsUp\Data\Mibs\" + strMIBFile
strTrapPayload = "%PassiveMonitor.LoggedText"
'String to find trap definition in MIB file
If InStr(strTrapPayload, "TrapMinor") > 0 Then
strTrapMinor = Right(Left (strTrapPayload,InStr(strTrapPayload, "TrapMinor") + 13), 4)
End If
strTrapSearch = "::= " + strTrapMinor
'Email fields
strSubject = "%Device.HostName SNMP Trap Notification"
strFrom = "whatsupgold@yourcompany.com"
strTo = "whoevercares@yourcompany.com"
strTextBody = "" 'defined below once all info is obtained
strServer = "yourmailserver"
intFileLine = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strInputFile, 1)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
intFileLine = intFileLine + 1
If InStr(strSearchString, strTrapSearch) > 0 Then
intDescLine = intFileLine - 20
End If
Loop
objFile.Close
'intFileLine = intFileLine - 15
Set objFile = objFSO.OpenTextFile(strInputFile, 1)
For i = 1 To intDescLine
objFile.SkipLine
Next
intCounter = 0
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
intDescLine = intDescLine + 1
If InStr(strSearchString, "DESCRIPTION") > 0 And intCounter = 0 Then
intCounter = intCounter + 1
For j = 1 To 10
strTemp = objFile.ReadLine
If InStr(strTemp, "--#") = 0 Then
strTemp = LTrim(strTemp)
strDescription = strDescription + strTemp + " "
Else
j = 10
End If
Next
End If
Loop
objFile.Close
'Main email body:
strTextBody = "%Device.HostName has reported an incident via an SNMP trap." & chr(13) & chr(13)
strTextBody = strTextBody & "Description: " & chr(13) & chr(13) & strDescription & chr(13) & chr(13)
strTextBody = strTextBody & "----------------------------------------------------------------------------------------------------------" & chr(13) & chr(13)
strTextBody = strTextBody & "SNMP trap payload: " & chr(13) & chr(13)
strTextBody = strTextBody & "%PassiveMonitor.LoggedText" & chr(13) & chr(13)
strTextBody = strTextBody & "----------------------------------------------------------------------------------------------------------" & chr(13) & chr(13)
strTextBody = strTextBody & "This mail was sent on %System.Date at %System.Time"
'Sending the email alert
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = strSubject
objMessage.From = strFrom
objMessage.To = strTo
objMessage.TextBody = strTextBody
'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strServer
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send