Skip to content

Josh's IT-Blog

Information Technology, and other interesting things …

  • Home
  • About
  • Contact
  • Links

Create a calculated SNMP Rule in SCOM

Posted on 26. August 201122. June 2020 By Burkard Josh No Comments on Create a calculated SNMP Rule in SCOM
Network, SCOM, System Center

Sometimes you need a SCOM Rule 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 create a Rule and a Performance View to show the autonomny time for an APC UPS. The originaly readed value is in 1/100 seconds, but i want it to show in minutes.

Creating the Rule

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.4.1.318.1.1.1.2.2.3.0"))
if err.number = 0 then
   ' You can calculate the value here
   ' 1/100seconds to seconds
   intValue = intValue / 100
   ' seconds to minutes
   intValue = intValue / 60
end if
' Return the values to SCOM
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("DeviceIP", strDeviceIP)
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. To get the devices ip address and communitystring, you have to define this parameters, which could be readed by the script with Wscript.Arguments:

$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.

The evaluated values in the fields Instance and Value are derived from the vbscript’s object oBag.

Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("DeviceIP", strDeviceIP)
Call oBag.AddValue("PerfValue", intValue )
Call oAPI.Return(oBag)

Override the Rule for a group

Override the Rule to enable it for a specified group

Create the Performance View

Create a Performance View for the already defined Object name:

Share this:

  • Facebook
  • Twitter
  • Email
  • Print
Tags: SCOM 2007 R2 SNMP

Post navigation

❮ Previous Post: unwilling Server
Next Post: Downgrade Windows 7 from Enterprise/Ultimate Edition to lower Edition ❯

Leave a Reply Cancel reply

About

Author Image
My name is Josh Burkard.
I'm a DevOps 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.

Follow me on Twitter

My Tweets

Categories

  • General (13)
  • Hardware (9)
    • Network (8)
      • Cisco (2)
    • Storage (2)
  • Microsoft Azure (1)
    • Automation (1)
  • PowerShell (1)
  • Software (1)
    • Excel (1)
  • System Center (19)
    • SCCM (3)
    • SCDPM (1)
    • SCOM (13)
    • 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)

Links

  • Burkard-Fingerlin Family
  • Swisscom (Schweiz) AG
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

About

Author Image
My name is Josh Burkard.
I'm a DevOps 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.

Follow me on Twitter

My Tweets

FOLLOW ME ON GITHUB

joshburkard (Josh Burkard)

Josh Burkard

joshburkard
Belgium
https://www.burkard.it
Joined on Jul 10, 2015
13 Public Repositories
0 Public Gists

Copyright © 2023 Josh's IT-Blog.

Theme: Oceanly by ScriptsTown

 

Loading Comments...
 

    loading Cancel
    Post was not sent - check your email addresses!
    Email check failed, please try again
    Sorry, your blog cannot share posts by email.