Archive Script For Graphs

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Post Reply
Posts: 1
Joined: Fri Nov 05, 2004 10:12 am
Location: MA

Archive Script For Graphs

#1 Post by pdonahue » Fri Nov 05, 2004 10:50 am

Attached is a very simple script that archives the graphs generated by cacti and rrdtool. The script queries the database for all configured devices, hits the webserver for the associated images, then saves them to disk in a hierarchical directory structure. These graphs can later be viewed with any web browser.

The script is called from crontab every night. All 4 time periods (daily, weekly, monthly, annually) are archived depending on how the script is called. Below is a sample crontab entry. You may to have to change the time definition if your crontab doesn't support the @period extensions.

Code: Select all

@daily          $PERL   $HOME/bin/ daily
@weekly         $PERL   $HOME/bin/ weekly
@monthly        $PERL   $HOME/bin/ monthly
@yearly         $PERL   $HOME/bin/ yearly
To run the script just place it in the bin directory of your cacti homedir and update the constants in the beginning of the script to reflect your database, cacti, and httpd configurations. I recommend using the cacti guest account to hit the webserver, especially if the webserver is not on the same machine you will be running the script from as no encryption is used. Also, you should use a read only account whenever possible.

Code: Select all

use constant {
# database
    DATABASE    => 'cacti',
    DBUSER      => 'cacti',
    DBPASS      => 'cactipass',
# cacti
    GUESTUSER   => 'guest',
    GUESTPASS   => 'guestpass',
# web
    ARCHROOT    => '/usr/local/apache/htdocs/cacti/archives',

You will have to setup your httpd to allow browsing of the cacti/archives directory. See the docs specific for your server. Please let me know if you have any comments/questions. I will try to answer them on here when I get a chance.
(2.57 KiB) Downloaded 1523 times

Cacti User
Posts: 68
Joined: Thu Aug 04, 2005 8:34 am

#2 Post by disorganizer » Sun Aug 07, 2005 3:58 pm

maybe archiving the whole rrd's would be the better thing. maybe even cleaning up unused rrd's on the way would also be fine.

we would then only need to enable the usage of archived rrd's in cacti (see routers.cgi on how this could be achieved).

maybe this should be a nice feature request for cacti *g*

Post Reply