Here are some very brief instructions on getting the WMI Mapper and wbemcli stuff working.
First, download and install the WMI Mapper package linked above from HP. Then go into the directory where you installed it. In that directory is a file called "cimserver_planned.conf" and another file called "cimserver_current.conf". The "planned" file is read whenever the service starts, and is then copied over the "current" file (yeah its weird but there ya have it).
Edit the cimserver_planned.conf file, and (1) disable the HTTPS service for now, and (2) enable the regular HTTP service. Later on you can come back and do what's needed to get the "secure" WBEM channel working, which essentially involves creating certificates and private keys for the mini HTTPS daemon, but for now just turn it off. The daemon won't run if there are any HTTPS problems so just turn it off. Is it off?
Restart the Pegasus WMI Mapper service, and then make sure that something is listening on TCP port 5988 (that's the WBEM-over-HTTP port, while 5989 is the WBEM over HTTPS port).
If its running and listening, you can connect to it with a WBEM client like wbemcli by providing the full URL of the WBEM-HTTP service. Essentially wbemcli is just a front-end wrapper for a regular HTTP agent, so you have to provide all of the HTTP details, including authentication stuff, the fully-qualified domain name of the host, the target namespace, the target class, etc. You have to conform completely to the HTTP specs here, and this bites a lot of people in the rear. Like, you really have to specify the fully-qualified domain name, because that's part of the HTTP specs.
Also, make sure that the account you specify in the HTTP auth has sufficient credentials to read WMI data. I use the administrator account for testing. There are some docs around that tell you how to open up the WMI security and the COM protocol (both need to be opened), but that's way outside this posting.
"wbemcli ec" will give you a list of all classes in a specific branch of the namespace. For example, to list all of the classes in the /root/cimv2 part of the namespace, use the following:
Code: Select all
$ wbemcli -nl ec 'http://username:password@fully.qualified.domain.name:5988/root/cimv2'
Better pipe that to a file or something, cause it's usually a lot of data. Microsoft also has a WMI Browser tool in their
WMI Admin Tools kit (requires IE) that is pretty handy for this stuff but not much easier to use.
Once you know a class, you can query for it directly with the "gc" option. Using wbemcli to query for information about the Win32_PerfFormattedData class itself would be:
Code: Select all
$ wbemcli -nl gc 'http://username:password@fully.qualified.domain.name:5988/root/cimv2:Win32_PerfFormattedData'
That will return basic information about the class proper (not information about any instances of the class though--we'll get to that in a moment).
Due to the way that this stuff is architected, the perfmon namespace is organized as peers, not hierarchical. So if you wanted to query for (say) PerfDisk/LogicalDisk performance counters you would basically need to query for the Win32_PerfFormattedData_PerfDisk_LogicalDisk class.
Using wbemcli, this would be:
Code: Select all
$ wbemcli -nl gc 'http://username:password@fully.qualified.domain.name:5988/root/cimv2:Win32_PerfFormattedData_PerfDisk_LogicalDisk'
That would return a list of all the properties (attributes, fields, whatever) associated with the class:
Code: Select all
-AvgDiskBytesPerRead
-AvgDiskBytesPerTransfer
-AvgDiskBytesPerWrite
-AvgDiskQueueLength
-AvgDiskReadQueueLength
-AvgDisksecPerRead
[...]
From there you can do the stuff you really want. You can enumerate the instances of the class with "wbemcli ei":
Code: Select all
$ wbemcli -nl ei 'http://username:password@fully.qualified.domain.name:5988/root/cimv2:Win32_PerfFormattedData_PerfDisk_LogicalDisk'
_LogicalDisk.Name="C:"
-FreeMegabytes=181257
-PercentFreeSpace=59
-PercentIdleTime=100
[...]
You can query for a specific class by name, using "wbemcli gc" and then specifying the property/value pair:
Code: Select all
$ wbemcli -nl gi 'http://username:password@fully.qualified.domain.name:5988/root/cimv2:Win32_PerfFormattedData_PerfDisk_LogicalDisk.Name="_Total"'
_LogicalDisk.Name="_Total"
-AvgDiskBytesPerRead=0
-AvgDiskBytesPerTransfer=0
-AvgDiskBytesPerWrite=0
-AvgDiskQueueLength=0
-AvgDiskReadQueueLength=0
-AvgDisksecPerRead=0
[...]
Note that using a property value of "C:" would be illegal HTTP syntax so the ":" would have to be hex-escaped for the command line (eg, Name="C%3A").
You can also use the "gp" query to ask for a specific property value associated with a specific instance. For example, asking for the Free Megabytes would be:
Code: Select all
$ wbemcli -nl gp 'http://username:password@fully.qualified.domain.name:5988/root/cimv2:Win32_PerfFormattedData_PerfDisk_LogicalDisk.Name="_Total" FreeMegabytes'
181257
where "181257" is the value of the FreeMegabytes property associated with the "_Total" instance.
Note that the above does not seem to work with "C%3A" and I'm not sure why not. Trying to specify "C:" causes errors with the HTTP transport part, but "C%3A" doesn't get mapped to WMI correctly it seems. Probably a bug in the WMI Mapper's HTTP listener, dunno. The source is up to v2.52 or something and the HP kit is still at v2.1 or whatever, but I don't know of any other precompiled binaries out there.
I have similar problems with some other classes. Like, asking wbemcli to enumerate all the instances of the /root/cimv2:LogicalDisk class will return a list of all the drives, with naming properties of ".DeviceID" but I can't seem to query for a specific instance by specifying the DeviceID. This is probably be a variation on the .Name="C%A" problem above, dunno.
Another problem -- and who knows where it is cause there's so many components here -- is that non-instanced classes cannot seem to be queried by name. For example, you can pull in memory peformance counters if you enumerate the class (there's only one instance), but you cannot seem to query the single instance by name="@" or the hex escape equivalent. You can just use the enumerate instance (ei) and achieve the same results, so this isn't a big deal really.
One cool thing about the WMI Mapper tool is that it's a WBEM-to-WMI proxy, and once the data is converted to WMI you can query any running host on the WMI side of the network. To do this, put the target NetBIOS name before the /root/ part of the path. For example:
Code: Select all
$ wbemcli -nl gc 'http://username:password@fully.qualified.domain.name:5988/OTHERHOST/root/cimv2:Win32_PerfFormattedData'
and that will cause the WBEM-HTTP query to be converted to WMI-COM and directed to OTHERHOST for processing. As long as your credentials are good you'll be able to query the other target.
One other thing to note, the above trick does not work with the "local" machine that is acting as the gateway. It can only be queried through the /root/ branch directly, not by system name. I don't know if that's part of the WMI spec, part of the WMI Mapper, or what.
This can be accounted for in scripts by looking to see if the WBEM target host (as specified in the URL) is the same as the query host, and simply omitting the latter from the URL.
For an example of how I'm looking to use this, see
this post, which shows a query for Everest sensor readings (although don't rely on that--I'm hoping they will move the sensors to performance monitor tree, and create sensor-specific classes).
Enjoy