Integrate Rancid on Librenms
Rancid
Librenms can generate a list of hosts that can be monitored by RANCID. We assume you have currently a running Rancid, and you just need to create and update the file 'router.db'
https://docs.librenms.org/Extensions/Rancid/
https://shrubbery.net/rancid/
Ubuntu Rancid Install
The options shown below also contains the default values.
sudo apt-get install rancid subversion
Edit Rancid config file to use subversion or git instead of default cvs, and adds a group:
sudo nano /etc/rancid/rancid.conf
LIST_OF_GROUPS="librenms core"
Now change these two lines:
CVSROOT=$BASEDIR/CVS; export CVSROOT
RCSSYS=cvs; export RCSSYS
to:
CVSROOT=$BASEDIR/SVN; export CVSROOT
RCSSYS=svn; export RCSSYS
NOTE - This only creates 1 group! You can of course make more when you get the hang of it, this is just a basic 'Need it to work" deal.
Run this command to create the folder structure:
sudo passwd rancid
su - rancid
/var/lib/rancid/bin/rancid-cvs
NOTE - do NOT change cvs to svn here! Leave command as is!
Get a list of devices from Librenms you can pull configs from:
cd /opt/librenms/scripts
sudo ./gen_rancid.php
Copy the output. Replace all ":" with ";" example:
alphcr1:cisco:up will change to:
alphcr1;cisco;up
copy and past results into the below file:
sudo nano /var/lib/rancid/librenms/router.db
AND
sudo nano /var/lib/rancid/core/router.db
NOTE - This ONLY applies to newer RANCID versions and Linux distros. Older versions will need to retain the : and not the ;
Create/edit rancids login file:
sudo nano /var/lib/rancid/.cloginrc
Add following at minimum:
add user * <your username here>
add password * <your password here>
add method * ssh
add noenable * {1} ******This disables the enable when using radius etc *******
# You can enter some sensible text here to define the device below
add user {192.168.88.1} {rancid}
add password {192.168.88.1} {sshpassword} {enablepassword}
add method {192.168.88.1} {ssh:2223}
#add autoenable {192.168.88.1} 1
# You can enter some sensible text here to define the device below
add user {192.168.88.2} {rancid}
add password {192.168.88.2} {telnetpassword} {enablepassword}
add method {192.168.88.2} {telnet}
#add autoenable {192.168.88.2} 1
Grant permissions for rancid:
sudo chown rancid /var/lib/rancid/.cloginrc
sudo chmod 600 /var/lib/rancid/.cloginrc
Test config: sudo /usr/lib/rancid/bin/clogin -f /var/lib/rancid/.cloginrc <device hostname>
NOTE: IF you run into a 'diffie-hellmen' kind of error, then it is because your Linux distro is using newer encryption methods etc. This is basically just letting you know that the device you tested on is running an outdated encryption type. I recommend updating downstream device if able. If not, the following should fix:
sudo vi /etc/ssh/ssh_config
Add:
KexAlgorithms diffie-hellman-group1-sha1
Re-try logging into your device again
Upon success, run rancid:
sudo su -c /var/lib/rancid/bin/rancid-run -s /bin/bash -l rancid
Ensure your configs pulled:
sudo su - rancid
cd librenms/configs/
ls
Make sure your config files are there :-)
sudo usermod -a -G rancid www-data ***** run as root user
sudo usermod -a -G rancid librenms
Add Rancid into LibreNMS config.php:
### Rancid
$config['rancid_configs'][] = '/var/lib/rancid/librenms/configs/';
$config['rancid_repo_type'] = 'svn'; //'svn' or 'git'
$config['rancid_ignorecomments'] = 0;
If you're running RANCID v3.x, add the following line :
$config['rancid_version'] = '3';
Now restart apache
sudo /etc/init.d/apache2 restart
Included Rancid script
To generate the config file (maybe even add a cron to schedule this). We've assumed a few locations for Rancid, the config file you want to call it and where LibreNMS is:
cd /opt/librenms/scripts/
php ./gen_rancid.php > /
var/lib
/rancid/core/router.db
cron:
150
* * * root
cd/opt/librenms/scripts
&&php ./gen_rancid.php > /
var/lib
/rancid/core/router.db
Now configure LibreNMS (make sure you point dir to your rancid data directory):
$config['rancid_configs']['core']=
'/the/path/where/is/rancid/core';
After that, you should see some "config" tab on routers that have a rancid update.
Finally
sudo /etc/init.d/apache2 restart
http://packetsandpings.blogspot.com/2013/05/installing-and-configuring-rancid.html
https://docs.librenms.org/Extensions/Rancid/
https://shrubbery.net/tools.html
hi,
ReplyDeletei have problem in tab config, "missing previous config"
only latest one is show