SaveConfigs 0.85 For a german version, please scroll down. 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, Enterasys 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" (like: Nortel, Extreme, ...) and test them ________________________________________________________________________________________________ GERMAN: Features: - Per Knopfdruck im neuen Host-Template wird die Konfiguration gesichert und verglichen: - automatischer Aufbau einer Telnet/SSH Verbindung zu Netzkomponenten - automatische Erkennung des Modells: Huawei, Cisco IOS/CatOS, Enterasys getestet. - Absetzung der korrekten Befehle zur Anzeige der Running-Config (oder beliebig anderer Informationen, die erwuenscht sind) - Vergleich der neuen Konfiguration mit bereits gesicherter Konfiguration - und Archivierung der alten Config - Das Ganze auch als Cronjob fuer alle (bis auf 127.0.0.1) hinterlegten Hosts aus der Datenbank durchfuehrbar. - Misc: IP-Adresse als Telnetlink zur Netzkomponente verfuegbar I. Installation fuer die Weboberflaeche: (Alle folgenden Befehlsbeispiele sind auf Ubuntu zugeschnitten) 1. Pakete "nmap" und "expect" nachinstallieren: sudo apt-get install nmap expect 2a. Dateien kopieren: "saveconfigs.sh" und "commands.exp" nach /usr/local/icinga/cgi-bin/ kopieren Rechte anpassen, damit der Webuser diese Dateien ausfuehren darf. Ggf. Ausfuehrung von *.sh Dateien in der entsprechenden Webserver-Konfigurationsdatei erlauben. 2b. Logincredentials in "saveconfigs.sh" anpassen 3. Ordner /tftpboot erstellen und fuer alle Benutzer freigeben?! Hier werden die Konfigurationen spaeter gesichert und auch archiviert. 4. Erstellen einer neuen Grid Ansicht: "icinga-my-host-template.xml" kopieren nach /usr/local/icinga-web/app/modules/Cronks/data/xml/grid/ 5. Anlegen einer neuen Grid-Ansicht im "Data" Cronk-Container: Editieren von cronks.xml im Unterverzeichnis /usr/local/icinga-web/app/modules/Cronks/config/ und hinzufuegen von: Cronks System.ViewProc false Saving Configuration SaveConfig data icinga-my-host-template 6. Cache leeren und Services neustarten (folgendes Beispiel unter Ubuntu): sudo service icinga restart sudo service apache2 restart sudo rm -rf /usr/local/icinga-web/app/cache/config/*.php II. Installation des Cronjobs: 1. Zugriff auf die Datenbank in "CRONsaveconfigs.sh" anpassen 2. Cronjob einrichten, welcher die "Cronsaveconfigs.sh" Datei ausfuehrt: sudo vi /etc/crontab oder crontab -e * * * * * - - - - - ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ +---- Wochentag (0-7) (Sonntag =0 oder =7) ¦ ¦ ¦ +------ Monat (1-12) ¦ ¦ +-------- Tag (1-31) ¦ +---------- Stunde (0-23) +------------ Minute (0-59) //// Beispiele // Taeglich 0 Uhr: 0 0 * * * ./CRONsaveconfigs.sh >/dev/null 2>&1 // Sonntags um 23:59 Uhr: 59 23 * * 0 ./CRONsaveconfigs.sh >/dev/null 2>&1 // Am 1. jeden Monats um 1:00 Uhr: 0 1 1 * * ./CRONsaveconfigs.sh >/dev/null 2>&1 TODO: - Code vereinfachen - Weitere Netzkomponenten in "commands.exp" hinzufuegen (Nortel, Extreme, ...) und testen - In "saveconfigs.sh" den eigentlichen Konfigurationsausschnitt besser erkennen