Monitor Windows Service stats from Linux

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

Moderators: Developers, Moderators

Post Reply
oakfan52
Posts: 28
Joined: Mon Jan 02, 2006 9:26 pm
Location: Sacramento, CA

Monitor Windows Service stats from Linux

Post by oakfan52 »

What I want to do is monitor windows service stats from my Linux cacti. For example I just want to know the current state of the spooler service on my print server. so i can set the threshold to alert me if the spooler srevice stops.
elnino
Cacti User
Posts: 205
Joined: Tue Mar 08, 2005 9:51 pm

Post by elnino »

I know it's possible to monitor processes running on Compaq/HP servers running Insight Manager. As far as monitoring certain services, I'm not sure if that is possible via SNMP.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Look at the OID .1.3.6.1.2.1.25.4.2.1.7. It maintains the list of all processes and if they're running, paused, etc.
oakfan52
Posts: 28
Joined: Mon Jan 02, 2006 9:26 pm
Location: Sacramento, CA

Post by oakfan52 »

I have already found a script9s) to show all running processes. I am looking for services not processes.
elnino
Cacti User
Posts: 205
Joined: Tue Mar 08, 2005 9:51 pm

Post by elnino »

Thats not going to be possible through SNMP. You'll probably need to run something locally on the server to check the status and then a script on the Cacti machine to grab that data
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Well since the running processes are the services running, thats the closest you're going to be able to get. Otherwise, you're going to need to use WMI to get more detail.
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

BSOD2600 wrote:Well since the running processes are the services running, thats the closest you're going to be able to get. Otherwise, you're going to need to use WMI to get more detail.
Actually, there is a way to monitor Services from Linux. The OID is .1.3.6.1.4.1.77.1.2.3.1.1 for the index for the services. There is another OID for the service state, which basically returns 0 for stopped, and 4 for running (paused, etc... seem to return 0 instead of what they are suppose to).

I actually have been monitoring Services at work using this for the last 8 months or so, I already have the script and templates setup, I'll post them here once I get back to work tomorrow.
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Actually, here it is now. I had to do a few changes to it, since it was originally used for Cacti v0.8.6c (which is what our production server still runs, way too many modifications to upgrade at this time) but this was exported from v0.8.6i so you shouldn't have any issues with it.

If someone could verify that it works for them also, then I will go ahead and create some instructions for it.
Attachments
services.zip
(4.12 KiB) Downloaded 13754 times
Last edited by cigamit on Mon Nov 06, 2006 9:50 am, edited 3 times in total.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

oh yea, completely forgot about the lanmanager OID stuff.
oakfan52
Posts: 28
Joined: Mon Jan 02, 2006 9:26 pm
Location: Sacramento, CA

Post by oakfan52 »

Thanks,

I will work on it tonight.
User avatar
Scipio
Posts: 22
Joined: Tue Oct 12, 2004 4:49 am
Location: Switzerland
Contact:

Post by Scipio »

Hello,

I could not make this work. So I started debugging. The PHP code was OK but something was wrong. I always had 0 state for every services. After digging in the logs drinking a few coffees, I realize that the oid in the DB was too short... the field was cutting of a little bit of the OID. Here is an exemple:

Code: Select all

d:\webserver\cacti2.xxxx.com\scripts\win_services.php win_services 192.168.1.21 public 1 130 get servstate 49.72.101.114.107.105.109.101.114.32.67.97.98.108.101.69.97.115.121.32.46.78.101.116.32.83.99.104.101.100.117.108.101.114.32.67.111.110.116.114.111.108.108.101
instead of:

Code: Select all

d:\webserver\cacti2.xxxx.com\scripts\win_services.php win_services 192.168.1.21 public 1 130 get servstate 49.72.101.114.107.105.109.101.114.32.67.97.98.108.101.69.97.115.121.32.46.78.101.116.32.83.99.104.101.100.117.108.101.114.32.67.111.110.116.114.111.108.108.101.114.32.86.49.46.50
So here is the fix:
In the table poller_item, the field arg1 is a varchar(250). I changed it to TEXT. Then in cacti I cleared the poller cache. Then It was working :)

I dont know if this fix generate some troubles with the rest of cacti but I saw nothing wrong for the moment.
Tiago Coimbra
Gruyère Energie
lex8009
Posts: 37
Joined: Thu May 18, 2006 4:30 pm

service monitoring

Post by lex8009 »

Cigamit, the service monitoring that script and template you created, is that specific for linux, or can be used for cacti on windows?
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: service monitoring

Post by cigamit »

lex8009 wrote:Cigamit, the service monitoring that script and template you created, is that specific for linux, or can be used for cacti on windows?
Its just polling using SNMP, so it does not matter if you base cacti machine is Linux or Windows. The machine you are monitoring has to be windows ofcourse.
mories
Posts: 8
Joined: Fri Dec 30, 2005 1:45 pm

Post by mories »

cigamit,

i was having some trouble getting this to work.
at first i changed the arg1 field to text as mentioned before.

then i noticed that the index of the services was one character to short.
in the 'view poller cache' screen i saw that the action for the datasource was
"Action: 2, Script: /var/www/html/scripts/win_services.php win_services charlie public 1 14 get servstate 1.77.83.83.81.76.83.69.82.86.69.82"

where it should be .... "11.77.83.83.81.76.83.69.82.86.69.82"

so after some looking around i found that this statement which was there twice was causing the problem.
-------
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";
-----
i changed the values 36 and 26 to 35 and 25 in both occurences, recreated some graphs and they are working now.

i do not have the knowledge to see what happens exactly. i am running this on cactiez beta 3.

Thanks for you great work on the plugins and CactiEZ.
Last edited by mories on Fri Jun 16, 2006 12:55 pm, edited 1 time in total.
qwertz
Cacti User
Posts: 98
Joined: Thu Feb 16, 2006 9:20 am

Post by qwertz »

What a beautiful template!

Everything worked perfectly on my ubuntu machine

THANKS

Qwertz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest