Spine won't run batch files or launch cscript vbs scripts

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

Moderators: Developers, Moderators

Post Reply
rnrtodd
Posts: 2
Joined: Tue Jun 30, 2009 4:50 am

Spine won't run batch files or launch cscript vbs scripts

Post by rnrtodd »

Hi all,

Can anyone tell me if SPINE is capable of executing batch files and vb scripts?

I'm trying desperately to get spine running on my windows implementation of Cacti. It has been running fine for the last 12months, although with the cmd.php poller, sometimes there have been 'gaps' in my graphs due to excessive polling times.

I use a couple of custom vb scripts called by cscript that work well. But now spine doesn't seem to want to work with these.

SPINE v0.8.7e
cygwin full install (c:\cygwin\bin in search path)
Cacti 0.8.7a

Here's an extract from the log..... (v=5)

{date/time} - SPINE: Poller[0] Host[56] SNMP Result: Host responded to SNMP
{date/time} - SPINE: Poller[0] Host[56] Host has no information for recache.
{date/time} - SPINE: Poller[0] Host[56] NOTE: There are '1' Polling Items for this Host
{date/time} - SPINE: Poller[0] Host[56] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
{date/time} - SPINE: Poller[0] Host[56] ERROR: Empty result [TESTSERVER]: 'c:/windows/system32/cscript.exe //nologo D:/www/cacti/scripts/get_CSG_stats.vbs TESTSERVER'

{date/time} - SPINE: Poller[0] Host[56] DS[289] SCRIPT: c:/windows/system32/cscript.exe //nologo D:/www/cacti/scripts/get_CSG_stats.vbs TESTSERVER, output: U
{date/time} - SPINE: Poller[0] Host[56] DEBUG: HOST COMPLETE: About to Exit Host Polling Thread Function

I've ensured the full path is listed, and the forward slashes are used. I've also tried this with backslashes too for good measure.

thanks in advance....

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

Post by BSOD2600 »

Cacti 0.8.7a? Time for an upgrade. 0.8.7e is the latest.

If you manually run that command, I assume it works fine? What about when you run it under the account credentials of the web server (IUSR_ for XP, IIS_WPG for 2003, IIS_USRS for Vista/7) ?

Consider reading my faq which address how to properly configure WMI for user accounts.
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

With this new install, I made a few changes to attempt to make things a bit smarter. First off, do you have a full cygwin install? What version "uname -a"? Also, do you have the sh.exe in the same directory with all the rest of the stuff from the package.

To get this working, you may have to run some magic in your script. Unfortunately, I am not escaping backslashes fully in the code. I did a hack to protect (not alter) anything beyond the second script command level argument. So, it may be that you simply need to move the WMI components a little further down the stack.

So, instead of simply "cscript ... blah blah blah", you would do the following:

Code: Select all

cmd /c cscript ... blah blah blah
This is ugly, because, the way Cygwin works is this. First when we fork a command using the "popen" call, it first runs a "sh.exe", which first requires a "cmd.exe". The the sh.exe, then forks another sh.exe to actually run your process. So it looks like the following:

Code: Select all

spine -> cmd.exe -> sh.exe -> sh.exe -> cmd.exe -> cscript.exe
That's ugly!. This is one of the reasons I wrote the script server. Protects you from that nasty behavior. You should consider moving to that.

Anyway, remember to re-populate the poller cache after you change the script, unless you are running 0.8.7e. I think we fixed that there.

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?
rnrtodd
Posts: 2
Joined: Tue Jun 30, 2009 4:50 am

Post by rnrtodd »

Thanks for your quick response folks....

Q: Full install of CYGWIN?
A: Yes....
CYGWIN_NT-5.2 E1VMCTXMON1 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin

Q: Do I have the sh.exe in the same directory with all the rest of the stuff from the package.
A: Yes (C:\cygwin\bin) - however SH.EXE also lives in the C:\CACTI directory along with SPINE.EXE and RRDTOOL.EXE

As a test, I've changed the script to: cmd /c d:\www\cacti\scripts\test.bat

Where test.bat is to generate a simple output to the screen, so it contains:
@echo result:22

But when I run spine I get....
{date/tiome} - SPINE: Poller[0] Host[56] NOTE: There are '1' Polling Items for this Host
9 [main] sh 4448 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
{date/tiome} - SPINE: Poller[0] Host[56] ERROR: Empty result [AUSCTRXG03]: 'cmd /c d:/www/cacti/scripts/test.bat'
{date/tiome} - SPINE: Poller[0] Host[56] DS[289] SCRIPT: cmd /c d:/www/cacti/scripts/test.bat, output: U
{date/tiome} - SPINE: Poller[0] Time: 1.8120 s, Threads: 10, Hosts: 2


SH.EXE.stackdump:
Exception: STATUS_ACCESS_VIOLATION at eip=0043AF00
eax=00000000 ebx=00000000 ecx=61106EC8 edx=00000000 esi=611021A0 edi=0045A190
ebp=0022CCE8 esp=0022C6AC program=c:\cacti\sh.exe, pid 524, thread main
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0022CCE8 0043AF00 (00000003, 6116ACA0, 00A90090, 00000000)
0022CD98 610060D8 (00000000, 0022CDD0, 61005450, 0022CDD0)
61005450 61004416 (0000009C, A02404C7, E8611021, FFFFFF48)
15 [main] sh 524 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)




Any help is greatly appreciated.

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

Post by TheWitness »

Since you have the full install of Cygwin, remove everything from the spine directory except spine itself and the conf file.

Also, I should check to verify that your cygwin build and mine are the same, but not tonight.

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?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests