Search My Techie Guy

Saturday, October 7, 2017

RRDTool Says: ERROR: Opening x.rrd No such file or directory - Creating Cacti Graphs

Summary:

I faced this issue on a new cacti installation recently, at this point i had successfully finished adding the device to be monitored by cacti.
Cacti was also able to successfully query the snmp interface statistics for the test device i added. The challenge came when i added my first graph.  
I was getting the error below:


 "RRDTool Says: ERROR: opening '/var/www/html/rra/t_traffic_in_6.rrd': No such file or directory"

Problem or Goal:


Cause:

I couldn't straight away tell the cause, but what was obvious is that the ".rrd" files were not being created whenever a graph was created!
Another symptom worth mentioning is that my test device status was showing "unknown" instead if "up", yet the snmp/ping query was successful!

Solution:

I tried a few things so am a bit confused myself on what exactly did the trick!!
but here is a list of checks to guide you in case you find yourself in a similar situation.

1. Check the HTTPD error log ("error_log") for any hints relating to this error

This is usually found under "/var/log/httpd/"


 # tail /var/log/httpd/error_log

2. Check the cacti log ("cacti.log") for any hints relating to this error
3. Make sure the directory "rra" is owned by user "cacti" and has "rwx" privileges


# cd /var/lib/cacti/
# ls -ltr
total 16
drwxr-xr-x. 6 apache apache 4096 Sep 22 22:34 cache
lrwxrwxrwx. 1 root   root     24 Sep 22 22:34 include -> /usr/share/cacti/include
lrwxrwxrwx. 1 root   root     20 Sep 22 22:34 lib -> /usr/share/cacti/lib
drwxr-xr-x. 2 apache apache 4096 Sep 22 22:34 scripts
drwxr-xr-x. 2 root   root   4096 Sep 22 22:50 cli
drwxr-xr-x. 2 cacti  root   4096 Sep 26 18:33 rra
  
4. Check the cacti crone tab and try to run the "poller.php" script as user "cacti" and again as user "root", which ever runs smoothly without giving you errors should be the one to use in running the "poller.php" crone job.
For my case, whenever i would attempted to run the "poller.php" script as user "cacti", i would get the following mysql error:


# /usr/bin/php /usr/share/cacti/poller.php

"FATAL: Connection to Cacti database failed. Please ensure the database is running and your credentials in config.php are valid."

But as user "root", my "poller.php" script would run ok.
So i edited my cacti crone tab to look like this:


# cd /etc/cron.d
# vi cacti 
*/5 * * * * root /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Problem Solved?

Yes, the ".rrd" files were created after running the poller.php script successfully.
For the new graphs, i get the same RRD ERROR on the GUI!, but when the poller.php runs (which happens every 5 mins according to the crone tab), the ".rrd" files are created for the new graphs and the graphs start plotting statistics successfully.

Immediately after creating the graph i see the same error:



After waiting the 5 mins interval, the poller.php runs and the ".rrd" files are created for that graph, i get normal graphs.



The difference is that before i edited the cacti crone tab to be ran by user "root", even waiting for the 5 mins interval was not clearing the error.

I know this is not the perfect way, but if you manage to figure out why the ".rrd" are not created at the instant you click "create" in the cacti GUI, you can leave for me a comment and i will be happy to fine tune my system.

No comments: