Monitor Windows via WMI from Cacti on Linux

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

Moderators: Developers, Moderators

Post Reply
chet
Posts: 41
Joined: Mon Feb 09, 2009 12:49 pm

Post by chet »

When I run the following

/

Code: Select all

usr/bin/php -q /var/www/html/scripts/wmi.php 192.168.3.2 cacti Win32_PerfFormattedData_PerfOS_Processor PercentProcessorTime 
I get the following returned

Could not open input file: /var/www/html/scripts/wmi.php

What do I need to do to correct this, both the wmi.php and wmi-logins.php are in my scripts dir

4 -rw-r--r-- 1 root root 1154 2009-03-05 19:02 wmi-logins.php
4 -rw-r--r-- 1 root root 4027 2009-03-05 18:38 wmi.php

Thanks

Martyn
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Re: Graph Templates

Post by claymen »

argon0 wrote:Don't know if I'm just missing this or whether you just CANNOT do this, except via Graph Templates...

Would like to be able to change the Exchange Active Connections graph to name the databases, instead of having it just say Database1, Database2.... on the graph....

And is there an easy way to copy several lines of a graph then edit them, rather then adding each line one at a time (I remember something - a bit of a hack I did - from ages ago where you could add 3 or 4 lines at once...)
Create the graph from the template, then swap that graph's template to none. Then you can edit the names.

I have got more up to date templates for exchange in SVN. This is what I currently use for our exchange databases below.
Attachments
new.exchange.png
new.exchange.png (73.33 KiB) Viewed 7193 times
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

chet wrote:When I run the following

/

Code: Select all

usr/bin/php -q /var/www/html/scripts/wmi.php 192.168.3.2 cacti Win32_PerfFormattedData_PerfOS_Processor PercentProcessorTime 
I get the following returned

Could not open input file: /var/www/html/scripts/wmi.php

What do I need to do to correct this, both the wmi.php and wmi-logins.php are in my scripts dir

4 -rw-r--r-- 1 root root 1154 2009-03-05 19:02 wmi-logins.php
4 -rw-r--r-- 1 root root 4027 2009-03-05 18:38 wmi.php

Thanks

Martyn
Can you open /var/www/html/scripts/wmi.php manually from bash? Also make sure your path to php is correct, mine is /usr/bin/php but on other linux distro's it may be in a different location. Please check that also.
chet
Posts: 41
Joined: Mon Feb 09, 2009 12:49 pm

Post by chet »

Hi claymen, as a total windows user I'm just getting to grips with all these distro's and I'm hoping you will stick with me on this one.

Your question to me was:
Can you open /var/www/html/scripts/wmi.php manually from bash
I'm not sure as yet because I would not know how to execute this, but with your help I will make sure I can, what do I need to do to run this command?

I have checked the location of php and I believe that it is in my /usr/bin/ I'm running Ubuntu here if that helps at all.

Thanks for you reply and looking forward to your help

Chet
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Log into the server, on the command prompt you get (which in most cases is bash and will be the default on Ubuntu) see if you can actually read the file.

So try this

Code: Select all

cat /var/www/html/scripts/wmi.php
Do you get any data back? If no then you have either a permission problem (not likely based on the permissions you pasted where everyone has read access) or the path is wrong..

Second, make sure you can execute php

Code: Select all

/usr/bin/php -v
That if the php executable is there return the version of php, if it doesnt then thats the problem your path to php is wrong. Running the following may be able to locate it for you.

Code: Select all

whereis php
Where exactly did you get the error message about opening the input file from?
chet
Posts: 41
Joined: Mon Feb 09, 2009 12:49 pm

Post by chet »

Thanks for you time again, I have moved on a stage now as I had a typo in my command, too many hours steering at the screen.

I now get from:
usr/bin/php -q /var/www/cacti/scripts/wmi.php 192.168.3.2 cacti Win32_PerfFormattedData_PerfOS_Processor PercentProcessorTime
NTSTATUS: NT_STATUS_NET_WRITE_FAULT - NT_STATUS_NET_WRITE_FAULT

This is from my wmi-logins.php

$logins['cacti'] = array('TINTERNET/wmi','wmi');

The box I'm trying to connect to is a XP box with SP3, I have edited the WMI security and added the user there and also in COM security.

My XP box has a user "wmi" with the password of "wmi" set-up as administrator for testing purposes, and the workgroup its sit in is TINTERNET.

Can you see a reason why I can not connect at all, there are no firewalls in the way at all.

Thanks

Martyn
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

Try without the workgroup, just use 'wmi' as the username and 'wmi' as the password in that case.
chet
Posts: 41
Joined: Mon Feb 09, 2009 12:49 pm

Post by chet »

Still the same mate, sorry

Code: Select all

wmic -U wmi%wmi //192.168.3.2 "select * from Win32_ComputerSystem"
ERROR: dcom_create_object.
ERROR: Login to remote object.
NTSTATUS: NT_STATUS_NET_WRITE_FAULT - NT_STATUS_NET_WRITE_FAULT

Cheers
User avatar
claymen
Cacti User
Posts: 259
Joined: Mon Aug 18, 2008 4:30 am
Location: Australia
Contact:

Post by claymen »

That looks like permissions, I get the same error when I use an incorrect login.
chet
Posts: 41
Joined: Mon Feb 09, 2009 12:49 pm

Post by chet »

I have the correct logon details and yes you are correct, if I try and connect from anoter machine using the windows management instrumentation, I get access denied, it works if I try local.

What else can I check to get this working

Cheers

Martyn
chet
Posts: 41
Joined: Mon Feb 09, 2009 12:49 pm

Post by chet »

OK its now sorted, I will post how I did it later.

Cheers

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

Post by argon0 »

Suspect user was not member of Performance Log Users group?

Anyway.

Claymen - I think there is an error in the SQL Templates, the data input methods WMI - SQL... Point to

Code: Select all

/usr/bin/php -q <path_cacti>/wmi.php <host> <credential> <class> <columns> <filter> <filterval>
But the wmi.php file is at

Code: Select all

<path_cafcti>/script/wmi.php
I've editted the input methods manually - just thought I'd note this here for anybody else who wasn't getting the SQL graphs working...

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 »

Which version were the templates from?

I checked 0.0.5 and the latest SVN and they appear ok.
argon0
Cacti User
Posts: 460
Joined: Fri Mar 12, 2004 1:22 pm

Post by argon0 »

SQL Server 2005...

Tried the SQL templates, with no joy, but noticed that the data query is doing this:

Code: Select all

 /usr/bin/php -q /var/www/html/scripts/wmi.php x.x.x.x  cacti Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager Buffercachehitratio,Buffercachehitratio_Base
Which isn't working.

Had a look at the Win32_PerfRawData classes on my SQL2005 server using wbemtest, and found that the Win32_PerfRawData_MSSQLSERVER_SQLServer class does not exist, instead it looks like it has been replaced with the class Win32_PerfRawData_MSSQLLIVE2005_MSSQLLIVE2005

Thus I have created a new Data Query/Template for 2005 servers, which I shall attach later, once I test it on other SQl2005 servers!!
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:SQL Server 2005...

Tried the SQL templates, with no joy, but noticed that the data query is doing this:

Code: Select all

 /usr/bin/php -q /var/www/html/scripts/wmi.php x.x.x.x  cacti Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager Buffercachehitratio,Buffercachehitratio_Base
Which isn't working.

Had a look at the Win32_PerfRawData classes on my SQL2005 server using wbemtest, and found that the Win32_PerfRawData_MSSQLSERVER_SQLServer class does not exist, instead it looks like it has been replaced with the class Win32_PerfRawData_MSSQLLIVE2005_MSSQLLIVE2005

Thus I have created a new Data Query/Template for 2005 servers, which I shall attach later, once I test it on other SQl2005 servers!!
That is correct. It also changes when you have multiple named instances. Theres not really a way around it other than making your data source WMI class field adjustable. That way by default it'll be for the standard install and then you can change it if need be.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest