Dell Remote Access : SNMP Trap DSMT

Dell.SNMPTrap.DSMT (DataSourceModuleType)

Data Source Module Type

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Event.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.SnmpTrapProvider Default
PA ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default
Mapper ConditionDetection System.Event.GenericDataMapper Default

Source Code:

<DataSourceModuleType ID="Dell.SNMPTrap.DSMT" Accessibility="Internal" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>System!System.ParamListSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element minOccurs="1" maxOccurs="1" name="IP" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="CommunityString" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Version" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="AllTraps" type="xsd:boolean"/>
<xsd:element minOccurs="0" maxOccurs="1" name="OIDProps">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="OIDProp" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="EventOriginId" type="xsd:string"/>
<xsd:element name="PublisherId" type="xsd:string"/>
<xsd:element name="PublisherName" type="xsd:string"/>
<xsd:element name="Channel" type="xsd:string"/>
<xsd:element name="LoggingComputer" type="xsd:string"/>
<xsd:element name="EventNumber" type="xsd:string"/>
<xsd:element name="EventCategory" type="xsd:string"/>
<xsd:element name="EventLevel" type="xsd:string"/>
<xsd:element name="UserName" type="xsd:string"/>
<xsd:element name="Params" type="ParamListType"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Snmp!System.SnmpTrapProvider">
<IP>$Config/IP$</IP>
<CommunityString>$Config/CommunityString$</CommunityString>
<AllTraps>$Config/AllTraps$</AllTraps>
<Version>$Config/Version$</Version>
<OIDProps>$Config/OIDProps$</OIDProps>
</DataSource>
<ProbeAction ID="PA" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>SNMPTrapProvider.vbs</ScriptName>
<Arguments>$Config/IP$ #*# $Data[Default='']/Version$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[1]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[1]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[2]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[2]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[3]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[3]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[4]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[4]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[5]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[5]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[6]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[6]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[7]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[7]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[8]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[8]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[9]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[9]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[10]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[10]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[11]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[11]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[12]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[12]/Value$ #*#
$Data[Default='']/SnmpVarBinds/SnmpVarBind[13]/OID$ #*# $Data[Default='']/SnmpVarBinds/SnmpVarBind[13]/Value$ ###</Arguments>
<ScriptBody><Script>
'**********************************************************************************
' Script Name - SNMPTrapProvider.vbs
' Author: Rashma
'
' Description:
'
' (c) Copyright &#xA9; 2009&#x2013; 2017 Dell Inc, or its subsidiaries. All Rights Reserved
'**********************************************************************************
Option Explicit
SetLocale("en-us")

Const DebugScript = False
Dim FileSystemObject
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Dim ParseOIDs, OidLookup, descLookup, DescrMap

'Arguments
' args(0) = ipaddress
' args(1) = version
' .
' args(N) args(N+1) - oid value


Dim oArgs(), oAPI, oBag, logMessage, myOid, tempSplit, drsCAMessage, drsCASubSystem, tOid, tOidValue
Dim logLevel : logLevel = 0

GetArguments WScript.Arguments, oArgs

Dim myIP: myIP = Trim(oArgs(0))
Dim trapver: trapver = Trim(oArgs(1))

CreateLog myIP
InitLookups

Set oAPI = CreateMOMScriptAPI
Set oBag = CreatePropertyBag(oAPI)
Dim cnt : cnt = 0

For cnt = 2 To UBound(oArgs) step 2
tOid = Trim(Replace(oArgs(cnt),"\n",""))
tOidValue = oArgs(cnt+1)
If(Strcomp(tOid, "") &lt;&gt; 0) Then
PropertyBagPopulator oBag, tOid, tOidValue
end If
Next


'Add SNMP Version to property bag
oBagAddValue oBag, "Version", trapver

ReturnData oAPI, oBag
set oAPI = nothing

'ProperyBagPopulator
Function PropertyBagPopulator(ByRef oBag, oid, val)
If descLookup.Exists(oid) then
'oBagAddValue oBag, descLookup.Item(oid), val
AddToPropertyBag descLookup.Item(oid), val
OidLookup.Add oid, val
Else
Dim i
Dim tSplit: tSplit = Split(oid,".")
Dim tstr: tstr = "." + tSplit(0)
for i=1 to Ubound(tSplit)-1
tstr = tstr+"."+tSplit(i)
next
'if the last digit is not 0, do not remove it
if tSplit(Ubound(tSplit)) &lt;&gt; "0" Then
tstr = tstr + "." + tSplit(Ubound(tSplit))
end if

