Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu Jun 27, 2019 6:00 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Archive Script For Graphs
PostPosted: Fri Nov 05, 2004 10:50 am 
Offline

Joined: Fri Nov 05, 2004 10:12 am
Posts: 1
Location: MA
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:
PERL=/usr/bin/perl
@daily          $PERL   $HOME/bin/archive.pl daily
@weekly         $PERL   $HOME/bin/archive.pl weekly
@monthly        $PERL   $HOME/bin/archive.pl monthly
@yearly         $PERL   $HOME/bin/archive.pl 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:
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.


Attachments:
archive.pl.txt [2.57 KiB]
Downloaded 1510 times
Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 07, 2005 3:58 pm 
Offline
Cacti User

Joined: Thu Aug 04, 2005 8:34 am
Posts: 68
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*


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group