Observium Professional edition – rancid integration

Updates: 11/12/2014 – Latest revision of Observium Pro’s code for show rancid config has been rewritten without php-svn extension. If you have php-svn installed, it’s best to uninstall it – apt-get remove php5-svn ; service apache2 restart

Update: 12/1/2014 – Updated svn to subversion due to Mike Hammett’s feed back.

Update: 12/8/2014 – Updated cron find command.

 

So documentation on this one is a little weak.

Fortunately, this guy has blazed a trail for us.

Login and get ready!

apt-get install rancid subversion

We need to add a group for rancid to store configs in.

pico /etc/rancid/rancid.conf

Add this line:

LIST_OF_GROUPS="observium"

Changes these two lines

CVSROOT=$BASEDIR/CVS; export CVSROOT
RCSSYS=cvs; export RCSSYS

to

CVSROOT=$BASEDIR/SVN; export CVSROOT
RCSSYS=svn; export RCSSYS

We need to create the folder structure.

su - rancid
/var/lib/rancid/bin/rancid-cvs

We need to create a .cloginrc file.

pico /var/lib/rancid/.cloginrc

I’m backing up mostly Mikrotik devices so my config is a little different.

add user * rancid
add password * password
add identity * /var/lib/rancid/.ssh/id_dsa
add method * ssh
add noenable * {1}

Make sure you have your public key credentials in /var/lib/rancid/.ssh/

Test it out

/var/lib/rancid/bin/mtlogin router

Add www-data to rancid group

usermod -a -G rancid www-data

Update the Observium config

pico /opt/observium/config.php

Add these lines:

$config['rancid_configs'][]              = "/var/lib/rancid/observium/configs/";
$config['rancid_ignorecomments']        = 0;

Restart apache

/etc/init.d/apache2 restart

Check it out in Observium.

You should see a config tab with your configs there.

Screenshot 2014-10-23 14.54.08

Observium has a script which can generate the router.db config based on what’s in Observium.

rancid@observium:/opt/observium/scripts$ php generate-rancid.php 
# do not edit file directly!
#RANCID router.db autogenerated by 
router:mikrotik:up

Dump it in the config file with

php /opt/observium/scripts/generate-rancid.php > /var/lib/rancid/observium/router.db

We can add this in cron to do this automatically.

If you want rancid to back up daily, then add something like this to cron.

0 5 * * * /var/lib/rancid/bin/rancid-run
#hourly router dump
50 23 * * * /usr/bin/find /var/lib/rancid/logs -type f -mtime   +2 -exec rm {} \;

Leave a Reply

Your email address will not be published. Required fields are marked *

*