If descLookup.Exists(tstr) then
'oBagAddValue oBag, descLookup.Item(tstr), val
AddToPropertyBag descLookup.Item(tstr), val
else
'oBagAddValue oBag, tstr, val
AddToPropertyBag tstr, val
end if
OidLookup.Add tstr, val
End If
End Function

Function AddToPropertyBag(ByVal key, val)
Dim statusStr
if (key = "drsAlertCurrentStatus") Then
Select case val
case 1
statusStr = val + "(Other)"
case 2
statusStr = val + "(Unknown)"
case 3
statusStr = val + "(Ok)"
case 4
statusStr = val + "(NonCritical)"
case 5
statusStr = val + "(Critical)"
case 6
statusStr = val + "(NonRecoverable)"
case else
statusStr = "Unknown"
end select
oBagAddValue oBag, key, statusStr
elseif (key = "EventNumber") Then
Dim tempSplit
tempSplit = Split(val,".")
oBagAddValue oBag, key, tempSplit(Ubound(tempSplit))
else
oBagAddValue oBag, key, val
end if
End Function

Function InitLookups
Set OidLookup = CreateObject("Scripting.Dictionary")
Set descLookup = CreateObject("Scripting.Dictionary")

'DRAC specific OIDs

descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.9", "drsChassisServiceTag"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.8", "drsAlertMessageArgs"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.7", "DeviceDisplayName"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.6", "drsAlertFQDD"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.5", "drsAlertFQDN"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.4", "drsSystemServiceTag"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.3", "drsAlertCurrentStatus"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.2", "drsAlertMessage"
descLookup.Add ".1.3.6.1.4.1.674.10892.5.3.1.1", "drsAlertMessageID"
descLookup.Add ".1.3.6.1.6.3.1.1.4.1", "EventNumber"

End Function

Function GetArguments(ByRef arglist, ByRef argArray)
Dim ArgumentIterator, ArgumentCounter, ArgumentBuffer , ArgumentTemp
ArgumentIterator = 0: ArgumentCounter = 0

Do
ArgumentTemp = arglist(ArgumentIterator)

' #*# is used as a delimiter between each of the arguments.
' ### is used as a token to show end of argument list.

if (StrComp(ArgumentTemp,"#*#") = 0) Then
ArgumentCounter = ArgumentCounter + 1
End if

' Going to the next argument delimited by space
ArgumentIterator = ArgumentIterator + 1
Loop while Not(StrComp(ArgumentTemp,"###") = 0)
Redim argArray(ArgumentCounter)

ArgumentIterator = 0: ArgumentCounter = 0
ArgumentBuffer = "Not Available"
Do
' iterate through the arguments passed to the VB Script
ArgumentTemp = arglist(ArgumentIterator)

' #*# is used as a delimiter between each of the arguments.
' ### is used as a token to show end of argument list.

if (StrComp(ArgumentTemp,"#*#") = 0) Or (StrComp(ArgumentTemp,"###") = 0) Then
argArray(ArgumentCounter) = ArgumentBuffer

' Going to the next actual argument delimited by #*#
ArgumentCounter = ArgumentCounter + 1
ArgumentBuffer = "Not Available"

elseif (StrComp(ArgumentBuffer,"Not Available") = 0) Then

ArgumentBuffer = ArgumentTemp

else

ArgumentBuffer = ArgumentBuffer &amp; " " &amp; ArgumentTemp

End if

' Going to the next argument delimited by space
ArgumentIterator = ArgumentIterator + 1

Loop while Not(StrComp(ArgumentTemp,"###") = 0)

End Function

' Begin Logheader
Dim objLogTextFile

Function CreateLog(myIP)
If logLevel &lt;&gt; 0 Then
Dim fileSize, strOutFile, newFilename, dateStr, datesuffix, timesuffix, subStrLoc, hyphenIP
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB
Dim strFileName

dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim mdmpFolder : mdmpFolder = "cmc_Traps_Logs"
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
hyphenIP = myIP
If ( InStr(hyphenIP,".") &gt; 0 ) Then
hyphenIP = Replace(hyphenIP,".","_")
End If
If ( InStr(hyphenIP,":") &gt; 0 ) Then
hyphenIP = Replace(hyphenIP,":","_")
End If
strFileName = "SNMPTraps" &amp; hyphenIP &amp; ".log"

If Not FileSystemObject.FolderExists(tFolder) Then
FileSystemObject.CreateFolder(tFolder)
End If
If Not FileSystemObject.FolderExists(tFolder &amp; "\" &amp; mdmpFolder) Then
FileSystemObject.CreateFolder(tFolder &amp; "\" &amp; mdmpFolder)
End If
strOutFile = tFolder &amp; "\"&amp; mdmpFolder &amp; "\" &amp; strFileName
DebugOut "Logging to " &amp; strOutFile
If Not FileSystemObject.FileExists(strOutFile) Then
Set objLogTextFile = FileSystemObject.CreateTextFile(strOutFile)
objLogTextFile.Close()
End If
fileSize = FileSystemObject.GetFile(strOutFile).Size
If (fileSize &gt; MaxFileSize) Then
dateStr = CDate(Now())
datesuffix = ( Year(dateStr)*100 + Month(dateStr) )*100 + Day(dateStr)
timesuffix = Right((Hour(dateStr)*100+Minute(dateStr))*100+Second(dateStr)+1e7, 6)
subStrLoc = Instr(1, strOutFile,".")
newFilename = Mid(strOutFile,1,(subStrLoc-1))
newFilename = newFilename &amp;"-"&amp; datesuffix &amp;"-"&amp;timesuffix&amp;".log"
DebugOut "MoveFile " &amp; strOutFile &amp; " to " &amp; newFilename
FileSystemObject.MoveFile strOutFile, newFilename
Set objLogTextFile = FileSystemObject.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = FileSystemObject.OpentextFile(strOutFile, ForAppending, True)
End If
Err.Clear
End If

End Function

Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
DebugOut Message
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End Sub
' End of Logheader

'********** SCOM Functions
Function CreateMOMScriptAPI
If DebugScript = False Then
Set CreateMOMScriptAPI = CreateObject("MOM.ScriptAPI")
Else
Set CreateMOMScriptAPI = New RegExp
End If
logMessage = "INFO: New MOM.ScriptAPI"
MOMDebugLog 1, logMessage
End Function

Function CreatePropertyBag(ByRef oAPI)
If DebugScript = False Then
set CreatePropertyBag = oAPI.CreatePropertyBag()
Else
Set CreatePropertyBag = New RegExp
End If
logMessage = "INFO: New Property Bag"
MOMDebugLog 1, logMessage
End Function

Function ReturnData (ByRef oAPI, ByRef oData)
If DebugScript = False Then
Call oAPI.Return(oData)
End If
logMessage = "INFO: Returning Data to SCOM"
MOMDebugLog 1, logMessage
End Function

Sub oBagAddValue(ByRef oBag, prop, val)
If DebugScript = False Then
Call oBag.AddValue(prop, val)
End If
logMessage = "INFO: Set prop:" &amp; prop &amp; "; key = " &amp; val
MOMDebugLog 1, logMessage
End Sub

Sub oAPIAddItem(ByRef oAPI, ByRef oBag)
If DebugScript = False Then
Call oAPI.AddItem(oBag)
End If
logMessage = "INFO: Add Instance to Property Bag"
MOMDebugLog 1, logMessage
End Sub

Function DebugOut(message)
If DebugScript Then WScript.Echo message
End Function
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
<ConditionDetection ID="Mapper" TypeID="System!System.Event.GenericDataMapper">
<EventOriginId>$Config/EventOriginId$</EventOriginId>
<PublisherId>$Config/PublisherId$</PublisherId>
<PublisherName>$Config/PublisherName$</PublisherName>
<Channel>$Config/Channel$</Channel>
<LoggingComputer>$Config/LoggingComputer$</LoggingComputer>
<EventNumber>$Config/EventNumber$</EventNumber>
<EventCategory>$Config/EventCategory$</EventCategory>
<EventLevel>$Config/EventLevel$</EventLevel>
<UserName>$Config/UserName$</UserName>
<Params>$Config/Params$</Params>
</ConditionDetection>
</MemberModules>
<Composition>
<Node ID="Mapper">
<Node ID="PA">
<Node ID="DS"/>
</Node>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Event.Data</OutputType>
</DataSourceModuleType>