Please consider donating: https://www.corelan.be/index.php/donate/


2,935 views

Using custom/non-Performance Counter data to build graphs in Operations Manager 2007

It is pretty easy to use data collected by Performance monitors in Counter objects within OpsMgr 2007. You can create graphs, create rules/monitors alerts, etc

But you can do the same with any type of information that can be gathered by e.g. a vbs vbscript

Suppose you want to monitor the number of files in a given folder, and use this in a graph, then this is what you should do :

 

First, you need to build a script that will return the collected data in a property bag, so you can use it as it is was performance collection data

A basic script to monitor the number of files in a given folder could look like this :

 

Option Explicit

‘ Script that monitors the returns the number of files in a given folder (parameter 1)
‘ Written by Peter Van Eeckhoutte
https://petersblog.dyndns.org:8899
‘ peter.ve@telenet.be
‘ April 2008
‘ version 1.0

‘ The script should be called with the following parameters (separate parameters with a single blank space)
‘ Parameter 1 : absolute path to the folder that needs to be monitored.  Make sure to put the path between double quotes

Dim oArgs
Set oArgs = Wscript.Arguments
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")

if oArgs.Count < 1 Then
    ‘ If the script is called without the required argument,
    ‘ create an information event and then quit.
    Call oAPI.LogScriptEvent(WScript.ScriptName,851,0,WScript.ScriptName+" script was called without the necessary argument and was not executed. You need to specify the absolute path to the folder that needs to be monitored")
    Wscript.Quit -1
    Else
    Call oAPI.LogScriptEvent(WScript.ScriptName,951,0,WScript.ScriptName+" script was launched successfully")
End If

Dim oFso
Dim oBag
Dim NrOfFiles


Set oFso = CreateObject("Scripting.FileSystemObject")

If oFso.FolderExists(oArgs(0)) Then
  NrOfFiles=oFso.GetFolder(oArgs(0)).Files.Count
  Else
   NrOfFiles=0
End If
Set oBag = oAPI.CreatePropertyBag()

Call oBag.AddValue("NrOfFiles",NrOfFiles)
Call oAPI.LogScriptEvent(WScript.ScriptName,890,0,"Files found in " & oArgs(0) & " : " & NrOfFiles)
Call oAPI.Return(oBag)

 

Graphing custom data

First, we need to set up OpsMgr to run the script on our targets, in such a way that the collected information would become available

In short, this is what we need to do before we can use the data :

– create a PerformanceCollection rule and then create overrides for each of the servers that need to be monitored

– create a performance view to see the data

Go to rules, right click and create a Probe based rule, and interpret the results as performance data

image_6

Save the rule in a custom management pack and click next to continue

Set a good name, set the target to Windows Operating System, set the category to PerformanceCollection (you will have to scroll up to see the Collection Categories) and leave the rule DISABLED for now

Set the target to a class/group containing Operating System objects

image_50

Set the schedule (e.g. 15 minutes)

image_10

Set a good script name (don’t forget the vbs extension), paste the script from the table above (make sure not to miss any carriage returns)

Set the script timeout

image_12

Click the parameters button and enter the path that you want to monitor   e.g.  "D:\"

image_14

Set the performance mapping information to the variable that is returned by the script

In my example, this is "NrOfFiles"

image_16

Create the rule

The rule is now disable, so you need to create an override for each server, and set "Enabled" to true for those servers. Additionally, you can specify another path per server by changing the Parameter field

image_18

 

image_20

 

Save the override and wait until the script runs.

Check the Operations Manager eventlogs on the target machine(s) and verify that the script has ran and completed succesfully

 

If the scrip ran fine, we’ll create a graph to display the results

Open the monitoring pane, find the folder that represents your custom management pack

Right click and choose "New >  Performance View"

image_22

Set a good name

Criteria : Show data related to  "Windows 2003 Computer" (select the same group that was used when you’ve created the rule)

image_24

 

Enable "collected by specific rules"

image_26

 

Click the "specific" link under Criteria Description and select the newly created Rule

image_54

 image_56

 

Save the graph

Wait until data starts flowing back to OpsMgr and you should see the performancecollection objects. After enabling the objects you want to see, the graph lines should become visible as well.

image_58

 

Using custom data to create alerts / monitors

You can use the same script to create alerts (using a rule or a monitor) – browse through this blog to find more information on creating monitors based on scripts and use the data from the PropertyBag in the unhealthy or healthy expression builder

© 2008 – 2021, Peter Van Eeckhoutte (corelanc0d3r). All rights reserved.

Comments are closed.

Corelan Training

We have been teaching our win32 exploit dev classes at various security cons and private companies & organizations since 2011

Check out our schedules page here and sign up for one of our classes now!

Donate

Want to support the Corelan Team community ? Click here to go to our donations page.

Want to donate BTC to Corelan Team?



Your donation will help funding server hosting.

Corelan Team Merchandise

You can support Corelan Team by donating or purchasing items from the official Corelan Team merchandising store.

Protected by Copyscape Web Plagiarism Tool

Corelan on Slack

You can chat with us and our friends on our Slack workspace:

  • Go to our facebook page
  • Browse through the posts and find the invite to Slack
  • Use the invite to access our Slack workspace
  • Categories