Running Cactid as root causes problem with perl scripts

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

Moderators: Developers, Moderators

Post Reply
LingaringBell
Posts: 6
Joined: Tue Apr 06, 2010 1:59 pm

Running Cactid as root causes problem with perl scripts

Post by LingaringBell »

In order to use ICMP ping I did:

chmod +s /usr/local/spine/bin/spine

ICMP ping works great now, but I'm getting the following errors in the system log:
  • 04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[25] ERROR: Empty result [192.168.2.200]: 'perl /usr/share/cacti/scripts/linux_memory.pl MemFree:'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[25] ERROR: Empty result [192.168.2.200]: 'perl /usr/share/cacti/scripts/linux_memory.pl SwapFree:'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[25] ERROR: Empty result [192.168.2.200]: 'perl /usr/share/cacti/scripts/loadavg_multi.pl'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[25] ERROR: Empty result [192.168.2.200]: 'perl /usr/share/cacti/scripts/unix_users.pl '
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[25] ERROR: Empty result [192.168.2.200]: 'perl /usr/share/cacti/scripts/unix_processes.pl'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[25] ERROR: Empty result [192.168.2.200]: 'perl /usr/share/cacti/scripts/query_unix_partitions.pl get used /dev/sda1'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[25] ERROR: Empty result [192.168.2.200]: 'perl /usr/share/cacti/scripts/query_unix_partitions.pl get available /dev/sda1'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: 'perl /usr/share/cacti/scripts/query_unix_partitions.pl get used /dev/sda1'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: 'perl /usr/share/cacti/scripts/query_unix_partitions.pl get available /dev/sda1'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: 'perl /usr/share/cacti/scripts/unix_processes.pl'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: 'perl /usr/share/cacti/scripts/unix_users.pl '
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: 'perl /usr/share/cacti/scripts/loadavg_multi.pl'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: 'perl /usr/share/cacti/scripts/linux_memory.pl SwapFree:'
    04/06/2010 03:25:05 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: 'perl /usr/share/cacti/scripts/linux_memory.pl MemFree:'

These two hosts are the only devices I currently monitor with these perl scripts. If I set cactid back to run without root privileges the problem goes away and these graphs start getting data as normal. I've searched the forums up and down but the only thing I could find hint of that might be the problem is that cactid needs the full path to perl input somewhere, but I couldn't figure out where to do this. Besides, why would cactid poll fine as a non root if that was the issue? Any help is appreciated.
-Bell
LingaringBell
Posts: 6
Joined: Tue Apr 06, 2010 1:59 pm

Post by LingaringBell »

oops and I foolishly forgot the most important info:

Cacti Version 0.8.7e
Cacti OS Ubuntu 8.04
SNMP Version NET-SNMP version: 5.4.1
RRDTool Version RRDTool 1.3.x
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

Do you also have installed the perl-suidperl package ?

if not that may be the problem ...
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

Could also be a path thing. The command line for the script query is supposed to have the full path to perl, I'm pretty sure.

root often has a restricted $PATH.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
LingaringBell
Posts: 6
Joined: Tue Apr 06, 2010 1:59 pm

Post by LingaringBell »

phalek, I was sure that your idea was going to fix it, but I used apt to install perl-suid and the problem still persists.

A new piece of information, I went into Data Input Methods and changed the Input string for Unix - Get Load Average to be: /usr/bin/perl <path_cacti>/scripts/loadavg_multi.pl

Doing this caused this error to appear in the system log:
  • 04/07/2010 01:41:42 PM - CMDPHP: Poller[0] ERROR: SQL Cell Failed!, Error:'1064', SQL:"select xml_path from snmp_query where id="
Then when the poller tries to run I get basically the same error as before, but with the full path:
  • 04/07/2010 01:35:07 PM - SPINE: Poller[0] Host[23] ERROR: Empty result [127.0.0.1]: '/usr/bin/perl /usr/share/cacti/scripts/loadavg_multi.pl'
I haven't been able to find any information on the new error.
LingaringBell
Posts: 6
Joined: Tue Apr 06, 2010 1:59 pm

Post by LingaringBell »

I just tried running cactid manually from the command line with debug logging on and everything worked fine.... I don't get it. If it was a PATH or permissions problem then I would get the same error from the command line.


Here is the output to the log:
  • 04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: MYSQL Free & Close Completed
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: Allocated Variable Memory Freed
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: PHP Script Server Pipes Closed
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: Thread Cleanup Complete
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The Value of Active Threads is 0
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: HOST COMPLETE: About to Exit Host Polling Thread Function
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DS[299] SCRIPT: perl /usr/share/cacti/scripts/query_unix_partitions.pl get used /dev/sda1, output: 1726344
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DS[299] SCRIPT: perl /usr/share/cacti/scripts/query_unix_partitions.pl get available /dev/sda1, output: 17162264
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DS[298] SCRIPT: perl /usr/share/cacti/scripts/unix_processes.pl, output: 77
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DS[297] SCRIPT: perl /usr/share/cacti/scripts/unix_users.pl , output: 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DS[296] SCRIPT: perl /usr/share/cacti/scripts/loadavg_multi.pl, output: 1min:0.02 5min:0.02 10min:0.00
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DS[295] SCRIPT: perl /usr/share/cacti/scripts/linux_memory.pl SwapFree:, output: 915664
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DS[294] SCRIPT: perl /usr/share/cacti/scripts/linux_memory.pl MemFree:, output: 783420
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: The NIFTY POPEN returned the following File Descriptor 6
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] NOTE: There are '7' Polling Items for this Host
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] RECACHE: Processing 1 items in the auto reindex cache for '127.0.0.1'
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] SNMP Result: Host responded to SNMP
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] PING Result: ICMP: Host is Alive
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[23] DEBUG: ICMP Host Alive, Try Count:1, Time:0.1010 ms
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The Value of Active Threads is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: Valid Thread to be Created
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: In Poller, About to Start Polling of Host
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The Value of Active Threads is 0
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Host[0] DEBUG: HOST COMPLETE: About to Exit Host Polling Thread Function
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The Value of Active Threads is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: Valid Thread to be Created
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: In Poller, About to Start Polling of Host
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: Initial Value of Active Threads is 0
    04/07/2010 03:21:26 PM - SPINE: Poller[0] SPINE: Initializing PHP Script Server(s)
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: SNMP Library Version is 5.4.1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: SNMP Header Version is 5.4.1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] SPINE: Initializing Net-SNMP API
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: MySQL is Thread Safe!
    04/07/2010 03:21:26 PM - SPINE: Poller[0] Version 0.8.7e starting
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The Maximum SNMP OID Get Size is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The PHP Script Server is Not Required
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: StartHost='23', EndHost='23', TotalPHPScripts='0'
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The number of php script servers to run is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The script timeout is 25
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The number of concurrent processes is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The polling interval is 300 seconds
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The threads variable is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The log_pstats variable is 0
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The boost_redirect variable is 0
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The log_pwarn variable is 0
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The log_perror variable is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The snmp_retries variable is 3
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The ping_timeout variable is 400
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The ping_retries variable is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The ping_method variable is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The ping_failure_count variable is 3
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The ping_recovery_count variable is 3
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The availability_method variable is 1
    04/07/2010 03:21:26 PM - SPINE: Poller[0] DEBUG: The path_php variable is /usr/bin/php
LingaringBell
Posts: 6
Joined: Tue Apr 06, 2010 1:59 pm

Post by LingaringBell »

I found a solution, but I'm not sure how happy I am with it. If I run poller.php with the root user instead of the www-data user everything works fine. It must be a permissions issue somewhere, but heck if I can find it.
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

www-data user ??? I thought the poller should be run as the cacti user ....

Code: Select all

[root@redmine ~]# cat /etc/cron.d/cacti
*/5 * * * * cacti php /var/www/html/cacti/poller.php > /dev/null 2>&1
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
LingaringBell
Posts: 6
Joined: Tue Apr 06, 2010 1:59 pm

Post by LingaringBell »

I'm pretty sure that the user you use doesn't matter as long as that user has write permissions to the rra and log directories. I never even made a linux cacti user, only a mysql cacti user. Maybe I am mistaken?
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests