At last - Windows Services monitoring with WMI!

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

Moderators: Developers, Moderators

Dave96
Posts: 13
Joined: Sat Jan 21, 2006 7:52 pm

Post by Dave96 »

Is there any tutorial on how to use Cacti with WMI monitoring?

I'm interested in this script but not sure how to implement it.
User avatar
mrh
Cacti User
Posts: 84
Joined: Tue Mar 08, 2005 9:50 am

Post by mrh »

Mike, I recommend that you just import the xml as is, then goto the input methods and check that yours looks this way:

cscript <nologo> <path_cacti>/scripts/Win32_Services.vbs <hostname> <servicename>
mrh | cacti 0.8.6h | plugin architecture | thold | monitor | iis6
Mikeos
Posts: 9
Joined: Wed Jun 07, 2006 9:06 am

Post by Mikeos »

Hi MRH,

Thanks for the last post, I checked my data input method and changed it to what you recommended. I can run the script from the command line without any problems. I turned debugging on for one poller cycle and saw this in the output debug:-

CMD: cscript //nologo C:/Inetpub/wwwroot/cacti/scripts/win_services.vbs localhostW32Time, output: U

Looks like its not adding a space between the server and service its trying to query. Im my data input method there is a space (checked and re-checked). Is it the markup on the XML file that is the issue now ?

Thanks for your help so far....

Cheers

-Mike
User avatar
mrh
Cacti User
Posts: 84
Joined: Tue Mar 08, 2005 9:50 am

Post by mrh »

Strange... the space should be there. Anyway, have you checked that the scheduled task for the poller is being run with a privileged user?

Try to run from the cmd line with the scheduled task user... if working then try to re-check once more for that space - bear in mind that if you add the space on the data input method, it probably won't be refreshed on the data template or data source... check! ;)
mrh | cacti 0.8.6h | plugin architecture | thold | monitor | iis6
User avatar
mrh
Cacti User
Posts: 84
Joined: Tue Mar 08, 2005 9:50 am

Post by mrh »

I think I found the problem. The cscript appears not be working always with the //nologo option, so my recommendation is: open a shell cmd with your poller scheduled user and run: "cscript //nologo /S" - this will save the //nologo for future cscript uses with that user on your cacti machine - let me know the results :)
mrh | cacti 0.8.6h | plugin architecture | thold | monitor | iis6
User avatar
mrh
Cacti User
Posts: 84
Joined: Tue Mar 08, 2005 9:50 am

Post by mrh »

Mike, you'll need to delete your graphs and create them again if any changes have been made to the data input method... I've personally checked that will fix your "space" problem ;)
mrh | cacti 0.8.6h | plugin architecture | thold | monitor | iis6
rodesian
Posts: 1
Joined: Fri Oct 13, 2006 4:49 am

No Data in Graph

Post by rodesian »

Hello, i have read the hole Topic, so far. I have import the Scritp frot Site 2
an ther is an error. I dont now how to fix it.
Pleas HELP me.

:(
Attachments
import_error.jpg
import_error.jpg (32.15 KiB) Viewed 14166 times
tymbow
Cacti User
Posts: 54
Joined: Sat May 14, 2005 8:00 pm

Post by tymbow »

Please don't take this the wrong way as I don't mean this to be rude but why is this monitoring services with WMI "at last"? Have people had issues doing this... just interested?
Is there any tutorial on how to use Cacti with WMI monitoring?
I started writing a generic framework for pulling WMI based data into Cacti but I got bored with it because it was easier to just knock up a script for whatever WMI data I needed. It's all really easy to do (well, relatively) so I suppose I could try to write something up if enough people really want soething like this.
mumuuu
Posts: 6
Joined: Tue Mar 22, 2005 8:00 am

Post by mumuuu »

I started writing a generic framework for pulling WMI based data into Cacti but I got bored with it because it was easier to just knock up a script for whatever WMI data I needed. It's all really easy to do (well, relatively) so I suppose I could try to write something up if enough people really want soething like this.
I'm really interested by your script +1 :lol:
rodesian
Hello, i have read the hole Topic, so far. I have import the Scritp frot Site 2
an ther is an error. I dont now how to fix it.
Pleas HELP me.
I have the same problem ..... if someone have the solution
User avatar
mrh
Cacti User
Posts: 84
Joined: Tue Mar 08, 2005 9:50 am

Post by mrh »

Hi there,

I've never got any problem when exporting importing this template, however always some corrections are always required in my case, like chaning gt with < or adding spaces between ">" and "<".

Please find attached the exported template in plain text so you can copy and paste into the cacti text box (better for me than .xml files)

HAVE LUCK! :)
Attachments
win32_services.txt
(8.09 KiB) Downloaded 1354 times
mrh | cacti 0.8.6h | plugin architecture | thold | monitor | iis6
topstuff
Posts: 6
Joined: Thu Jan 31, 2008 2:13 am

Still problems..

Post by topstuff »

Hi,
I have been asked to investigate how to use WMI with cacti, in particular would like to monitor SQL Server..

I am a complete novice with cacti and WMI so please be patient with me!

Essentially I have downloaded the file from the forum "cacti_graph_template_win32_services_137.xml" then I have tried to import it.. and received the 3 errors as mentioned before "unmet dependencies". (See output below).

My confusion is I can run the following command with output: -1
cscript ./win32_services.vbs localhost W32Time HOWEVER
1. How does the above script relate to the XML file imported? (Two different query's yeah?
2. How do I use the smaller vbs script (win32_services.vbs) to create a graph in cacti?
3. The 3 unmet dependencies with the XML file whilst importing is an error.. if yes, how to fix it?

Keeping in mind I would like to ultimately monitor SQL Server via WMI any advice would be *greatly* appreciated.

Thanks
Sam


**** Import Output *****


GPRINT Preset

[success] Normal [update]
[success] Exact Numbers [update]

Data Input Method

[success] Win32 Services [update]

Data Template

[success] Win32 Services [update]
+ Found Dependency: (Data Input Method) Win32 Services
+ Found Dependency: (Data Input Field) ServiceState
+ Unmet Dependency: (Data Input Field) Output Type ID
+ Unmet Dependency: (Data Input Field) Index Value
+ Unmet Dependency: (Data Input Field) Index Type

+ Found Dependency: (Data Input Field) Hostname
+ Found Dependency: (Data Input Field) ServiceName
+ Found Dependency: (Data Input Field) NoLogo

Graph Template

[success] Win32 Services [update]
User avatar
mrh
Cacti User
Posts: 84
Joined: Tue Mar 08, 2005 9:50 am

Post by mrh »

hi, you need to make sure you copied the vbs file to the \scripts folder in your cacti installation, after that, double check the input methods for the right command line. the errors you all are experiencing with the import could be due to a different cacti version, but at least it imports it.

also please make sure the poller runs with an account has the privileges to get the -1 or 0 results.

hope this helps... i'm using this script without modifications since long long time ago, however it should be rewritten into perl as the nologo command that cscript generates is a pitfall to avoid - i remember i needed to modify the nologo permanently (see cscript cmd-line help) from the poller account profile.
mrh | cacti 0.8.6h | plugin architecture | thold | monitor | iis6
topstuff
Posts: 6
Joined: Thu Jan 31, 2008 2:13 am

Script errors

Post by topstuff »

Thanks for the reply.
Having not built WMI scripts before, I asked a colleague to help me debug the script.. we straight away noticed that the script was not returning any info.. my colleague was really surprised that the forum posts has mentioned if the script returned -1 then everything was ok, given that the script early on appears to fail, not sure how to proceed.

I added the vbs script to the script directory but no luck:
<path to cacti>\scripts\win32_services.vbs

Input String defined in cacti:
cscript <nologo> <path_cacti>/scripts/Win32_Services.vbs <hostname> <servicename>


I am suppose to eventually create custom WMI scripts for disk/SQL server usage..

Thanks again for your help and any further advice/info would be great.

-Sam
danwdoo
Cacti User
Posts: 50
Joined: Thu Oct 26, 2006 11:42 pm

Specifying a username for remote hosts

Post by danwdoo »

Hello,
I am wanting to use this script to monitor the services on a couple of XP workstations that are not domain members. Is there a way to specify a local user account that it will use with the script so it can connect via WMI?

Thanks!
Danny
Gunnar
Posts: 14
Joined: Wed Jun 24, 2009 10:38 am

Post by Gunnar »

I have been able to install and run the script. Nice - Thank you.

However, as I have several services i like to monitor, the graph title does not show the service monitored.

I tried to add "|query_ServiceName|" and "<servicename>", amongst others, in the title field of the graph template, but no success.

Does anyone have an idea on how to do this correctly?

thanks as always!
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests