Poller does not run scripts

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

Moderators: Developers, Moderators

User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Poller does not run scripts

Post by tata_tulen »

Hi all,
I've problem with my scripts. I can run them manually with correct results, however poller seems to not run them - one of that script is customized ping script and in intermediate firewall log I can see packets generated by the script with manual run, but I can't see any periodically repeated packet that shoud be generated by the script with poller run...

In the cacti log I can see something like this:

Code: Select all

11/10/2011 02:44:02 PM - SPINE: Poller[0] Host[37] DS[674] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/10/2011 02:44:02 PM - SPINE: Poller[0] Host[37] DS[673] SCRIPT: perl /var/www/cacti/scripts.ping2.pl 192.168.254.10, output: U 
What could be wrong?

Thanks!
-tt-
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Poller does not run scripts

Post by noname »

Can your poller user (e.g. cactiuser) execute your script?
(permissions, pathname, etc. for all commands you're using)
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

Yes, I've created new scheduled command in cron - and the script can run.
-tt-
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

I've turn on the DEVELOP level of logging and there is something I do not understand:

Code: Select all

11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DEBUG: HOST COMPLETE: About to Exit Host Polling Thread Function
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DS[674] SCRIPT: perl /var/www/cacti/scripts/ping.pl 192.168.254.10, output: U
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DS[674] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] ERROR: Empty result [192.168.254.10]: 'perl /var/www/cacti/scripts/ping.pl 192.168.254.10'
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DEBUG: The POPEN returned the following File Descriptor 9
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DS[673] SCRIPT: perl /var/www/cacti/scripts.ping2.pl 192.168.254.10, output: U
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DS[673] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] ERROR: Empty result [192.168.254.10]: 'perl /var/www/cacti/scripts.ping2.pl 192.168.254.10'
11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DEBUG: The POPEN returned the following File Descriptor 9
How can the result of script be empty? Manual run returns a value, so as cron job (I controled it in Webmin)...

I'm not as good in linux as I'd like to be, so that I do not know all possibilities of this behaviour.
-tt-
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Poller does not run scripts

Post by noname »

Code: Select all

11/11/2011 08:36:02 AM - SPINE: Poller[0] Host[37] DS[674] WARNING: Result from SCRIPT not valid. Partial Result: ...
Did you use multiple 'print' statement in your script? (Or did you add a newline to output?)
- Making Your Scripts Work With Cacti - Cacti Docs
Note: Spine requires, that multiple parameters are spit out by a single “print” statement. Do not print them in a loop!
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

I'm testing it on this script:

Code: Select all

#!/usr/bin/perl

# take care for tcp:hostname or TCP:ip@
$host = $ARGV[0];
$host =~ s/tcp:/$1/gis;

open(PROCESS, "echo \"oops\" > /tmp/oops.txt |");
close(PROCESS);
open(PROCESS, "ping -c 1 $host |");
close(PROCESS);
open(PROCESS, "ping -c 5 $host | grep rtt |");
$ping = <PROCESS>;
close(PROCESS);
$ping =~ m/(rtt min\/avg\/max\/mdev = )(.*)\/(.*)\/(.*)\/(.*) (ms|usec)/;

if ($6 eq "usec") {
        print $3/1000;  # re-calculate in units of "ms"
}else{
        print $3;
}
As I understand your link, it should be ok. Anyway, it make me to try cmd.php poller and BINGO! That's ok. Many thanks!

However I'd like to use spine, I've occasional troubles with CPU utilization with cmd.php poller. What can be wrong with the script above?
-tt-
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

Damned, I'm sorry for editting the post. The problem is really in using spine. I've notices a typo in Data Input Method for the custom script - and it works with cmd.php (as the "deafult" ping script does), however no script does work with spine...
-tt-
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: Poller does not run scripts

Post by noname »

>> it works with cmd.php (as the "deafult" ping script does), however no script does work with spine...

Nothing?! That's odd..
Is there any error in Cacti's log?
Or what results is shown when you performed as follows:

Code: Select all

./spine --verbosity=5
See also: Debugging - Check Cacti's Poller
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

I do not know, how to redirect stdout from spine command (using '>' or '| tee' does not work), however with DEVEL log level I can see just some error I've already posted:

Code: Select all

11/11/2011 12:03:01 PM - SPINE: Poller[0] Host[37] DS[673] SCRIPT: perl /var/www/cacti/scripts/ping2.pl 192.168.254.10, output: U
11/11/2011 12:03:01 PM - SPINE: Poller[0] Host[37] DS[673] WARNING: Result from SCRIPT not valid. Partial Result: ...
11/11/2011 12:03:01 PM - SPINE: Poller[0] Host[37] ERROR: Empty result [192.168.254.10]: 'perl /var/www/cacti/scripts/ping2.pl 192.168.254.10'
11/11/2011 12:03:01 PM - SPINE: Poller[0] Host[37] DEBUG: The POPEN returned the following File Descriptor 16 
However I've noticed there is one .sh script and it's working. Well, spine seems to have some problem with perl... :o
-tt-
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Poller does not run scripts

Post by TheWitness »

Run it as the poller user from the command line using "./spine -R -V 3". Also, we specifically ask you to use the full path to 'perl' in your data input methods. This is due to the fact that we do not pass the users environment to the scripts. This is done to increase performance and reduce load. Make sure that when you are done, that the poller cache contains the entire path to perl.

So, if you follow the rules, generally things work just fine.

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?
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

Hi, sorry for long response time.

I modified the Data Input Methods to use full perl path, but this didn't helped.
TheWitness wrote:Run it as the poller user from the command line using "./spine -R -V 3".
Please, could you guide me? I'm not "linux-aware", I'm just 'advanced user'. I do not know the 'www-data' user password so I cannot log in as that user... I can run cron job as that user, however I do not know how to redirect the output of spine command to the file (as I wrote, the ways I know - " > file.txt" and "| tee file.txt" don't work)...

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

Re: Poller does not run scripts

Post by TheWitness »

Use th "-S" flag to get output to standard output.
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?
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

I'm sorry for very log time response, I've been out of office...

See the result of 'spine -S -R -V 3 > spine.txt' command in attachement. It seems as all is ok, however the perl script don't work with spine poller...
Attachments
spine.txt
spine -S -R -V 3 > spine.txt
(52.2 KiB) Downloaded 279 times
-tt-
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Poller does not run scripts

Post by TheWitness »

They worked in this output. What is the difference?
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?
User avatar
tata_tulen
Posts: 18
Joined: Wed Jun 03, 2009 5:52 am
Location: CZE

Re: Poller does not run scripts

Post by tata_tulen »

I just realize I run the script as root, not as www-data - I've created the cron job with run as www-data and the result is different - in spine.txt there is the same errors as in cacti log with spine as poller.

Well, it's permission problem, am I right?

May be this is significant - when I run the cron job, I get this warnings:

Code: Select all

Insecure $ENV{PATH} while running setuid at /var/www/cacti/scripts/linux_memory.pl line 3.
Insecure $ENV{PATH} while running setuid at /var/www/cacti/scripts/linux_memory.pl line 3.
Insecure $ENV{PATH} while running setuid at /var/www/cacti/scripts/loadavg_multi.pl line 4.
Insecure $ENV{PATH} while running setuid at /var/www/cacti/scripts/unix_users.pl line 8.
Insecure $ENV{PATH} while running setgid at /var/www/cacti/scripts/ping.pl line 7.
Insecure $ENV{PATH} while running setgid at /var/www/cacti/scripts/ping3.pl line 7.
Insecure $ENV{PATH} while running setuid at /var/www/cacti/scripts/ping3.pl line 7.
Insecure $ENV{PATH} while running setgid at /var/www/cacti/scripts/ping2.pl line 7.
Insecure $ENV{PATH} while running setgid at /var/www/cacti/scripts/ping3.pl line 7.
Attachments
spine.txt
(54.08 KiB) Downloaded 155 times
-tt-
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests