Monitor Windows Service stats from Linux

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

Moderators: Developers, Moderators

Post Reply
lupick
Posts: 18
Joined: Tue Nov 28, 2006 10:44 am

Post by lupick »

lupick wrote:
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.

Full debug:

PHP Notice: Undefined variable: config in /var/www/html/cacti/lib/snmp.php on line 33
PHP Notice: Use of undefined constant SNMP_POLLER - assumed 'SNMP_POLLER' in /var/www/html/cacti/scripts/win_services_ori.php on line 24
PHP Warning: Missing argument 10 for cacti_snmp_walk(), called in /var/www/html/cacti/scripts/win_services_ori.php on line 24 and defined in /var/www/html/cacti/lib/snmp.php on line 225
PHP Notice: Use of undefined constant SNMP_POLLER - assumed 'SNMP_POLLER' in /var/www/html/cacti/lib/snmp.php on line 225
PHP Fatal error: Call to undefined function read_config_option() in /var/www/html/cacti/lib/snmp.php on line 233
User avatar
anemisti
Posts: 1
Joined: Sat Jan 05, 2008 9:32 am

win_service.php problem

Post by anemisti »

Hi Lupick

I solved by adding the following string to the file win_service.php

include_once(dirname(__FILE__) . "/../include/global.php");

seems to be that work correctly.

A. :o
mrloon
Posts: 14
Joined: Wed May 31, 2006 10:11 pm

Still unable to get the XML to read results

Post by mrloon »

I've grabbed the latest zip of the services query, and made the change from 36 to 35 for position (tried at 36 also), as well as the change for adding the global.php file, but still no results:

+ Running data query [26].
+ Found type = '6 '[script query].
+ Found data query XML file at 'C:/Inetpub/wwwroot/cacti/resource/script_server/win_services.xml'
+ XML file parsed ok.
+ Executing script for list of indexes 'c:\php\php.exe -q C:\Inetpub\wwwroot\cacti\scripts\win_services.php localhost 1:161:500:xxx:::MD5::DES: index'
+ Executing script query 'c:\php\php.exe -q C:\Inetpub\wwwroot\cacti\scripts\win_services.php localhost 1:161:500:xxx:::MD5::DES: query index'
+ Found data query XML file at 'C:/Inetpub/wwwroot/cacti/resource/script_server/win_services.xml'
+ Found data query XML file at 'C:/Inetpub/wwwroot/cacti/resource/script_server/win_services.xml'
+ Found data query XML file at 'C:/Inetpub/wwwroot/cacti/resource/script_server/win_services.xml'

Is there any other reason for it? When I run the script noted above manually from a command prompt, I do see the index OIDs, as well as the second line providing the names of the services.

What else should I attempt?
Cacti Version - 0.8.7a
Plugin Architecture - 1.4
Poller Type - CMD.php
Server Info - Windows NT 5.2
Web Server - Microsoft-IIS/6.0
PHP - 5.2.4
PHP Extensions - bcmath, calendar, com_dotnet, ctype, session, filter, ftp, hash, iconv, json, odbc, pcre, Reflection, date, libxml, standard, tokenizer, zlib, SimpleXML, dom, SPL, wddx, xml, xmlreader, xmlwriter, ISAPI, gd, mysql, snmp, sockets, RRDTool
MySQL - 5.0.45-community-nt
RRDTool - 1.2.15
Plugins
  • Network Discovery (discovery - v0.8.3)
    Documents (docs - v0.1)
    Host Info (hostinfo - v0.2)
    PHP Network Managing (manage - v0.5.1)
    Device Monitoring (monitor - v0.8.2)
    Global Plugin Settings (settings - v0.3)
    Thresholds (thold - v0.3.9)
    Network Tools (tools - v0.2)
    Update Checker (update - v0.4)
    ReportIt (ReportIt - v0.5.1)
    Report Creator (reports - v0.3)
ato
Posts: 3
Joined: Thu Feb 14, 2008 10:11 am

Post by ato »

I've got a blank graph in cacti 8.7b under windows 2003 SP2, and I resolv my problem.

winservice.php :


line 51:

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'],37) . "\n";
				else
					print substr($return_arr[$i]['oid'],27) . "\n";
			}
line 61:

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'],37);
				else
					$arr_index2[$i] =  substr($arr_index[$i]['oid'],27);
			}
old8xp
Posts: 5
Joined: Thu Jul 27, 2006 7:58 pm

Post by old8xp »

I have use the template in RHL 8.0 . But It can't graph a blank . "nan"

when I look the cacti log:
"03/02/2008 01:27:01 AM - CMDPHP: Poller[0] Host[2] DS[8] WARNING: Result from SERVER not valid. Partial Result: U "

it seem the template can't work well in Linux.

how can I solve it?

think U a lot.
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.
YoMarK
Cacti User
Posts: 89
Joined: Fri Feb 02, 2007 8:36 am
Location: Eindhoven/The Netherlands

Post by YoMarK »

Hi old8xp: I did have the same problem(I think).

