CMD not valid. Partial Result:

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

Moderators: Developers, Moderators

BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

CMD not valid. Partial Result:

Post by BelgianViking »

I 'm trying to to better understand and use scripting in Cacti, although I have no programming background at all. I thought the great "Script to Graph Walkthrough" was a good challenge to start with. I had to change some of the details to make it work on Windows, but that went smoothly. I created a VBS script that generates a random number. Than I create a php script that prints this number.
This script is as simple as this:
<?
$Return = `cscript //Nologo random.vbs`;
print trim($Return);
?>

Running it from the command line gives me the right output:
C:\Inetpub\wwwroot\cacti\scripts>c:\php\php.exe random.php
0.4340479

However, the graph is not displaying values, and the gprint of the 'current value' displays the famous "-1,#J". The RRD file is created and the Graph debug mode says OK.

When turning on the debug level I found this in the cacti log:

06/08/2005 10:27:27 AM - POLLER: Poller[0] CACTI2RRD: c:\rrdtool\rrdtool.exe update c:\Inetpub\wwwroot\cacti\rra\random_number_129.rrd --template random_number 1118219226:U

When I ran the poller manually [c:\inetpub\wwwroot\cacti>c:\php\php.exe poller.php], an "Open with ..." window pops up, saying : Click the program you want to use to open 'random.php'

So, I made the default application to use "php-win.exe". Now, I got the following error when debugging:
06/08/2005 01:42:02 PM - CMDPHP: Poller[0] Host[0] CMD: c:\Inetpub\wwwroot\cacti\scripts\random.php, output: U
06/08/2005 01:42:02 PM - CMDPHP: Poller[0] Host[0] WARNING: Result from CMD not valid. Partial Result:


Anyone has some suggestions ?

For whom it is relevent; using Cacti 8.6.c and the CMD poller.

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

Post by BSOD2600 »

Try simply running php poller.php with out the .EXE for starters.

Look in the debug a little more for when cacti runs the script and attemps to return something. What is the output / error?
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

I ran the poller as you asked and set the logging to DEBUG. I've attached the full log, allthough it contains a lot of overhead from my other devices.
I can't find any more detailed stuff on the OUTPUT you indicate, but I might overlook something. Or do I need other/more loggings ?
Thanks already !!
Attachments
cactilog.txt
(38.35 KiB) Downloaded 468 times
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Hmm, did you grant the proper permissions to the user for the schedule task to cmd.exe, php-win.exe, random.php, and rrdtool.exe ?
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

I think so. I made the Administrator the sheduled task user, and I logged in as Administrator and ran the poller manually. Same result. And since all the other stuff works, it could only have been random.php-rights, the others are used for all stats ...
Is there any way to get more information or error messages, maybe by changing some scripts ?
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

please include full path to vbs code in your 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?
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

My script is now
<?php
$Return = `cscript //Nologo c:\inetpub\wwwroot\cacti/random.vbs`;
print trim($Return);
?>
... but it doesn't do the trick ... Damn.
Allthough it doesn't make me less enthousiast about Cacto ;-)
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

that's vbs, make sure you use only back slashes...

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?
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

OK, fair enough. Tried this
<?php
$Return = `cscript //Nologo c:\inetpub\wwwroot\cacti\\random.vbs`;
print trim($Return);
?>
Same result.

In order to skip the VBS sidestep (which I wanted to test) I now created this php script that generates the random number itself:
<?php
srand((double)microtime()*1000000);
$Return = rand(0,1000)/1000;
print trim($Return);
?>

It also works OK on the command line, but not through the poller. Same errors.
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

single backslash please :(
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?
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

The double backslash works fine when I run it manually. If I ommit the second, the '\r' gets interpreted as the carriage return.
Still, the version without the call to the vbs should do the job too...
Last edited by BelgianViking on Mon Jun 13, 2005 1:14 am, edited 1 time in total.
[size=75][color=#EE5019]| Cacti 0.8.6g | MySQL 4.1.14 w Query Cache | Net-SNMP 5.2.1 | IIS 6 | fast-cgi | PHP 5.0.3 | RRDtool 1.2.9 | Windows 2003 Server SP1 | Cactid 0.8.6f |
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

What happens if you use all forward slashes?

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?
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

It does exactly the same thing; works on command line, same error in log when running through the poller.
[size=75][color=#EE5019]| Cacti 0.8.6g | MySQL 4.1.14 w Query Cache | Net-SNMP 5.2.1 | IIS 6 | fast-cgi | PHP 5.0.3 | RRDtool 1.2.9 | Windows 2003 Server SP1 | Cactid 0.8.6f |
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Try this:

<?php
$command = addslashes("cscript //Nologo c:\inetpub\wwwroot\cacti\random.vbs");
$Return = `$command`;
print trim($Return) . "\n";
?>

Larry
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?
BelgianViking
Cacti User
Posts: 97
Joined: Thu Mar 24, 2005 4:59 am
Location: Brussels, Belgium

Post by BelgianViking »

Running this gave me the same '\r' interpretation (I attached a screenshot). Making it double backslashes does the trick (can see it in the screenshot too). Using slashes instead works too.
But in the cacti log ... it is the same error that appears...
Attachments
randomscript.JPG
randomscript.JPG (12.02 KiB) Viewed 10532 times
[size=75][color=#EE5019]| Cacti 0.8.6g | MySQL 4.1.14 w Query Cache | Net-SNMP 5.2.1 | IIS 6 | fast-cgi | PHP 5.0.3 | RRDtool 1.2.9 | Windows 2003 Server SP1 | Cactid 0.8.6f |
| Dell 2450 - 2x P3 733 MHz, 1GB RAM |[/size][/color]
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest