Information Technology, and other interesting things ...

Create a calculated SNMP monitor

Sometimes you need a SCOM monitor which was calculated from one or more SNMP values. Maybe the values have to be calculated, cause the value is in an unhandy format or unit. In this example i will monitor the input frequency for an for an UPS. The originaly readed value is in 1/10 Hz, but i like to monitor in Hz.

Create the monitor

Select Timed Script Two State Monitor and select the destination managementpack.

Insert this code to the field Script:

Visual Basic

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

DimoAPI,oBag

SetoAPI=CreateObject("MOM.ScriptAPI")

On ErrorResumeNext

err.clear

DimoArgs

SetoArgs=WScript.Arguments

strDeviceIP=oArgs(0)

strCommunity=Decode(oArgs(1))

setobjSNMP=CreateObject("OlePrn.OleSNMP")

objSNMP.Open strDeviceIP,strCommunity,2,1000

intValue=Int(objSNMP.Get(".1.3.6.1.2.1.33.1.4.2.0"))

intValue=intValue/10

' Return the values to SCOM

SetoBag=oAPI.CreatePropertyBag()

IfintValue&lt;45OrintValue&gt;55Then

CalloBag.AddValue("devState","BAD")

Else

CalloBag.AddValue("devState","GOOD")

EndIf

CalloBag.AddValue("PerfValue",intValue)

CalloAPI.Return(oBag)

FunctionDecode(strB64)

' decode CommunityString

strXML="&lt;B64DECODE xmlns:dt="&amp;Chr(34)&amp;_

"urn:schemas-microsoft-com:datatypes"&amp;Chr(34)&amp;" "&amp;_

"dt:dt="&amp;Chr(34)&amp;"bin.base64"&amp;Chr(34)&amp;"&gt;"&amp;_

strB64&amp;"&lt;/B64DECODE&gt;"

SetoXMLDoc=CreateObject("MSXML2.DOMDocument.3.0")

oXMLDoc.LoadXML(strXML)

decode=oXMLDoc.selectsinglenode("B64DECODE").nodeTypedValue

setoXMLDoc=nothing

EndFunction

As you see, you have to define the SNMP OID in the script. After this you can calculate with the returned value and define rules for the GOOD and BAD state.

To get the devices ip address and communitystring, you have to define this parameters, which could be readed by the script with Wscript.Arguments. Click to the Parameters-button:

Primary Sidebar

About

My Name is Josh Burkard.
I'm a Senior Systems Engineer working with one of swiss largest telecom and full-service hosting provider. in my work I have a lot to do with Microsoft server operating systems, System Center, VMware, Microsoft Azure Cloud and other software.
On this site I will write some posts about different technology problems and their solutions.
please note also my tweets and retweets from this area.