VBScript/WMI problem

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

Moderators: Developers, Moderators

Post Reply
donc
Posts: 13
Joined: Wed Oct 25, 2006 2:45 pm

VBScript/WMI problem

Post by donc »

I've been banging my head against the wall trying to figure this problem out today so I'm hoping someone here can help.

I have a clean Cacti install (0.8.6j) running on Windows Server 2003 (std. edition). Cacti is all patched up as is Windows. SNMP polling works against the localhost and I can see my graphs for the data collected that way. What I can't seem to get working is the collection of WMI data via VBScript.

I ran through the instructions on the Simplest Method of Going from Script to Graph with a couple of minor changes (swapping out my vbscript for the walk-through's perl). The script itself, is quite basic. It just retrieves the Processes count from Win32_PerfFormattedData_PerfOS_System:

Code: Select all

On Error Resume Next

Set objWMISvc = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMISvc.ExecQuery("SELECT * from Win32_PerfFormattedData_PerfOS_System")
For Each objItem in colItems
	WScript.StdOut.Write objItem.Processes
Next
I set up a new Data Input Method of type Script/Command and set the Input String to "c:/windows/system32/cscript.exe d:/cacti/cacti-0.8.6j/scripts/getprocesscount.vbs" (minus the quotes). However, I'm seeing an error in my logs and (obviously) nothing is being graphed:

Code: Select all

02/01/2007 06:50:01 PM - CACTID: Poller[0] Host[1] PING Result: ICMP: Host is Alive
02/01/2007 06:50:01 PM - CACTID: Poller[0] Host[1] SNMP Result: SNMP not performed due to setting or ping result
02/01/2007 06:50:01 PM - CACTID: Poller[0] Host[1] ERROR: Empty result [127.0.0.1]: 'c:/windows/system32/cscript.exe d:/cacti/cacti-0.8.6j/scripts/getprocesscount.vbs'
02/01/2007 06:50:01 PM - CACTID: Poller[0] Host[1] DS[21] WARNING: Result from SCRIPT not valid. Partial Result: ...
02/01/2007 06:50:01 PM - CACTID: Poller[0] Host[1] DS[21] SCRIPT: c:/windows/system32/cscript.exe d:/cacti/cacti-0.8.6j/scripts/getprocesscount.vbs, output: U
02/01/2007 06:50:01 PM - CACTID: Poller[0] Host[1] DS[20] SNMP: v1: 127.0.0.1, dsname: traffic_in, oid: .1.3.6.1.2.1.2.2.1.10.65539, value: 50715712
02/01/2007 06:50:01 PM - CACTID: Poller[0] Host[1] DS[20] SNMP: v1: 127.0.0.1, dsname: traffic_out, oid: .1.3.6.1.2.1.2.2.1.16.65539, value: 27879333
02/01/2007 06:50:01 PM - CACTID: Poller[0] Time: 0.8280 s, Threads: 1, Hosts: 2
02/01/2007 06:50:01 PM - SYSTEM STATS: Time:1.1137 Method:cactid Processes:1 Threads:1 Hosts:2 HostsPerProcess:2 DataSources:3 RRDsProcessed:2
I've verified that the script by itself will run properly using the same credentials as the scheduled task but I continue to get the "Result from SCRIPT not valid" error in my log.

Any ideas?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Possibly an cactid issue. Try with cmd.php poller and see if that works.
donc
Posts: 13
Joined: Wed Oct 25, 2006 2:45 pm

Post by donc »

I tried using cmd.php but it throws back the same error:

Code: Select all

02/01/2007 07:20:08 PM - CMDPHP: Poller[0] Host[1] PING: Host is alive
02/01/2007 07:20:08 PM - CMDPHP: Poller[0] Host[1] SNMP: Host responded to SNMP
02/01/2007 07:20:09 PM - CMDPHP: Poller[0] Host[1] DS[20] SNMP: v1: 127.0.0.1, dsname: traffic_out, oid: .1.3.6.1.2.1.2.2.1.16.65539, output: 37806977
02/01/2007 07:20:09 PM - CMDPHP: Poller[0] Host[1] DS[20] SNMP: v1: 127.0.0.1, dsname: traffic_in, oid: .1.3.6.1.2.1.2.2.1.10.65539, output: 57538610
02/01/2007 07:20:09 PM - CMDPHP: Poller[0] Host[1] DS[21] WARNING: Result from CMD not valid.  Partial Result: Microsoft (R) Window
02/01/2007 07:20:09 PM - CMDPHP: Poller[0] Host[1] DS[21] CMD: c:/windows/system32/cscript.exe d:/cacti/cacti-0.8.6j/scripts/getprocesscount.vbs, output: U
02/01/2007 07:20:09 PM - CMDPHP: Poller[0] Time: 0.6442 s, Theads: N/A, Hosts: 1
02/01/2007 07:20:10 PM - SYSTEM STATS: Time:3.1477 Method:cmd.php Processes:2 Threads:N/A Hosts:2 HostsPerProcess:1 DataSources:3 RRDsProcessed:2
It also doesn't seem to have an effect if I use WScript.Echo or Wscript.StdOut.Write/WriteLine to return the result.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Since one can see the script is returning part of the "Microsoft (R) Windows Script Host Version 5.6" stuff, you must run the script with the //nologo command. Look at how others on the forum running WMI scripts handle it and follow their example.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

What version of Cactid?

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?
donc
Posts: 13
Joined: Wed Oct 25, 2006 2:45 pm

Post by donc »

BSOD2600 wrote:Since one can see the script is returning part of the "Microsoft (R) Windows Script Host Version 5.6" stuff, you must run the script with the //nologo command. Look at how others on the forum running WMI scripts handle it and follow their example.
Good catch. The //nologo option wasn't saved when I manually ran the poller as the local administrator on the box. If you look at the run above when it was cactid you can see where cscript wasn't spitting out the logo. Adding that and rerunning it as the local administrator worked. Now, however, when I run it under the same context as the scheduled task it gets stuck at "Waiting on 1/2 pollers" and the following is logged:

02/02/2007 09:30:01 AM - CMDPHP: Poller[0] ERROR: Either there are no items in the cache or polling is disabled

That persists after rebuilding the poller cache. The user running the Scheduled Task does have local admin rights on the machine and I've set all the perms using the script referenced here.

I'm running cactid version 0.8.6.i from here.

Is there any way to capture or see what, specifically, cactid is receiving when it runs?
donc
Posts: 13
Joined: Wed Oct 25, 2006 2:45 pm

Post by donc »

I think it's a problem within cactid. I dropped the version of cactid referenced in this thread into the cactid folder and then moved the 1.5.21 version of cygwin1.dll to the /cygwin/bin folder and now the vbscript polling is working properly.

Code: Select all

02/02/2007 10:57:01 AM - CACTID: Poller[0] Time: 0.5930 s, Threads: 1, Hosts: 1
02/02/2007 10:57:02 AM - CACTID: Poller[0] Host[1] PING Result: ICMP: Host is Alive
02/02/2007 10:57:02 AM - CACTID: Poller[0] Host[1] SNMP Result: Host responded to SNMP
02/02/2007 10:57:02 AM - CACTID: Poller[0] Host[1] DS[22] SCRIPT: c:/windows/system32/cscript.exe //nologo d:/cacti/cacti-0.8.6j/scripts/getprocesscount.vbs, output: 39
02/02/2007 10:57:02 AM - CACTID: Poller[0] Host[1] DS[20] SNMP: v1: 127.0.0.1, dsname: traffic_in, oid: .1.3.6.1.2.1.2.2.1.10.65539, value: 537449816
02/02/2007 10:57:02 AM - CACTID: Poller[0] Host[1] DS[20] SNMP: v1: 127.0.0.1, dsname: traffic_out, oid: .1.3.6.1.2.1.2.2.1.16.65539, value: 69883195
02/02/2007 10:57:02 AM - CACTID: Poller[0] Time: 1.1400 s, Threads: 1, Hosts: 2
02/02/2007 10:57:03 AM - SYSTEM STATS: Time:3.1548 Method:cactid Processes:2 Threads:1 Hosts:2 HostsPerProcess:1 DataSources:3 RRDsProcessed:2
I did try several other versions of cactid from the Windows packages folder on the cacti.net site but they all seemed to exhibit similar behavior when I was using a more recent version of the cygwin1 dll.

If there's any other data you'd like me to collect that might help you nail down the source of the problem, let me know. I'm happy to help.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest