WMI Data Collection Tutorial
Subscribe

From OpenNMS

Jump to: navigation, search

Contents

WMI Data Collection Tutorial

This tutorial intends to be a guide through the basic steps you should follow to retrieve data and generate graphical reports using Windows Management Interface (WMI) from a Windows Server.

The default configuration files provide a sample set of metrics and graph templates to retrieve data using WMI.

Credentials

Before beginning to use the WMI data collection, you will need to configure it appropriate by editing the $OPENNMS_HOME/etc/wmi-config.xml and providing it with information about your Windows environment.

Note.png On Windows

WMI will require a domain administrator, a local administrator or a user with the capability of remote registry and DCOM component access. The Remote Registry service must also be enabled.


You will have to configure the WMI configuration file which, if you're familiar with the SNMP equivalent, is very simple. Here is an example of what a configuration may look like:

NOTE: You have to specify a definition for an IP range or a specific IP. Not specifying a definition does not imply scan everything automatically.

<wmi-config retry="2" timeout="1500"
    username="Administrator" domain="WORKGROUP" password="password">
  <definition username="DomainUserA" domain="MYDOMAIN" password="unsecurepwd">
    <range begin="192.168.1.1" end="192.168.1.10"/>
  </definition>
  <definition  username="BobVilla" domain="MYMACHINENAME" password="buildahouse">
    <specific>192.168.1.12</specific>
  </definition>        
</wmi-config>

Collection Package

The first thing you need to do is to create a package (or modify the default package) inside $OPENNMS_HOME/etc/collectd-configuration.xml to add the service that will be associated with the WMI collector.

Because the default configuration has already a service defined for WMI, the only thing you need to do is change the status from “off” to “on”:

<package name="example1">
...
  <service name="WMI" interval="300000" user-defined="false" status="on">
    <parameter key="collection" value="default"/>
    <parameter key="thresholding-enabled" value="true"/>
  </service>
</package>
<collector service="WMI" class-name="org.opennms.netmgt.collectd.WmiCollector"/>

This will associate the WMI Collector to all nodes which contain a service called WMI.

The parameter collection is associated with the WMI Collection name defined on $OPENNMS_HOME/etc/wmi-datacollection-config.xml.

WMI Data Collection Config

There are two kinds of data:

  • Single Instance Data, to store a specific metric that will be stored at node's level, for example:
<wpm name="wmiOSMemory" wmiClass="Win32_PerfFormattedData_PerfOS_Memory"
     keyvalue="Name" recheckInterval="3600000"
     ifType="all" resourceType="node">
  <attrib name="AvailableBytes" alias="wmiOSMemAvailBytes"
     wmiObject="AvailableBytes" type="Gauge"/>
  <attrib name="CacheBytes" alias="wmiOSMemCacheBytes"
     wmiObject="CacheBytes" type="Gauge"/>
  <attrib name="CacheFaultsPerSec" alias="wmiOSMemCacheFaults"
     wmiObject="CacheFaultsPerSec" type="Counter"/>
  <attrib name="CommitLimit" alias="wmiOSMemCommitLimit"
     wmiObject="CommitLimit" type="Gauge"/>
  <attrib name="CommittedBytes" alias="wmiOSMemCommitted"
    wmiObject="CommittedBytes" type="Gauge"/>
  <attrib name="PageFaultsPerSec" alias="wmiOSMemPgFaultsSec"
    wmiObject="PageFaultsPerSec" type="Gauge"/>
  <attrib name="PoolNonpagedAllocs" alias="wmiOSMemNPPAllocs"
    wmiObject="PoolNonpagedAllocs" type="Counter"/>
  <attrib name="PoolPagedAllocs" alias="wmiOSMemPPAllocs"
    wmiObject="PoolPagedAllocs" type="Counter"/>
</wpm>
  • Multiple Instance Data, to store metrics from objects having multiple instances like network interfaces or filesystems, for example:
<wpm name="wmiLogicalDisk" wmiClass="Win32_PerfFormattedData_PerfDisk_LogicalDisk"
     keyvalue="Name" recheckInterval="3600000"
     ifType="all" resourceType="wmiLogicalDisk">
  <attrib name="LogDiskName" alias="wmiLDName"
    wmiObject="Name" type="string"/>
  <attrib name="FreeMegabytes" alias="wmiLDPctFreeMBytes"
    wmiObject="FreeMegabytes" type="Gauge"/>
  <attrib name="PercentLogDiskReadTime" alias="wmiLDPctDiskRdTime"
    wmiObject="PercentDiskReadTime" type="Gauge"/>
  <attrib name="PercentLogDiskWriteTime" alias="wmiLDPctDiskWrTime"
    wmiObject="PercentDiskWriteTime" type="Gauge"/>
  <attrib name="PercentFreeSpace" alias="wmiLDPctFreeSpace"
    wmiObject="PercentFreeSpace" type="Gauge"/>
  <attrib name="SplitLogIOPerSec" alias="wmiLDSplitIOsPerSec"
    wmiObject="SplitIOPerSec" type="Gauge"/>
</wpm>

Each column name contains 4 elements: the name of the metric, the alias to be used inside the RRDs, the WMI Object is the name of the metrics that belongs to the WMI class defined at WPM level; and the type of the numeric value (gauge or counter).

The keyvalue in WPM is related with the way to uniquely identify each resource in OpenNMS.

For each custom resource type, there is an entry on $OPENNMS_HOME/etc/datacollection/wmi.xml, for example:

<resourceType name="wmiPhysicalDisk" label="Windows Physical Disk"
     resourceLabel="${wmiPDName}">
  <persistenceSelectorStrategy
    class="org.opennms.netmgt.collectd.PersistAllSelectorStrategy"/>
  <storageStrategy
    class="org.opennms.netmgt.dao.support.IndexStorageStrategy"/>
</resourceType>

Graph Templates

The file $OPENNMS_HOME/etc/snmp-graph.properties, contains the templates for the metrics defined on wmi-datacollection-config.xml, for example:

report.wmi.physdisk.time.name=Percent Physical Disk Time (WMI)
report.wmi.physdisk.time.columns=wmiPDPctDiskRdTime,wmiPDPctDiskWrTime
report.wmi.physdisk.time.propertiesValues=wmiPDName
report.wmi.physdisk.time.type=wmiPhysicalDisk
report.wmi.physdisk.time.command=--title="Percent Physical Disk {wmiPDName} Time (WMI)" \
 --vertical-label="Percent Time" \
 --lower-limit 0 \
 --upper-limit 100 \
 --units-exponent 0 \
 DEF:pctread={rrd1}:wmiPDPctDiskRdTime:AVERAGE \
 DEF:minPctread={rrd1}:wmiPDPctDiskRdTime:MIN \
 DEF:maxPctread={rrd1}:wmiPDPctDiskRdTime:MAX \
 DEF:pctwrite={rrd2}:wmiPDPctDiskWrTime:AVERAGE \
 DEF:minPctwrite={rrd2}:wmiPDPctDiskWrTime:MIN \
 DEF:maxPctwrite={rrd2}:wmiPDPctDiskWrTime:MAX \
 AREA:pctread#00ff00:"Read " \
 GPRINT:pctread:AVERAGE:"Avg \\: %10.2lf" \
 GPRINT:minPctread:MIN:"Min \\: %10.2lf" \
 GPRINT:maxPctread:MAX:"Max \\: %10.2lf\\n" \
 STACK:pctwrite#0000ff:"Write" \
 GPRINT:pctwrite:AVERAGE:"Avg \\: %10.2lf" \
 GPRINT:minPctwrite:MIN:"Min \\: %10.2lf" \
 GPRINT:maxPctwrite:MAX:"Max \\: %10.2lf\\n"

Remember that each template should be declared inside the entry “reports” at the beginning of the file.

Restart OpenNMS

You can check if you are able to access the server through WMI using a script named $OPENNMS_HOME/bin/checkwmi like this:

./checkwmi -matchType all -wmiClass Win32_BIOS -wmiObject Status -op EQ -value OK \
   -domain . 192.168.0.254 your_user_name_here your_password_here

This should produce an output like the following; if not, you should check your credentials and/or windows settings:

Checking:  for Status Op: EQ Val: OK
Check results: OK (1)
Result for (1) Win32_BIOS\Status: OK

After making changes in collectd-configuration.xml, wmi-config.xml and/or wmi-data-datacollection-config.xml you must restart OpenNMS.

Configure Nodes

Based on how has been configured Collectd for this particular tutorial, you need to add the service WMI to the node (or nodes) you want to monitor using WMI.