Trouble with external script (really strange)

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
alien2108
Posts: 4
Joined: Sat Oct 15, 2005 11:11 am

Trouble with external script (really strange)

Post by alien2108 »

Hi All!

I am now trobling over my problems with external script for two days. The thing is that script works as it should, just displays one number and that's it. Somehow cacti is refusing to pick that up (cacti 0.8.6g).

I have setup a Device Input method as "Script/Command" which takes one output field named "temp". Command is "<path_cacti>/scripts/ds1620_cacti". That's it.

Command (executable compiled with gcc) returns a simple number (without CR/LF):

[root@bladerunner scripts]# ./ds1620_cacti
46.00[root@bladerunner scripts]#

But when I turn debugging on in Cacti I see:

CMDPHP: Poller[0] Host[1] DS[12] CMD: /var/www/html/cacti/scripts/ds1620_cacti, output: U
CMDPHP: Poller[0] Host[1] DS[12] WARNING: Result from CMD not valid. Partial Result:

I have tried to manually run the script as cacti user and it works! What is very strange is also if I run:

php /var/www/html/cacti/poller.php

as cacti user it also works!

CMDPHP: Poller[0] Host[1] DS[12] CMD: /var/www/html/cacti/scripts/ds1620_cacti, output: 46.00

If I replace command with simple perl script to just print a number it always works. So config is OK I guess.

So what is different when cacti runs the script as supposed to when I run it as cacti user!?

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

Post by TheWitness »

Is it a shell script? If so, how bout "/bin/sh myscript"

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?
alien2108
Posts: 4
Joined: Sat Oct 15, 2005 11:11 am

Post by alien2108 »

No it is not shell script. it is executable. And now I did more testing. I imitated what cacti does in poller.php with:

<?php

$fp = popen("/var/www/html/cacti/scripts/ds1620_cacti","r");
$output = fgets($fp, 4096);
stream_set_timeout($fp, 25);
print("TEST=$output");

?>

If I access this through web page it works as it should. I get "TEST=44.50" displayed on page.

I tried to stick this lines into lib/poller.php to see what happens:

$ffp = popen("/var/www/html/cacti/scripts/ds1620_cacti","r");
$ff_output = fgets($ffp,4096);
cacti_log("TEST: $ff_output\n", true);

Strange! Same lines that work before now don't work.

it is total mystery to me, why it won't work in cacti. I am doing more debugging.
alien2108
Posts: 4
Joined: Sat Oct 15, 2005 11:11 am

Post by alien2108 »

Well using cactid instead of CMD.PHP did solve the problem, but mistery remains...
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests