Raspberry PI – Cacti troubleshooting

  1. Check out System Utilities, View Cacti Log files
  2. Check rrd file exists /var/lib/cacti/rra/
  3. Check content of the rrd file /usr/bin/rrdtool info /var/lib/cacti/rra/localhost_time_26.rrd
  4. Check that your perl script is working correctly
  5. Check which user is running crontab root@raspberrypi:/var/lib/cacti# more /etc/cron.d/cacti MAILTO=root */5 * * * * www-data php –define suhosin.memory_limit=512M /usr/share/cacti/site/poller.php 2>&1 >/dev/null | if [ -f /usr/bin/ts ] ; then ts ; else tee ; fi >
  6. Changing crontab user www-data to root resolved my issue
  7. Check /var/log/cacti/poller-error.log
  8. Check that output is correctly shown in the cacti.log
Log File [Total Lines: 70 – All Items Shown]
12/31/2018 01:32:06 AM – SYSTEM STATS: Time:4.8849 Method:cmd.php Processes:2 Threads:N/A Hosts:2 HostsPerProcess:1 DataSources:16 RRDsProcessed:11
12/31/2018 01:32:06 AM – CMDPHP: Poller[0] Time: 1.9014 s, Theads: N/A, Hosts: 1
12/31/2018 01:32:06 AM – CMDPHP: Poller[0] Host[1] DS[25] CMD: perl /usr/share/cacti/site/scripts/cpu_temp.pl, output: 52
12/31/2018 01:32:06 AM – CMDPHP: Poller[0] Host[1] DS[22] CMD: perl /usr/share/cacti/site/scripts/query_unix_partitions.pl get used /dev/mmcblk0p1, output: 22541
12/31/2018 01:32:06 AM – CMDPHP: Poller[0] Host[1] DS[22] CMD: perl /usr/share/cacti/site/scripts/query_unix_partitions.pl get available /dev/mmcblk0p1, output: 21679
12/31/2018 01:32:06 AM – CMDPHP: Poller[0] Host[1] DS[21] CMD: perl /usr/share/cacti/site/scripts/query_unix_partitions.pl get used /dev/root, output: 5292472
12/31/2018 01:32:06 AM – CMDPHP: Poller[0] Host[1] DS[21] CMD: perl /usr/share/cacti/site/scripts/query_unix_partitions.pl get available /dev/root, output: 8914312

There are two main „process“ with cacti. 

1/ Running the website. 
This is frequently done with the user „www-data“ or „apache“ running the Apache daemon 

2/ Running the poller with a task in the crontab. 
The poller updates the rrd files in rra/ 

when you install cacti with an apt-get (which splits dirs in 4 places, i’m not mentionning /etc/cacti here) notice: 
– /var/log/cacti/ contains log files owned by www-data:www-data, the dir is given: drwxr-xr-x rights 
– /usr/share/cacti/ contains the website files owned by root:root, the dir is given: drwxr-xr-x rights 
– /var/lib/cacti/rra/ contains rrd files owned by root:www-data, the dir is given: drwxrwx rights 
– /etc/cron.d/cacti (the cron script), uses www-data user to run the poller which perfectly makes sense then. 

If you install cacti „manually“ (using apt-get, aptitude, yum, yast or whatever for the LAMP but building cacti form sources), the apache user will be www-data or apache, the webserver rootdir will probably be /var/www/ and the correct user rights will be given to the apache user on that dir. 

Then you can run the poller with either www-data or cactiuser but you’ll have to allow this user to Read/Write in rra/. 

In short : 
– rra/ has to be writable for the user running cron, and readable by the user running apache 
– logs/ has to be writable for both users (cacti does some logging too), because both users have to write in that dir, you have to make sure the user running cacti and the user running apache are in the same group. using www-data for the polling is probably the most convenient way to do that. 

Hope this helps. 

My configuration:



root@raspberrypi:/etc# ls -ltr /usr/share/cacti/site/scripts/cpu_temp.pl
-rwxr-xr-x 1 pi pi 170 Jan 3 22:19 /usr/share/cacti/site/scripts/cpu_temp.pl
root@raspberrypi:/etc# more /usr/share/cacti/site/scripts/cpu_temp.pl
!/usr/bin/perl
open(PROCESS, „/usr/bin/vcgencmd measure_temp | /usr/bin/cut -c 6-7|“);
$output = ;
close(PROCESS);
chomp($output);
print „temp:“;print $output;
root@raspberrypi:/etc# /usr/share/cacti/site/scripts/cpu_temp.pl
temp:51

Sources:

https://docs.cacti.net/manual:087:3a_advanced_topics.1_data_input_methods#data_input_fields
https://forums.cacti.net/viewtopic.php?t=15136
https://forums.cacti.net/viewtopic.php?t=15136
https://forums.cacti.net/viewtopic.php?f=2&t=55543
https://www.linuxjournal.com/content/graph-any-data-cacti
https://docs.cacti.net/manual:087:3a_advanced_topics.1_data_input_methods
https://docs.cacti.net/manual:087:4_help.2_debugging#debugging
https://forums.cacti.net/about38653.html
https://www.raspberrypi.org/forums/viewtopic.php?t=126118
Jan D.
Jan D.

"The only real security that a man will have in this world is a reserve of knowledge, experience, and ability."

Articles: 673

Leave a Reply

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *