[HOWTO] Fetching WMI data from Linux

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

djs
Posts: 2
Joined: Fri Mar 09, 2007 1:54 pm

How to find latest version of HP WMI Mapper

Post by djs »

To download the latest version of the HP WMI Mapper tool, use the link to the revision history document for the download.:

http://h18023.www1.hp.com/support/files ... /8220.html

/djs
djs
Posts: 2
Joined: Fri Mar 09, 2007 1:54 pm

single instance problem (SOLUTION)

Post by djs »

ehall says above that you can't get the single instance, but 'You can just use the enumerate instance (ei) and achieve the same results, so this isn't a big deal really.'

See his post above where he talks about how you can't specify C:, etc., and look at the example that uses the 'ei' parameter to wbemcli command. You could use a little scripting wizardry to parse out the single instance info from the output of the 'ei' command (that returns the info for all the drives in this particular case).

/djs/
ostiguy
Posts: 2
Joined: Fri Mar 16, 2007 2:34 pm

Post by ostiguy »

Does anyone have a working script/config they can show me?

I can make things work from the command line, but when I enter that string as a data input method, it throws an error. I have written a shell script, and I get the same. Basically, I am really good at generating "output: U"s, and RRDs with NaN values.

03/16/2007 03:30:04 PM - CMDPHP: Poller[0] Host[2] CMD: cdrivefree.sh, output: U


My shell script is my working wbemcli invocation into a | tr -d '\n' because I thought the newline character was part of the problem, but probably is not.
Livio Zanol
Posts: 37
Joined: Thu Feb 23, 2006 5:59 pm

problems

Post by Livio Zanol »

I have yet some doubts.

Where can I read about how to get the information on where to find the information that I want?
When must I use the ei,gc,gp,ri and ai functions?

I'm getting some serious problems on this...
Exmple: (Following ehall example):

After some search I've find the Exchange class, so I've made a little search, and used the gc (get class) function on this class:

Code: Select all

./wbemcli -nl gc 'http://DOMINIO\user:pass@maquina.f.q.d.n:5988/EXCHANGE/root/MicrosoftExchangeV2:Exchange_MessageTrackingEntry'
And I've got some results:

Code: Select all

-AttemptedPartnerServer
-Caption
-ClientIP
-ClientName
-Cost
(...)
Ok! But if i try to enumerate the instances (ei function or even ein) I've got error:

Code: Select all

./wbemcli -nl ei 'http://DOMINIO\user:pass@maquina.f.q.d.n:5988/EXCHANGE/root/MicrosoftExchangeV2:Exchange_MessageTrackingEntry'

*
* ./wbemcli: Cim: (1) CIM_ERR_FAILED: A general error occurred that is not covered by a more specific error code: "[getInstanceEnum] general"
*
So I've tried all other functions and after see that the objects is PROPERTY type, I've also used the "gp" function withou success..

Code: Select all

<PROPERTY NAME="AttemptedPartnerServer"  TYPE="string">
</PROPERTY>
Where can I find information about how to make the WMI search sentences?
ostiguy
Posts: 2
Joined: Fri Mar 16, 2007 2:34 pm

Post by ostiguy »

Playing with scriptomatic , the exchange tracking log WMI stuff can spew damn near infinite amounts of information - it may spew back the entire contacts of all tracking logs. What are you trying to achieve with that object?



I am still getting nowhere with my problem - all U all the time
Livio Zanol
Posts: 37
Joined: Thu Feb 23, 2006 5:59 pm

The Message Tracking Class was just an example...

Post by Livio Zanol »

The Message Tracking Class was just an example...

I want to know how to construct my query.

I've tried to use what ehall wrotes, but I was not sucessfull. When must I use the functions? (ei, gp, ai, ri, gc, ec, etc...)

Where can I find more information about the queries structure and the WMI classes?
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

This is really just a windows question but I am trying to create a user with only read information for WMI but I get denied to LogonUser unless the user is an Administrator despite having the permissions set under the WMI tree.

Any help on this one?
juvann
Posts: 20
Joined: Mon Dec 18, 2006 4:04 am

Post by juvann »

llow wrote:This is really just a windows question but I am trying to create a user with only read information for WMI but I get denied to LogonUser unless the user is an Administrator despite having the permissions set under the WMI tree.

Any help on this one?
Sorry for the delay, I hope you have already resolved the problem.
I have a domain and all servers are joined to the domain I have created a user cacti group of Domain Users and for each server to monitor I have insert the user cacti in the local groups:
Distributed COM Users
Performance Log Users

In WMI Control - Security for the tree ROOT/CIMV2 the cacti user has the follow privileges:
- Execute Method
- Logon Accout
- Remote Enable

I hope is usefull.
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

Thanks but unfortunately I'm running Windows 2000 Server mostly. I'm not too worried about security because I have bigger problems if my monitoring servers get compromised.

I am, however, having a problem with cimv2:Win32_Service. Some services on some machines (seems random) show as State="Unknown" when they are running and I have not been able to figure it out. Any ideas?
cuph62
Posts: 2
Joined: Fri Feb 29, 2008 7:24 am

wbemcli

Post by cuph62 »

Hey,

I am trying to use wmi_mapper as wmi_proxy together with wbemcli.

However requesting info form a qualified hostname or ip-address does not work :

eg :

::
/usr/bin/wbemcli -nl ei http://uid:pwd@hostname:5988/host.domai ... PerfFormat

and also the usage of an ipaddress

/usr/bin/wbemcli -nl ei http://uid:pwd@hostname:5988/10.16.8.21 ... PerfFormat\
===

Both give me as result :

*
* /usr/bin/wbemcli: Http Exception: HTTP response code said error
*

Using a unqualified hostname works, but unfortunately this limits my requests severely..

I have tried to encode the dotted notations, but without sucess,
All tips appreciated
caprihan
Posts: 1
Joined: Tue May 20, 2008 4:54 am

Need help creating a process remotely

Post by caprihan »

Hi All,
Am a newbie to WMI Mapper...Have installed OpenPegasus on a Linux Box and am trying to create a notepad.exe process on my Windows XP based Laptop using the WMIMapper....Am getting CIM_ERR_FAILED exception when I try to invokeMethod by calling the Create method on the Win32_Process class on my Laptop.

Can anyone help out here? I have disabled HTTPS and am using HTTP. Can access restrictions be the problem?

Cheers,
Gaurav
nick.calvert
Posts: 2
Joined: Thu Jun 19, 2008 7:12 am

Post by nick.calvert »

Hi guys,

I am trying to write a script to execute some very basic WMI methods from a linux machine. I have the mapper working fine and if I do:
wbemcli gc –nl 'http://administrator:password@domain:59 ... entService'
I get a list of all the properties of that class – brilliant.

-Caption
-CreationClassName
-Description
-ElementName
-EnabledDefault
-EnabledState
-HealthState
-InstallDate
-Name
-OperationalStatus
-OtherEnabledState
-PrimaryOwnerContact
-PrimaryOwnerName
-RequestedState
-Started
-StartMode
-Status
-StatusDescriptions
-SystemCreationClassName
-SystemName
-TimeOfLastStateChange

Now I know there is a method called DefineVirtualSystem and if I get the wmi object under ruby and call the method with no parameters as “definevirtualsystem()” it creates a blank VM under HYPER-V.

If I do the following with wbemcli
wbemcli cm 'http://administrator:password!@domain:5 ... entService DefineVirtualSystem.()'

I get the following error message: wbemcli: Parse Exception: Invalid name-value pair
http://msdn.microsoft.com/en-us/library ... S.85).aspx this is the Technet page detailing the properties of that method, the important thing is I don’t want to pass any… How do I correct my syntax?

Cheers chaps!
felimwhiteley
Posts: 26
Joined: Mon Dec 10, 2007 10:14 am

Post by felimwhiteley »

There's also a wmiclient available which is in Ubuntu/Debian. I've got a post about this if anyone finds it useful.

http://felimwhiteley.wordpress.com/2008 ... rom-linux/
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

I found it useful and have done some things with it. I think this is certainly the cleanest way to manage Windows machines from Linux and I know my Windows admins were not too keen about installing 3rd party tools like nsclient.

If you are running a recent Debian or Ubuntu, you just run:

Code: Select all

sudo aptitude install wmi-client
As lot of my clients run RedHat servers and as this is not in the RedHat network or any of the Centos repositories, I had to compiled it. Straight forward if you have a machine setup for development.

If you want to use my binary which was compiled on Centos 5, you can find it attached in a zip file.

If you want to compile it yourself, you can find the source on a debian mirror, for example: http://debian.cs.binghamton.edu/debian/ ... rig.tar.gz

Compile is using autotools, untar the source

Code: Select all

cd Samba/source
./autogen.sh
./configure
make proto bin/wmic
If all goes well you will have a compiled wmic.
Attachments
wmic.zip
Centos 5 compile of wmi_0.1.13
(2.1 MiB) Downloaded 4233 times
User avatar
anx
Posts: 21
Joined: Sat Apr 28, 2007 1:47 am
Location: Melbourne, Australia
Contact:

Post by anx »

I've posted a template using wmic here:

http://forums.cacti.net/viewtopic.php?p=143047
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests