Skip to content

Josh's IT-Blog

Information Technology, and other interesting things …

  • Home
  • About
  • Contact
  • Links
  • Home
  • About
  • Contact
  • Links

Create a calculated SNMP monitor

  1. Home   »  
  2. Create a calculated SNMP monitor

Create a calculated SNMP monitor

11. October 201122. June 2020 Burkard JoshSCOMTagged SCOM 2007 R2, SNMP

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:

Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
On Error Resume Next
err.clear
Dim oArgs
Set oArgs = WScript.Arguments
strDeviceIP = oArgs(0)
strCommunity = Decode(oArgs(1))
set objSNMP = 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
Set oBag = oAPI.CreatePropertyBag()
If intValue < 45 Or intValue > 55 Then
   Call oBag.AddValue("devState", "BAD")
Else
   Call oBag.AddValue("devState", "GOOD")
End If
Call oBag.AddValue("PerfValue", intValue )
Call oAPI.Return(oBag)

Function Decode(strB64)
' decode CommunityString
   strXML = "<B64DECODE xmlns:dt=" & Chr(34) & _
   "urn:schemas-microsoft-com:datatypes" & Chr(34) & " " & _
   "dt:dt=" & Chr(34) & "bin.base64" & Chr(34) & ">" & _
   strB64 & "</B64DECODE>"
   Set oXMLDoc = CreateObject("MSXML2.DOMDocument.3.0")
   oXMLDoc.LoadXML(strXML)
   decode = oXMLDoc.selectsinglenode("B64DECODE").nodeTypedValue
   set oXMLDoc = nothing
End Function

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:

$Target/Property[Type="MicrosoftSystemCenterNetworkDeviceLibrary6172210!Microsoft.SystemCenter.NetworkDevice"]/IPAddress$ $Target/Property[Type="MicrosoftSystemCenterNetworkDeviceLibrary6172210!Microsoft.SystemCenter.NetworkDevice"]/CommunityString$ $Target/Property[Type="MicrosoftSystemCenterNetworkDeviceLibrary6172210!Microsoft.SystemCenter.NetworkDevice"]/Version$

Please note, that all parameters have to be insert as one (1) line, separated only with a space.

You created your first calculated SNMP monitor, but you didn’t enable it. To enable it, you have to create an override for a group, containing the desired devices.

Post navigation

Previous: Clone your Active Directory in 18 minutes using VMware
Next: Collect warranty informations with SCCM

About

Author Image
My name is Josh Burkard.
I'm a DevOps Engineer working with one of Europees largest payroll 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.

Categories

  • General (13)
  • Hardware (9)
    • Network (8)
      • Cisco (2)
    • Storage (2)
  • Hiking (1)
  • Home Assistant (5)
  • Microsoft Azure (1)
    • Automation (1)
  • PowerShell (3)
  • Software (1)
    • Excel (1)
  • System Center (18)
    • SCCM (3)
    • SCDPM (1)
    • SCOM (12)
    • SCSM (1)
    • SMA (1)
  • VMware (8)
  • Windows 2008 R2 (10)
    • Active Directory (7)
  • Windows 2012 R2 (1)
  • Windows 2016 (1)
  • Windows 7 (4)
    • BitLocker (1)
  • WordPress (1)
Proudly powered by WordPress | Theme: goldy-mex by inverstheme.