I've seen something strange today. I tried to develop a php Script/Command. I couldn't get output of the script (via print()) in Cacti, although the script run correctly in the Unix shell. Finally I realized no output was even present just after the script was run in poller.php. The command line was:
/usr/local/bin/php <path>/myscript.php <param1> <param2>
Finally I tried to do something with output redirection:
/usr/local/bin/php <path>/myscript.php <param1> <param2> 2>&1
Unexpectedly I _got_ the output in Cacti and I saw the graph!
This is PHP cli 4.4.0 under Solaris. I really don't know what could be the reason of this behavior. This is for the records. Any comments?
php script and output redirection
Moderators: Developers, Moderators
no, it's not the case, there are no errors. the script just returns designed correct output results - using print(). these results are visible when running at the prompt in terminal window, they're even visible when script is called from another script, but the're not visible in Cacti (until output redirection is applied).bulek wrote:It may happen that your script reports some error which is taken as a normal output of your script.
Well... yes, I understand that the script works correctly from command line. The difference is that cacti runs the scripts using crontab... in crontab there is some minimal environment defined - variables, path - and there can be missing something. This is quite common when a script works in shell but does not in Cacti. Try to redirect whole output to some file (inside crontab file) and look at the potential errors.
- Piotr
- Piotr
- TheWitness
- Developer
- Posts: 17007
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
What version of glibc are you running? I just saw this recently on a development version of GLIBC where stderr would fire the underlying select statement within popen function causing pre-mature return of partial results.
TheWitness
p.s. This would be caused by some warning or the like from your popen call.
TheWitness
p.s. This would be caused by some warning or the like from your popen call.
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?
Who is online
Users browsing this forum: No registered users and 6 guests