cmd.php with Script input issue ?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
PP-S3
Posts: 9
Joined: Mon Aug 02, 2004 12:32 pm

cmd.php with Script input issue ?

Post by PP-S3 »

hello,
i'm trying to use the "additionnal script" sql_stat.php on my linux server
but i have a strange behaviour which i can't sort out....

if i launch cmd.php by hand, i get the following output which is correct
Manual output for cmd.php
bash-2.05$ ./cmd.php
[...]
command: php -q /home/www/cacti/scripts/sql_stat.php Slow_queries, output: 4990
command: php -q /home/www/cacti/scripts/sql_stat.php Questions, output: 26767547
[...]
update /home/www/cacti/rra/localhost_mysql_slow_queries_8.rrd --template mysql_slow_queries N:4990
update /home/www/cacti/rra/localhost_mysql_queries_9.rrd --template mysql_queries N:26767547
time: 0
bash-2.05$
but when cmd.php is launched through cron, this is an other story...
here is what i get in rrd.log (including the log from the above cmd.php)
rrd.log output
(by cron below)
08/02/2004 8:05 PM - CMD: /usr/local/bin/rrdtool update /home/www/cacti/rra/localhost_mysql_slow_queries_8.rrd --template mysql_slow_queries N:U
08/02/2004 8:05 PM - CMD: /usr/local/bin/rrdtool update /home/www/cacti/rra/localhost_mysql_queries_9.rrd --template mysql_queries N:U
[...]
(by manual cmd.php below)
08/02/2004 8:06 PM - CMD: /usr/local/bin/rrdtool update /home/www/cacti/rra/localhost_mysql_slow_queries_8.rrd --template mysql_slow_queries N:4990
08/02/2004 8:06 PM - CMD: /usr/local/bin/rrdtool update /home/www/cacti/rra/localhost_mysql_queries_9.rrd --template mysql_queries N:26767547
[...]
(again by cron below, and so on....)
08/02/2004 8:10 PM - CMD: /usr/local/bin/rrdtool update /home/www/cacti/rra/localhost_mysql_slow_queries_8.rrd --template mysql_slow_queries N:U
08/02/2004 8:10 PM - CMD: /usr/local/bin/rrdtool update /home/www/cacti/rra/localhost_mysql_queries_9.rrd --template mysql_queries N:U
how come it works perfectly when run manually, whereas i get an "U" everytime it runs through cron :evil:

note : the cron entry belongs to the same user who ran the cmd.php manually

Anybody has an idea for me ? :)
thanks for the help :wink:

PP
User avatar
bulek
Cacti Pro User
Posts: 854
Joined: Mon May 20, 2002 2:07 am
Location: Poland
Contact:

Post by bulek »

The PATH variable (and other ones) is much shorter for cron comparing to normal user. Try to add full path to php executable or to apps launched inside of sql_stat.php script.

- Piotr
PP-S3
Posts: 9
Joined: Mon Aug 02, 2004 12:32 pm

Post by PP-S3 »

well actually, as cmd.php launches itself without any problem, i don't think it is a PATH problem for the PHP executable.

and the script itself is pretty straightforward and uses no external binary :-?

well i'll try and crawl through the cmd.php code and see how the "U" is computed...
PP-S3
Posts: 9
Joined: Mon Aug 02, 2004 12:32 pm

Post by PP-S3 »

well.... hum ! ....

looks like you were right once the cron output redirected to a file.... :oops:
actually, i re-read the crontab manpage and looks like path is not even set !

thanks for the help !! :wink:
Guest

Post by Guest »

oh ! and in case this would happen to somebody else :

even when changing the "Data Input Method" to put the full path to php, it still did not work.
The reason is that cmd.php queries the table data_input_data_cache, which -as its names implies- is..... a cache !!

so the changes were not taken into account.
a workaround (if you cannot modify the row manually in mySql for some reason)
- go to *each* Data source that uses the faulty "Data Input Method"
- in there change the selected data input method to something else (e.g put Unix Load average instead)
-save
- put back the right input method
-save

then the cache is updated and everything works fine !!! 8)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest