SaveConfigs 0.8
Features:
- One click in the new host-template will save the running-config of a device and compare it
- The scripts automatic:
- start a telnet/ssh connection to the networkdevice
- check the devicemodel: Huawei, Cisco IOS/CatOS are testet at the moment.
- send the correct commands to show the running-config
(or perhaps other important information, easy to customize)
- compare the new configuration with a already saved configuration from the past - and renames the old one, if changes were made.
- A script to create a cronjob, which gets all deviceIPs (except 127.0.0.1) from the mysql database
- Misc: IP-Address as a telnet link for every host entry
I. Installation of the new "SaveConfig" link for the webinterface:
(All examples below are for Ubuntu-Server)
1. install "nmap" and "expect":
sudo apt-get install nmap expect
2a. copy files:
copy "saveconfigs.sh" and "commands.exp" to /usr/local/icinga/cgi-bin/
Change the rights for the access: the Webuser need the rights to start these scripts
Perhaps let the webserver start *.sh files (beside *.cgi)
2b. change the logincredentials in "saveconfigs.sh"
3. create folder /tftpboot with the rights for every user to access it?!
The configurationfiles will be saved here!
4. copy the new host-template-file:
copy "icinga-my-host-template.xml" to /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/
5. Create a new gridview in the "Data" Cronk-Container:
edit "cronks.xml" in subfolder /usr/local/icinga-web/app/modules/Cronks/config/ und paste following lines:
Cronks
System.ViewProc
false
Saving Configuration
SaveConfig
data
icinga-my-host-template
6. empty the cache and restart services:
sudo service icinga restart
sudo service apache2 restart
sudo rm -rf /usr/local/icinga-web/app/cache/config/*.php
II. Create the cronjob:
1. copy the file "CRONsaveconfigs.sh" and edit the user to connect to the right mysql database.
2. create a cronjob, which executes "Cronsaveconfigs.sh":
sudo vi /etc/crontab
or
crontab -e
* * * * *
- - - - -
¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ +---- day of a week (0-7) (sunday =0 oder =7)
¦ ¦ ¦ +------ month (1-12)
¦ ¦ +-------- day of a month (1-31)
¦ +---------- hour (0-23)
+------------ minute (0-59)
//// examples
// every day at 0:00:
0 0 * * * ./CRONsaveconfigs.sh >/dev/null 2>&1
// every sunday at 23:59:
59 23 * * 0 ./CRONsaveconfigs.sh >/dev/null 2>&1
// at the first of every month, at 1:00:
0 1 1 * * ./CRONsaveconfigs.sh >/dev/null 2>&1
TODO:
- simplify the code
- Insert more devices in "commands.exp" (Enterasys, Nortel, Extreme, ...) and test them
- Get the complete running-config in "saveconfigs.sh" - better solution?!