Monitor Windows via WMI from Cacti on Linux

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Note to self: Don't implement these sorts of changes just before you go home...

Anyway - implemented all, getting Nans, ran from the command line as cacti user get the following:

./wmi.php -h 10.0.254.9 -u /etc/cacti/cactiwmi.pw -w Win32_ComputerS ystem -c PrimaryOwnerName,NumberOfProcessors


Return code non-zero, debug mode enabled!



/var/www/html/plugins/wmi/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //10.0.254.9 "SELECT PrimaryOwnerName,NumberOfProcessors FROM Win32_ComputerSystem"
Exec Status: 1

PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 3 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 3 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 4 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 4 in /var/www/html/scripts/wmi.php on line 130
[--debug-stderr] [-s0:________[-l
--configfile CONFIGFILE] [--option=name=value]0:--log-basename_LOGFILEBASE]_[--leak-report]_[--leak- report-full]
[--debug-stderr] [-s1:________[-R
--configfile CONFIGFILE] [--option=name=value]1:--name-resolve_NAME-RESOLVE-ORDER]
[--debug-stderr] [-s2:________[-O
--configfile CONFIGFILE] [--option=name=value]2:--socket-options_SOCKETOPTIONS]_[-n
2:--netbiosname_NETBIOSNAME]
[--debug-stderr] [-s3:________[-W
--configfile CONFIGFILE] [--option=name=value]3:--workgroup_WORKGROUP]_[--realm=REALM]_[-i
3:--scope_SCOPE]
[--debug-stderr] [-s4:________[-m
--configfile CONFIGFILE] [--option=name=value]4:--maxprotocol_MAXPROTOCOL]_[-U
4:--user_[DOMAIN\]USERNAME[%PASSWORD]]
[--debug-stderr] [-s5:________[-N
--configfile CONFIGFILE] [--option=name=value]5:--no-pass]_[--password=STRING]_[-A
5:--authentication-file_FILE]
[--debug-stderr] [-s6:________[-S
--configfile CONFIGFILE] [--option=name=value]6:--signing_on
6:off
6:required]_[-P
6:--machine-pass]
[--debug-stderr] [-s7:________[--simple-bind-dn=STRING]_[-k
--configfile CONFIGFILE] [--option=name=value]7:--kerberos_STRING]
[--debug-stderr] [-s8:________[--use-security-mechanisms=STRING]_[-V
--configfile CONFIGFILE] [--option=name=value]8:--version]
[--debug-stderr] [-s9:________//host_query
[--debug-stderr] [-s10:
[--debug-stderr] [-s11:Example_wmic_-U_[domain/]adminuser%password_//host_"select_*_from_Win
Any ideas?

Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

argon0 wrote:Claymen, just wondering if you are planning on upgrading to .8.7d in the near future?

If not, is there any particular reason (beyond the CDEFs) that you are not?

Argon0
We have quite a few hosts in cacti and upgrading has the potential to nuke lots of their gaphs from the CDEF changes. We also had heaps of issues upgrading from 0.8.7->0.8.7b (although the improvements were worth it).

Eventually we will but for the moment it's not a priority. I'll be setting 0.8.7d up at home as there are a few things I want to test :)
argon0 wrote:Note to self: Don't implement these sorts of changes just before you go home...

Anyway - implemented all, getting Nans, ran from the command line as cacti user get the following:

./wmi.php -h 10.0.254.9 -u /etc/cacti/cactiwmi.pw -w Win32_ComputerS ystem -c PrimaryOwnerName,NumberOfProcessors


Return code non-zero, debug mode enabled!



/var/www/html/plugins/wmi/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //10.0.254.9 "SELECT PrimaryOwnerName,NumberOfProcessors FROM Win32_ComputerSystem"
Exec Status: 1

PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 2 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 3 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 3 in /var/www/html/scripts/wmi.php on line 130
PHP Notice: Undefined offset: 4 in /var/www/html/scripts/wmi.php on line 130

Notice: Undefined offset: 4 in /var/www/html/scripts/wmi.php on line 130
[--debug-stderr] [-s0:________[-l
--configfile CONFIGFILE] [--option=name=value]0:--log-basename_LOGFILEBASE]_[--leak-report]_[--leak- report-full]
[--debug-stderr] [-s1:________[-R
--configfile CONFIGFILE] [--option=name=value]1:--name-resolve_NAME-RESOLVE-ORDER]
[--debug-stderr] [-s2:________[-O
--configfile CONFIGFILE] [--option=name=value]2:--socket-options_SOCKETOPTIONS]_[-n
2:--netbiosname_NETBIOSNAME]
[--debug-stderr] [-s3:________[-W
--configfile CONFIGFILE] [--option=name=value]3:--workgroup_WORKGROUP]_[--realm=REALM]_[-i
3:--scope_SCOPE]
[--debug-stderr] [-s4:________[-m
--configfile CONFIGFILE] [--option=name=value]4:--maxprotocol_MAXPROTOCOL]_[-U
4:--user_[DOMAIN\]USERNAME[%PASSWORD]]
[--debug-stderr] [-s5:________[-N
--configfile CONFIGFILE] [--option=name=value]5:--no-pass]_[--password=STRING]_[-A
5:--authentication-file_FILE]
[--debug-stderr] [-s6:________[-S
--configfile CONFIGFILE] [--option=name=value]6:--signing_on
6:off
6:required]_[-P
6:--machine-pass]
[--debug-stderr] [-s7:________[--simple-bind-dn=STRING]_[-k
--configfile CONFIGFILE] [--option=name=value]7:--kerberos_STRING]
[--debug-stderr] [-s8:________[--use-security-mechanisms=STRING]_[-V
--configfile CONFIGFILE] [--option=name=value]8:--version]
[--debug-stderr] [-s9:________//host_query
[--debug-stderr] [-s10:
[--debug-stderr] [-s11:Example_wmic_-U_[domain/]adminuser%password_//host_"select_*_from_Win
Any ideas?

Argon0
That error would make me think that wmic has crashed out entirely. Can you run the following manually?

Code: Select all

/var/www/html/plugins/wmi/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //10.0.254.9 "SELECT PrimaryOwnerName,NumberOfProcessors FROM Win32_ComputerSystem" 
Cause from the looks of that wmic itself returned the error code.
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

I did compile the binaries but they require some shared libraries.

If someone can point out a simple way to compile in said libraries I will do so but hopefully these at least partially help!

wmic-bin-1.2.2
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

I get :

[--debug-stderr] [-s|--configfile CONFIGFILE] [--option=name=value]
[-l|--log-basename LOGFILEBASE] [--leak-report] [--leak-report-full]
[-R|--name-resolve NAME-RESOLVE-ORDER]
[-O|--socket-options SOCKETOPTIONS] [-n|--netbiosname NETBIOSNAME]
[-W|--workgroup WORKGROUP] [--realm=REALM] [-i|--scope SCOPE]
[-m|--maxprotocol MAXPROTOCOL] [-U|--user [DOMAIN\]USERNAME[%PASSWORD]]
[-N|--no-pass] [--password=STRING] [-A|--authentication-file FILE]
[-S|--signing on|off|required] [-P|--machine-pass]
[--simple-bind-dn=STRING] [-k|--kerberos STRING]
[--use-security-mechanisms=STRING] [-V|--version]
//host query

I think it might be the username/password thing - its not expecting the authentication path...



Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
greg4tw
Posts: 10
Joined: Thu Mar 19, 2009 4:35 am
Location: Germany

Post by greg4tw »

The new wmic Binary doesnt run :(
After Updating to lignutls.so.26, I get errors with other shared libraries:
libtasn1.so.3

Under which Linux you are developing?
Which pakets must be installed?
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Nope - its the --namespace option....

O'm running Cigamit's version of the wmi executable, so that could be it. Will download the one you just posted and try that instead.
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Claymen,

What do we do with the wmic32 and/or wmic64? Do we just rename, based on the version of OS we are running?

Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Yes you would rename wmic32/64 to wmic based on whether your running 32bit or 64bit. Personally I run 64bit at home and work.

It's built under debian sid. I did some digging around to try and build it statically but couldn't quite get it to work right. If anyone has any pointers to do this that'd be excellent.

And yer the new templates require the updated wmic version which supports namespaces.
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

<erm> OK... Well I've built the libraries it relies on (in my case libgnutls.so.28) in /usr/local/lib, but it still tells me that it can't find them, despite adding the location to the path... Where are your shared libraries located?

OR, where can I find the wmi-client to build myself?

Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Yer, so you have...

Finally got it compiled, now to see if it actually works!!1

[EDIT:] Now I get, exactly as I did when using your compiled version:

bin/wmic: error while loading shared libraries: libgnutls.so.26: cannot open shared object file: No such file or directory

<groan>
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

Fina Flipping Ly...

Did it, got the libgnutls.so.26 installed and got Centos to know where it is (didn't realise that after adding it the path to a file in /etc/ld.so.conf.d (a directory) I had to run ldconfig from /sbin...

Which would probably have saved me from building wmic from scratch...


Yup, a quick check later, and it was enough....

OK what I did -> comes mainly from here: http://www.smartvox.co.uk/serfaq_instal ... proxy2.htm

But not all...

1st Installed gcc and gcc-c++ using Yum

Got all additional files from here: ftp://ftp.franken.de/pub/crypt/mirror/f ... rg/gcrypt/

Or rather its its sub-directories.

Because my version of Centos can't (for some reason) cope with zip or bzip files I had to uncompress and recompress on my Windows PC into Tar format for some files


IIRC I had to install Libgpg-error first from ftp://ftp.franken.de/pub/crypt/mirror/f ... bgpg-error

Once I had uploaded and uncompressed the file (using the tar -xvf command), switched to its directory from the command prompt, and I did
./configure --libdir=/usr/local/lib
make
make install

(any dependencies which raised their head here, I got around using Yum install - but, again IIRC I don't think anything did).


Then installed libgcrypt from the instructions on the link (but the latest version). To /usr/local/lib not lib64 in my case - but doubt it would have made much difference.

Then installed gnutls NOT libgnutls - as I couldn't actually find this separately.

Just replace libgnutls with gnutls in the smartvox insgtructions. Although I didn't bother with the --with-included-libtasn1 switch...


Then, at a guess, I could have moved the libgnutls.so.26* files to a central directory maybe usr/lib which was already in my path (in fact, just done this and tested - yup that works...)....

And Viola - wmic suddenly starts working!!
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

OH, one more thing... I did have to rebuild the Wmic, as I also got anothererror after doing all that:

Code: Select all

/usr/local/bin/wmic: /usr/lib/libpopt.so.0: no version information available (required by /usr/local/bin/wmic)
/usr/local/bin/wmic: /lib/libpam.so.0: no version information available (required by /usr/local/bin/wmic)


Although it also returned the data - I suspect this would break Cacti... The compiled version just gave

Code: Select all

CLASS: Win32_ComputerSystem
Name|NumberOfProcessors|PrimaryOwnerName
B-OF-EXBEV-0128|4|IT

Compiling WMIC is quite easy, as long as you follow the instructions in the README.

Argon0
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

No idea about those other wmic errors your seeing... you make compiling wmic look difficult. Although I did have issues at work on CentOS as it just seems to go out of its way to make doing things difficult. At home Debian just works and apt-get build-dep wmi-client sorts out all the dependencies ;)
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

OK...

Claymen - now I need some help!!

Got wmic working = I can run it neatly from the command line with wmi.php....

BUT, from Cacti, it doesn't want to work...

for example (from debug level Cacti logging) it is currently trying to get data from:

Code: Select all

/usr/bin/php -q /var/www/html/scripts/wmi.php -h '' -u '/etc/cacti/cactiwmi.pw' -w 'Win32_PerfFormattedData_PerfOS_Processor' -n '' -k '' -v '' -c 'PercentProcessorTime'
For Host 10.0.10.19.. I think this is breaking because Cacti isn't passing the host variable, because if I put

Code: Select all

-h '10.0.10.19' 
into the line above and run from command line it works...


Arghh...
No longer a n00by, probably, by now an 0ldby

Now Head of Technology at RSCH, back to the prickly subject of Monitorring....
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest