Performance Monitor Query

Created by BSOD2600
Version: 1.0

 

Background

This script is merely a wrapper around the Microsoft tool typeperf which is designed to query a single performance counter at a time. Typeperf leverages WMI, which requires user authentication, correct permission levels and of course only works from Windows. In the case of Cacti, typeperf will be executed with the permissions of the Cacti Scheduled Task. The query format typeperf requires can be somewhat confusing to figure out. The link above lists all the nitty-gritty details. Some simple examples though are below:

Check your Total CPU usage:
C:\>typeperf "\processor(_Total)\% Processor Time"

Check your available memory in bytes:
C:\>typeperf "\memory\Available Bytes"

Another method to figuring out the correct format is to look how the Windows Performance Monitor (perfmon.msc) formats the counters you're interested in. After the counters have been added and successfully retrieving data, right click on the graph and select Properties. Click on the Data Tab. You now can copy down the paths which are used.

perfmon properties

 

Installation

  1. Place perfmon_query.cmd in your \cacti\scripts\ folder.
  2. Import the templates
  3. Click on Data Sources
    1. Add Performance Monitor Query and specify the Host
    2. Change the name to reflect the counter name.
    3. Type in the typeperf query, making sure to surround it with double quotes. No need to put in the full path to the computer name as the script already handles it.
      data template
  4. Click on Graph Management
    1. Add Performance Monitor Query and specify the Host.
    2. Change the name to reflect the counter name.
    3. Change the Base Value, if required.
    4. Change the Veritcal Lable, if required.
    5. Change the Graph Color, if desired
    6. Select the correct Data Source, previously just created.
    7. Set the Graph Title
      graph template

  5. Wait 2 polling cycles (10 minutes) before the graph will contain data.