Monitor Windows Service stats from Linux

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

Moderators: Developers, Moderators

Post Reply
User avatar
streaker69
Cacti Pro User
Posts: 712
Joined: Mon Mar 27, 2006 10:35 am
Location: Psychic Amish Network Administrator

Post by streaker69 »

Ok, I upgraded my installation from the I version that was on the CactiEZ ISO to the J version from the distribution site. Since then, I've lost the Win Services option under devices. I've followed what I read here in the thread, about importing the XML file and making sure the other two files are in their correct locations. But I still don't have an option for Win Services under my devices. Upon looking through the database table 'graph_templates' Win Services is not list. I have the Graph Template and Data Template for it, but I cannot add it to a device.

Any idea how to get it back?
tonzy0907
Posts: 19
Joined: Wed May 30, 2007 6:16 am

one graph

Post by tonzy0907 »

is it possible to use one graph in all services i monitored?
ainesophaur
Posts: 5
Joined: Fri Aug 03, 2007 9:40 pm

Post by ainesophaur »

Hello to all :)

I'm running cactiez (cacti-h) (was running this before with no problem) and recently upgraded to j -- and now my graphs for win_Services are broken.

When I look at the graph, it's just a red x (like image missing) -- so I decided to look a little deeper and seen there was no rrd for the hostname - service.

I went as far as running chmod 777 on the rra directory.

My RRA timing is all right (according to the picture in page 4)

I'm not sure how to 'debug' this issue as I've never ran into it before, so I apologize in advance for a lack of detail.

All other graphs are fine.

I don't know why it isn't creating the rrd =\


Debug mode displays


/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-60 \
--title="RTSW DC1 - Services -" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
DEF:a="/var/www/html/rra/rtsw_dc1_service_state_41.rrd":service_state:LAST \
DEF:b="/var/www/html/rra/rtsw_dc1_service_state_41.rrd":service_state:AVERAGE \
AREA:a#EA8F00:"Service State" \
GPRINT:a:LAST:"%8.0lf\n" \
COMMENT:"(1 = Running, 0 = Stopped)"
RRDTool Says:

ERROR: opening '/var/www/html/rra/rtsw_dc1_service_state_41.rrd': No such file or directory
Attachments
dc1-services.jpg
dc1-services.jpg (6.78 KiB) Viewed 17831 times
justinchudgar
Posts: 9
Joined: Thu Oct 19, 2006 7:59 pm
Location: Weed, Siskiyou County, CA, USA
Contact:

No Services Returned...

Post by justinchudgar »

Everything seems to be working fine; but, when I do a verbose query I get:

Code: Select all

+ Running data query [20].
+ Found type = '6 '[script query].
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/win_services.xml'
+ XML file parsed ok.
+ Executing script for list of indexes '/usr/bin/php -q /usr/share/cacti/site/scripts/win_services.php 192.168.112.200 public 2 6 index'
+ Executing script query '/usr/bin/php -q /usr/share/cacti/site/scripts/win_services.php 192.168.112.200 public 2 6 query index'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/win_services.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/win_services.xml'
+ Found data query XML file at '/usr/share/cacti/site/resource/script_server/win_services.xml'
I have tried the 36/26-->35/25 fix mentioned above; but, get no data either way. I tried to see where to make the varchar(250) to text() change; but am stumped. Thanks in advance for the help.
KyRoo
Cacti User
Posts: 51
Joined: Fri Oct 19, 2007 10:19 am

Post by KyRoo »

Has anyone got this to work under 0.7.8 ?

i get this when i start this:

Code: Select all

 php -q win_services.php <ip> public 1 2 query index

Fatal error: Call to undefined function read_config_option() in /var/www/cacti/lib/snmp.php on line 233

Thx
kyRoo
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

You are going to find that a lot of your old scripts no longer work in v0.8.7, since instead of including config.php, you need to include global.php. Also, certain functions have changed and require more arguments to support SNMP v3.

Attached is a version that should work in v0.8.7.
Attachments
services.zip
Windows Services Script for Cacti v0.8.7
(4.36 KiB) Downloaded 2779 times
frdt
Posts: 13
Joined: Thu Aug 09, 2007 4:13 am

how to setup this template

Post by frdt »

hello , I new on cacti. Template is correctly imported but now where to go ?
In data query, associated graph under Data Template - Win Services , what to put in the fields name and field name ?
It's a basic question I know but .. don't understand how to configure a host to display this graph.
I have 150 devices monitored with standard plugin , for these hosts I just go to "new graph", select a host and then select the graph template in a drop down list. Here I don't have this template in the list.
can everyone help me to ..understand what to do
thanks and best regards
warnesj
Cacti User
Posts: 173
Joined: Sun May 29, 2005 7:34 pm

Post by warnesj »

Hey cigamit, thanks for the new scripts. But for whatever reason the script wasn't working for me on my Linux install. :( I had to make a couple of changes to the win_service.php file that I wanted to run by you for you're comments (just in case I did something stupid),

Here are a list of the changes I made,
  1. Original code,

    Code: Select all

    	if ((func_num_args() <= "4") && (func_num_args() >= "3")) {
    		if ($cmd == "index") {
    Changed code,

    Code: Select all

    	if ((func_num_args() <= "5") && (func_num_args() >= "3")) {
    		if ($cmd == "index") {
    For some reason when the "get" command went to check the servstate my server was passing 5 arguments (hostname, snmp connection info, snmp command, argument 1, and argument 2 - the oid of the service). With the "if" statement looking for 3 or 4 arguments my system wasn't able to actually get into the subroutine to query the service status.
  2. Original code,

    Code: Select all

    			for ($i=0; $i < sizeof($return_arr); $i++) {
    				if (substr($return_arr[$i]['oid'],0,4) == "SNMP")
    					print substr($return_arr[$i]['oid'],36) . "\n";
    				else
    					print substr($return_arr[$i]['oid'],26) . "\n";
    			}
    Changed code,

    Code: Select all

    			for ($i=0; $i < sizeof($return_arr); $i++) {
    				if (substr($return_arr[$i]['oid'],0,4) == "SNMP")
    					print substr($return_arr[$i]['oid'],35) . "\n";
    				else
    					print substr($return_arr[$i]['oid'],25) . "\n";
    			}
    The first digit of the OID's of the service index was getting trimmed off so Cacti was unable to query the service status. For example, if the service index was 19.84.83.77.32.67.108.105.101.110.116.32.65.99.99.101.112.116.111.114, the win_services.php script was querying 9.84.83.77.32.67.108.105.101.110.116.32.65.99.99.101.112.116.111.114. So what I did was decrease the character position that the substr command was starting at by 1.
  3. Original code,

    Code: Select all

    			for ($i = 0; $i < sizeof($arr_index); $i++) {
    				if (substr($arr_index[$i]['oid'],0,4) == "SNMP")
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],36);
    				else
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],26);
    			}
    Changed code,

    Code: Select all

    			for ($i = 0; $i < sizeof($arr_index); $i++) {
    				if (substr($arr_index[$i]['oid'],0,4) == "SNMP")
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],35);
    				else
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],25);
    			}
    Similarly to above, the first digit of the OID of the service index was getting trimmed, so I decreased the position where the substr command started at by 1.
Anyway with those changes this works great on my Cacti install now. :) Thanks a million for it!
frdt
Posts: 13
Joined: Thu Aug 09, 2007 4:13 am

nobody to help me to explain the usage of this script ?

Post by frdt »

I come back an dhope some explaination on how to use this script
thanks
best regards
old8xp
Posts: 5
Joined: Thu Jul 27, 2006 7:58 pm

Post by old8xp »

I use the scripts,bu it can't graph something .

turn on debug, it show this:

RRDTool Command:

/usr/local/rrdtool/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-60 \
--title="gxdcb77 - Service State - SNMP Service" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/shine/htdocs/client/cacti/rra/gxdcb77_service_state_26.rrd":service_state:LAST \
DEF:b="/shine/htdocs/client/cacti/rra/gxdcb77_service_state_26.rrd":service_state:AVERAGE \
AREA:a#EA8F00:"Service State" \
GPRINT:a:LAST:"%8.0lf\n" \
COMMENT:"(1 = Running, 0 = Stopped)"
RRDTool Says:

ERROR: the RRD does not contain an RRA matching the chosen CF

Can I solve it?


cigamit wrote:You are going to find that a lot of your old scripts no longer work in v0.8.7, since instead of including config.php, you need to include global.php. Also, certain functions have changed and require more arguments to support SNMP v3.

Attached is a version that should work in v0.8.7.
old8xp
Posts: 5
Joined: Thu Jul 27, 2006 7:58 pm

Post by old8xp »

I change the scripts like U,but it work incorret.
how Can I solve it?

error message is:
12/17/2007 06:29:22 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed!, Error:'1064', SQL:"SELECT snmp_query.id, snmp_query.name, snmp_query.xml_path FROM (snmp_query,host_snmp_query) WHERE host_snmp_query.snmp_query_id=snmp_query.id AND host_snmp_query.host_id= ORDER BY snmp_query.name"
12/17/2007 06:29:22 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed!, Error:'1064', SQL:"SELECT graph_local.graph_template_id FROM (graph_local,host_graph) WHERE graph_local.graph_template_id=host_graph.graph_template_id AND graph_local.host_id=host_graph.host_id AND graph_local.host_id= GROUP BY graph_local.graph_template_id"
12/17/2007 06:29:22 PM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed!, Error:'1064', SQL:"SELECT snmp_query.id, snmp_query.name, snmp_query.xml_path FROM (snmp_query,host_snmp_query) WHERE host_snmp_query.snmp_query_id=snmp_query.id AND host_snmp_query.host_id= ORDER BY snmp_query.name"
warnesj wrote:Hey cigamit, thanks for the new scripts. But for whatever reason the script wasn't working for me on my Linux install. :( I had to make a couple of changes to the win_service.php file that I wanted to run by you for you're comments (just in case I did something stupid),

Here are a list of the changes I made,
  1. Original code,

    Code: Select all

    	if ((func_num_args() <= "4") && (func_num_args() >= "3")) {
    		if ($cmd == "index") {
    Changed code,

    Code: Select all

    	if ((func_num_args() <= "5") && (func_num_args() >= "3")) {
    		if ($cmd == "index") {
    For some reason when the "get" command went to check the servstate my server was passing 5 arguments (hostname, snmp connection info, snmp command, argument 1, and argument 2 - the oid of the service). With the "if" statement looking for 3 or 4 arguments my system wasn't able to actually get into the subroutine to query the service status.
  2. Original code,

    Code: Select all

    			for ($i=0; $i < sizeof($return_arr); $i++) {
    				if (substr($return_arr[$i]['oid'],0,4) == "SNMP")
    					print substr($return_arr[$i]['oid'],36) . "\n";
    				else
    					print substr($return_arr[$i]['oid'],26) . "\n";
    			}
    Changed code,

    Code: Select all

    			for ($i=0; $i < sizeof($return_arr); $i++) {
    				if (substr($return_arr[$i]['oid'],0,4) == "SNMP")
    					print substr($return_arr[$i]['oid'],35) . "\n";
    				else
    					print substr($return_arr[$i]['oid'],25) . "\n";
    			}
    The first digit of the OID's of the service index was getting trimmed off so Cacti was unable to query the service status. For example, if the service index was 19.84.83.77.32.67.108.105.101.110.116.32.65.99.99.101.112.116.111.114, the win_services.php script was querying 9.84.83.77.32.67.108.105.101.110.116.32.65.99.99.101.112.116.111.114. So what I did was decrease the character position that the substr command was starting at by 1.
  3. Original code,

    Code: Select all

    			for ($i = 0; $i < sizeof($arr_index); $i++) {
    				if (substr($arr_index[$i]['oid'],0,4) == "SNMP")
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],36);
    				else
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],26);
    			}
    Changed code,

    Code: Select all

    			for ($i = 0; $i < sizeof($arr_index); $i++) {
    				if (substr($arr_index[$i]['oid'],0,4) == "SNMP")
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],35);
    				else
    					$arr_index2[$i] =  substr($arr_index[$i]['oid'],25);
    			}
    Similarly to above, the first digit of the OID of the service index was getting trimmed, so I decreased the position where the substr command started at by 1.
Anyway with those changes this works great on my Cacti install now. :) Thanks a million for it!
padawan
Posts: 25
Joined: Fri Nov 30, 2007 4:54 am

Post by padawan »

ERROR: the RRD does not contain an RRA matching the chosen CF

Can I solve it?
You have to change your graph template like this :
Item # 1 (service_state): Service State AREA AVERAGE
old8xp
Posts: 5
Joined: Thu Jul 27, 2006 7:58 pm

Post by old8xp »

padawan wrote:
ERROR: the RRD does not contain an RRA matching the chosen CF

Can I solve it?
You have to change your graph template like this :
Item # 1 (service_state): Service State AREA AVERAGE
I had changed the Service Stat as AREA , the graph is work.
but the graph is incorrect. It say which state is "nan".

when I look the cacti log, it say:
12/25/2007 08:14:01 AM - CMDPHP: Poller[0] Host[2] DS[9] WARNING: Result from SERVER not valid. Partial Result: U
which DS[9] is the state which I want to monitor.
slech
Cacti User
Posts: 90
Joined: Tue Nov 06, 2007 7:51 am

Post by slech »

I have the same problem

RRDTool Says:

ERROR: the RRD does not contain an RRA matching the chosen CF


12/29/2007 12:49:14 PM - CMDPHP: Poller[0] Host[25] DS[617] WARNING: Result from SERVER not valid. Partial Result: U
[size=75]
[color=green]|Cacti 0.87|[/color][color=green]|PA 1.3|[/color][color=green]|Poller cmd.php|[/color][color=green]|IIS 6.0|[/color][color=green]|PHP Version 5.2.4|[/color][color=green]|MySQL 5.0.27|[/color][color=green]|RRDtool 1.2.15|[/color][/size]
[color=brown]|Thold 0.3.8 |[/color] [color=red]|Zond 0.34 |[/color]
[url=http://forums.cacti.net/viewtopic.php?t=15067][size=75]Complete List of Cacti Scripts and Templates[/size][/url]
[url=http://forums.cacti.net/viewtopic.php?t=14985][size=75]Currently Known Plugins[/size][/url]
lupick
Posts: 18
Joined: Tue Nov 28, 2006 10:44 am

Post by lupick »

cigamit wrote:You are going to find that a lot of your old scripts no longer work in v0.8.7, since instead of including config.php, you need to include global.php. Also, certain functions have changed and require more arguments to support SNMP v3.

Attached is a version that should work in v0.8.7.
I've tried with cacti 0.87a ver on RHEL linuxbox.

if I run:

[root@linuxbox scripts]# php ./win_services.php winhost.domain.name public 2 9 index

PHP Fatal error: Call to undefined function read_config_option() in /var/www/html/cacti/lib/snmp.php on line 233

Any Ideas how to solve it?!?

thanks
L.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests