Monitor Windows via WMI from Cacti on Linux
Moderators: Developers, Moderators
Monitor Service using WMI
Hi
I'm moved a littel step forward,
attached you can find data&graph template to monitor service (running/stopped).
using this query:
select * from Win32_PerfRawData
I can get "State" but it's a string and I don't know how to convert it in a number so that Cacti can create graph
So I've used ProcessId to graph the process id of a service. if it's 0 it means that it's stopped.
Not really elegant but it could works, even if some windows process are using all the same processid (svchost.exe)
Claymen do you have a better solution?!?
Thank you
L.
I'm moved a littel step forward,
attached you can find data&graph template to monitor service (running/stopped).
using this query:
select * from Win32_PerfRawData
I can get "State" but it's a string and I don't know how to convert it in a number so that Cacti can create graph
So I've used ProcessId to graph the process id of a service. if it's 0 it means that it's stopped.
Not really elegant but it could works, even if some windows process are using all the same processid (svchost.exe)
Claymen do you have a better solution?!?
Thank you
L.
- Attachments
-
- services.zip
- (4.21 KiB) Downloaded 388 times
There are two options I can think of.
1. Modify wmi.php to have a special case for Win32_Service and parse the Running etc into 0,1,2,3.
2. Use sed or maybe awk to do the replacement of Running into 0 or 1 by adding it into your data input method.
I'd lean towards option 2 as you keep the wmi.php as generic as possible and the modification to use sed to process the result can be done within Cacti.
1. Modify wmi.php to have a special case for Win32_Service and parse the Running etc into 0,1,2,3.
2. Use sed or maybe awk to do the replacement of Running into 0 or 1 by adding it into your data input method.
I'd lean towards option 2 as you keep the wmi.php as generic as possible and the modification to use sed to process the result can be done within Cacti.
Monitor Service State
Claymen
I'v finished my template,, as suggested I've added a sed to sobtutute "running" with 1 and Stopped with 0
So now the graph is monitoring the effective service state.
Thak's for your help.
Last question.
I'd like to have the service name somewhere on the graph.
Do you know how to add it to the title without manually write it every time? (something like |host description| )
I've already tried to add the "name" datasource and add it as GPRINT item into graph template.
unfortunally cacti doesn't seems to recognize the string and it expect a number so I've alwasy the value 0 instead of service "Name"
take a look to the attachment
L.
I'v finished my template,, as suggested I've added a sed to sobtutute "running" with 1 and Stopped with 0
So now the graph is monitoring the effective service state.
Thak's for your help.
Last question.
I'd like to have the service name somewhere on the graph.
Do you know how to add it to the title without manually write it every time? (something like |host description| )
I've already tried to add the "name" datasource and add it as GPRINT item into graph template.
unfortunally cacti doesn't seems to recognize the string and it expect a number so I've alwasy the value 0 instead of service "Name"
take a look to the attachment
L.
- Attachments
-
- services-state.zip
- (4.15 KiB) Downloaded 306 times
From what I understand the only way to do what you are asking is to write a data query which becomes a little more complex. I've looked into it but then there is already work in the form of the WMI plugin but I've somewhat avoided using plugins due to the fact the architecture itself is not included in the main tree. E.g. I have to merge it in every time a vendor supplied package updates cacti.
Hi there,
Im using CENTOS 5, running Cacti Version 0.8.7e and install the CactiWMI-0.0.6-RC1. Import all templates ok, installed wmic also. I can run any commands i find on this thread with wmic directly and get results OK but when using any in Cacti it fails with:
Can someone help? It seems to me that some of the functions like Win32_ComputerSystem arent reconize or something?
Im using CENTOS 5, running Cacti Version 0.8.7e and install the CactiWMI-0.0.6-RC1. Import all templates ok, installed wmic also. I can run any commands i find on this thread with wmic directly and get results OK but when using any in Cacti it fails with:
When running a test command directly in bash i get this:CMDPHP: Poller[0] Host[6] DS[149] WARNING: Result from CMD not valid. Partial Result: U
Code: Select all
[root@localhost ~]# /usr/bin/php -q /var/www/cacti/scripts/wmi.php -h '<my_host>' -u '/etc/cacti/cactiwmi.pw' -w 'Win32_ComputerSystem' -n '' -k '' -v '' -c 'PercentProcessorTime'
NTSTATUS: NT code 0xc0041017 - NT code 0xc0041017
Return code non-zero, debug mode enabled!
/usr/bin/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //<my_host> "SELECT PercentProcessorTime FROM Win32_ComputerSystem"
Exec Status: 1
PHP Notice: Undefined offset: 1 in /var/www/cacti/scripts/wmi.php on line 120
¬¬ZeRoY¬¬
It looks like it wasn't able to run the WMI query.
What happens when you run the wmic command itself?
What happens when you run the wmic command itself?
Code: Select all
/usr/bin/wmic --namespace='root\CIMV2' --authentication-file=/etc/cacti/cactiwmi.pw //<my_host> "SELECT PercentProcessorTime FROM Win32_ComputerSystem"
Who is online
Users browsing this forum: No registered users and 4 guests