"Solved" it by replacing

Code: Select all

if ((func_num_args() <= "4") && (func_num_args() >= "3")) {
on line 46 by

Code: Select all

if ( 1==1) {
:)

Don't know why this check is even in, because there are always 5 arguments in my case:
C:\wamp\www>php C:\wamp\www\scripts\win_services.php 10.1.14.147(1) 2:161:1000:publ
ic:::MD5::DES:(2) get(3) servstate(4) .17.65.117.116.111.109.97.116.105.99.32.85.112.100.
97.116.101234234234(5)
Also, i needed to apply the changes from mories on the first page.
rlund
Posts: 16
Joined: Fri Apr 11, 2008 9:19 am

Post by rlund »

I had to change my SNMP to version 1, and they it worked.

FYI
bharmon
Posts: 2
Joined: Wed Jun 04, 2008 9:34 am

Service State 0 for running services

Post by bharmon »

I have read thru this entire post and have solved many of my problems.

So thanks for everyone's input.

The problem I am having now is that when I monitor a service it always shows "service state 0" even though the service is running.

Does anyone have any ideas?

Thanks
bharmon
Posts: 2
Joined: Wed Jun 04, 2008 9:34 am

Service State 0 for running services

Post by bharmon »

Service Graphs started working.

Maybe I just need a little patience.

Thanks
gueutzilla
Posts: 9
Joined: Sun Jul 13, 2008 10:28 am

Post by gueutzilla »

Hi,

Thanks for this template. This work perfectly after make some modifications in win_service.php.

I have a question... Do you know how can we restart a windows service if it reply output : 0 for 2 times???

for exemple, if my service fail, I would like to send a query to force restrating service on the remote host like "net start MyService".

Is it possible???

Thanks ;o)
cigamit
Developer
Posts: 3363
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

A future version of thold will support this... but not yet.
thebull
Posts: 5
Joined: Tue Sep 30, 2008 9:28 pm

Windows Service Monitoring need assistance

Post by thebull »

I made the changes and i have the same config mentioned below and same problem. I would love to know do i need to make any changes apart from this.

ato wrote:I've got a blank graph in cacti 8.7b under windows 2003 SP2, and I resolv my problem.

winservice.php :


line 51:

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'],37) . "\n";
				else
					print substr($return_arr[$i]['oid'],27) . "\n";
			}
line 61:

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'],37);
				else
					$arr_index2[$i] =  substr($arr_index[$i]['oid'],27);
			}
User avatar
N3NCY
Cacti User
Posts: 260
Joined: Thu Sep 22, 2005 7:50 pm
Location: Landenberg, PA
Contact:

Post by N3NCY »

Any thoughts on this error?

[root@FreeBSD /usr/local/www/data/cacti/scripts]# php win_services.php 172.28.0.21 public 2

Notice: Undefined offset: 1 in /usr/local/www/data/cacti/scripts/win_services.php on line 24

Notice: Undefined offset: 2 in /usr/local/www/data/cacti/scripts/win_services.php on line 25

Notice: Undefined offset: 3 in /usr/local/www/data/cacti/scripts/win_services.php on line 43

What is a simple / valid command line test to see if win_services.php is working?
Thank you,

Ernie
http://www.NMSWorld.com
[b]Dual Zeon Dual Core 2.6Ghz / 8GB RAM / 4x15k RPM SATA RAID5[/b]
[b]Cacti Version[/b] - 0.8.7b
[b]Poller Type[/b] - cactid 0.8.7 with Boost v1.7
[b]Server Info[/b] - FreeBSD 7.0-RELEASE
[b]Web Server[/b] - Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.8g DAV/2 PHP/5.2.5 mod_perl/2.0.3 Perl/v5.8.8
[b]PHP[/b] - 5.2.6
[b]MySQL[/b] - 5.0.51b Mod: poller_output ENGINE = MEMORY
[b]RRDTool[/b] - 1.3.0
[b]SNMP[/b] - 5.4.1
[b]Plugins[/b] - Host Info (hostinfo - v0.2), Update Checker (update - v0.3), Network Tools (tools - v0.2), FlowView (flowview - v0.3), Read-only Devices Tab (devices - v0.4), Network Discovery (discovery - v0.8.3), Syslog Monitoring (syslog - v0.5.2), Thresholds (thold - v0.3.9), Device Monitoring (monitor - v0.8.2), PHP Network Weathermap (weathermap - v0.941), SuperLinks (superlinks - v0.72), Report Creator (reports - v0.1b)
cspenpen
Cacti User
Posts: 67
Joined: Tue Dec 05, 2006 5:10 am

Post by cspenpen »

Hello

I install this version, but the graph still show service state is 0.
I modify win_services.php refer to those discuss, but I still get 0.
How can I do to fix this issue?

thx
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.
Attachments
winservices.PNG
winservices.PNG (15.66 KiB) Viewed 13126 times
colaandice
Posts: 1
Joined: Thu Dec 04, 2008 1:40 am

Post by colaandice »

thanks much
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests