VBS Help

Post support questions that relate to the Windows 2003/2000/XP operating systems.

Moderators: Developers, Moderators

User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

VBS Help

Post by pshankland »

Have been using Cacti for a while now and find it brilliant for collecting SNMP info but know, after reading through this forum, that it can do so much more.

I have downloaded the NT Scripts that use WMI to collect Win32 data through VBS and then via PHP deliver the info to Cacti. Could someone please take me through the steps needed to have IISUtils.vbs and IISUtils.php sitting on my desktop to them running within a brand new install of Cacti?

I need this noddy information once and I then feel I can create my own scripts - this info would probably be useful to a lot of other people as well.

Thanks.

Pete.
User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

Post by pshankland »

After looking through the forum 'a lot' I have got the following VBS file which has the following usage: cscript.exe w32_PhysicalDisk.vbs <server_name>

Code: Select all

strComputer=Wscript.Arguments.Item(0)
Set objWMIService=GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objPhysicalDisk=objWMIService.instancesof("Win32_PerfRawData_PerfDisk_PhysicalDisk")
For Each objItem in objPhysicalDisk
	CurrentDiskQueueLength=objItem.CurrentDiskQueueLength
Next

Wscript.Echo CurrentDiskQueueLength
This now gives me an input of the server name and an output. Could someone help me with the required *.pl file needed to run this vbs? Also, how to get the vbs and pl working within Cacti?

Thanks.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

A .pl file is a perl script. You'll need to install that on your server.

To get it working in cacti, you'll need to create a Data Input Method. In the input string, put something like: perl <path_cacti>/scripts/hddhealth.pl <HDDReport> <HDDData>. I also suggest you read the cacti manual, as it covers some of this. Also look at other working examples in cacti.
User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

Post by pshankland »

Right, this is what I have got so far:
  • 1-- Created the VBS file with 1 input and 1 output
    2-- Created a new Data Input Method, with cscript.exe <path_cacti>/scripts/w32_PhysicalDisk.vbs <strComputer> as the input string (Script/Command as input type) and an Input Field called strComputer and an Output Field called CurrentDiskQueueLength
    3-- Then, created a new Data Template using the above Data Input Method, a new Data Source and the field |host_hostname| in as the Data Input
    4-- Then, a very simply Graph Template at the moment with a Line1 and GPRINT items both reporting the DS created before
    5-- I then finally added the graph template to a couple of my Win2000 machines but although the graphs get generated I get a value of 0 all the time.
Anyone?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Sounds good... just need to debug what is going on.

1) Turn up the logging level in cacti and look for your script running. Does it return anything? If so,
2) Dump your rrd file the script is using and verify the data is going into that (rrdtool dump filename.rrd > filename.xml). If so,
3) Verify your graph template has the correct DS name you assigned in the data template for this script. disable any web accelerating programs and take a look at the working graph.
User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

Post by pshankland »

I created another script and other templates based on something I know would have a value - Current CPU Voltage but am still getting the same issues, no info.

Have set Cacti to DEBUG log level and am getting the following:

Code: Select all

11/23/2005 07:12:21 PM - CACTID: Poller[0] Host[14] ERROR: Empty result [172.29.2.23]: 'cscript.exe //nologo D:/Cacti/scripts/w32_CPU.vbs 172.29.2.23'
11/23/2005 07:12:21 PM - CACTID: Poller[0] Host[14] DS[43] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/23/2005 07:12:21 PM - CACTID: Poller[0] Host[14] ERROR: Empty result [172.29.2.23]: 'cscript.exe //nologo D:/Cacti/scripts/w32_PhysicalDisk.vbs |host_hostname|'
11/23/2005 07:12:21 PM - CACTID: Poller[0] Host[14] DS[42] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/23/2005 07:12:21 PM - CACTID: Poller[0] Host[14] DS[38] WARNING: Result from SERVER not valid.  Partial Result: ...
I exported the RRD file as well and am getting no data in there either (a small sample):

Code: Select all

<!-- Round Robin Database Dump -->
<rrd>
	<version> 0003 </version>
	<step> 300 </step> <!-- Seconds -->
	<lastupdate> 1132773900 </lastupdate> <!-- 2005-11-23 19:25:00 GMTST -->

	<ds>
		<name> ds_wmi_cpuvolts </name>
		<type> GAUGE </type>
		<minimal_heartbeat> 600 </minimal_heartbeat>
		<min> 0.0000000000e+00 </min>
		<max> 1.0000000000e+02 </max>

		<!-- PDP Status -->
		<last_ds> UNKN </last_ds>
		<value> 0.0000000000e+00 </value>
		<unknown_sec> 0 </unknown_sec>
	</ds>

<!-- Round Robin Archives -->
	<rra>
		<cf> AVERAGE </cf>
		<pdp_per_row> 24 </pdp_per_row> <!-- 7200 seconds -->

		<params>
		<xff> 5.0000000000e-01 </xff>
		</params>
		<cdp_prep>
			<ds>
			<primary_value> 0.0000000000e+00 </primary_value>
			<secondary_value> 0.0000000000e+00 </secondary_value>
			<value> 0.0000000000e+00 </value>
			<unknown_datapoints> 16 </unknown_datapoints>
			</ds>
		</cdp_prep>
		<database>
			<!-- 2005-05-27 21:00:00 GMTDT / 1117224000 --> <row><v> NaN </v></row>
			<!-- 2005-05-27 23:00:00 GMTDT / 1117231200 --> <row><v> NaN </v></row>
			<!-- 2005-05-28 01:00:00 GMTDT / 1117238400 --> <row><v> NaN </v></row>
			<!-- 2005-05-28 03:00:00 GMTDT / 1117245600 --> <row><v> NaN </v></row>
			<!-- 2005-05-28 05:00:00 GMTDT / 1117252800 --> <row><v> NaN </v></row>
			<!-- 2005-05-28 07:00:00 GMTDT / 1117260000 --> <row><v> NaN </v></row>
Stuck again now, thought I was getting somewhere :)
User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

Post by pshankland »

To show the exact steps I have taken with screenshots, please take a look at the following PDF file:

My WMI Problems

Let me know.

Thanks.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Does is run properly from the command line? If so, please try the Cactid from the following link: http://forums.cacti.net/viewtopic.php?p ... ght=#49066

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

With that version, you will have to provide the full path to cscript.exe in your data input method and then clear your poller cache.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

Post by pshankland »

TheWitness,

I have used the pre-Beta CatiD G version, used the full path to cscript (c:\windows\system32\cscript.exe), and also cleared the poller cache - unfortunatly still don't get any results and am getting the following in the logfile:

Code: Select all

11/23/2005 09:48:19 PM - CACTID: Poller[0] Host[14] ERROR: Empty result [172.29.2.23]: 'C:\Windows\System32\cscript.exe //nologo D:/Cacti/scripts/w32_CPU.vbs |host_hostname|'
11/23/2005 09:48:19 PM - CACTID: Poller[0] Host[14] DS[43] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/23/2005 09:48:19 PM - CACTID: Poller[0] Host[14] DS[43] SCRIPT: C:\Windows\System32\cscript.exe //nologo D:/Cacti/scripts/w32_CPU.vbs |host_hostname|, output: U
11/23/2005 09:48:19 PM - CACTID: Poller[0] Host[14] DEBUG: The POPEN returned the following File Descriptor 9
11/23/2005 09:48:26 PM - CACTID: Poller[0] Host[14] ERROR: Empty result [172.29.2.23]: 'C:\Windows\System32\cscript.exe //nologo D:/Cacti/scripts/w32_PhysicalDisk.vbs |host_hostname|'
11/23/2005 09:48:26 PM - CACTID: Poller[0] Host[14] DS[42] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/23/2005 09:48:26 PM - CACTID: Poller[0] Host[14] DS[42] SCRIPT: C:\Windows\System32\cscript.exe //nologo D:/Cacti/scripts/w32_PhysicalDisk.vbs |host_hostname|, output: U
11/23/2005 09:48:26 PM - PHPSVR: Poller[0] DEBUG: INCLUDE: 'D:\Cacti\scripts\ss_host_cpu.php' SCRIPT: 'ss_host_cpu' CMD: '172.29.2.23 14 1:161:500:public:::MD5::[None] get usage 0'
11/23/2005 09:48:27 PM - PHPSVR: Poller[0] SERVER: D:\Cacti\scripts\ss_host_cpu.php ss_host_cpu 172.29.2.23 14 1:161:500:public:::MD5::[None] get usage 0 output U
11/23/2005 09:48:27 PM - CACTID: Poller[0] Host[14] DS[38] WARNING: Result from SERVER not valid.  Partial Result: ...
11/23/2005 09:48:27 PM - CACTID: Poller[0] Host[14] DS[38] SERVER: D:\Cacti\scripts\ss_host_cpu.php ss_host_cpu 172.29.2.23 14 1:161:500:public:::MD5::[None] get usage 0, output: U
Any more suggestions - has it got anything to do with the |host_hostname| bit?

PS - as the pre-beta CactiD didn't work should I put it back to the current release?

Thanks.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Use forward slashes in your cscript path.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

can you run strace while running cactid from the command line and let me know what happens.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

command is (from source directory) "strace cactid host_id host_id" where the host_id is the one with the bugger script.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Personally, I'd try to get the script to work on cmd.php before moving to cactid, since as you've experianced, it has problems some times.

As per your rrd file output, notice you posted the logs from around 2005-05-28. Today is 2005-11-23. Scroll down in the xml file and take a look. This of course will only apply once the script actually sucessfully runs in Cacti...
User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

Post by pshankland »

TheWitness -- could you please explain the strace and host_id a bit more to me as I am having a few problems understanding completly

BSOD2600 - have just changed to using cmd.php and am basically getting the same results as with cactid:

Code: Select all

11/23/2005 10:25:01 PM - CMDPHP: Poller[0] Host[14] DS[42] WARNING: Result from CMD not valid.  Partial Result: 
11/23/2005 10:25:01 PM - CMDPHP: Poller[0] Host[14] DS[42] CMD: C:\Windows\System32\cscript.exe //nologo D:/Cacti/scripts/w32_PhysicalDisk.vbs |host_hostname|, output: U
11/23/2005 10:25:01 PM - CMDPHP: Poller[0] Host[14] DS[43] WARNING: Result from CMD not valid.  Partial Result: 
11/23/2005 10:25:01 PM - CMDPHP: Poller[0] Host[14] DS[43] CMD: C:\Windows\System32\cscript.exe //nologo D:/Cacti/scripts/w32_CPU.vbs |host_hostname|, output: U
The XML dump was massive so didn't bother listing it all here :)

Both -- I have changed to using forward slashes (/'s) within the Script/Command but it dosn't seem to show!

Code: Select all

C:/Windows/System32/cscript.exe //nologo <path_cacti>/scripts/w32_CPU.vbs <strComputer>
Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests