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!
Trouble with external script (really strange)
Moderators: Developers, Moderators
- TheWitness
- Developer
- Posts: 17007
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
Is it a shell script? If so, how bout "/bin/sh myscript"
TheWitness
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?
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?
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.
<?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.
Who is online
Users browsing this forum: cigamit and 0 guests