Here's a quick and dirty perl script that backs up your cisco ios router and switch configs via tftp when ever someone makes a config change. You need to have activestate perl install and Net::Telnet::Cisco and Timestamp::Simple perl mods.
- You need to make sure your devices are sending syslog message to orion.
- Create an alert/filter rule in syslog view that looks for messages containing *CONFIG*
- Add an alert action that executes an external app. ie "C:\Perl\bin\perl.exe"
\scripts\save_router_config.pl ${Hostname} - Copy perl script below. Make necessary changes. Our routers require usernames and passwords to login. If you routers only require password, the username variable is ignored.
#!/usr/bin/perluse Net::Telnet::Cisco;use Timestamp::Simple qw(stamp);my $device = "$ARGV[0]"; my $user = "username";my $pass = "password";my $enable_pass = "enable_password";my $backup_host = 'tftp_server';my $numArgs = $#ARGV + 1;my $dt = stamp;if ($numArgs != 1 ){ print "usage: save_router_config.pl device name\n"; exit;}my $session = Net::Telnet::Cisco->new(Host => $device );$session->login($user, $pass);my @output = "";if ($session->enable($enable_pass) ){ @output = $session->cmd('show privilege'); print "My privileges: @output";}else{ warn "Can't enable: " . $session->errmsg;}$session->cmd("copy run tftp://$backup_host/configs/$device/$dt-$device.cfg\n\n\n");$session->close;