Hi all,
Was wondering if you could help me out. I'm trying to run a bash script that will pull running configs from hosts to a TFTP server. I have the following script and it works well. The only issue is that where it says hostIP=$1 and hostName=$2 it only works if i manually enter the IP and hostname. Is there anyway I can run this script without having to manually enter the hostname and IP? I have like 3000 devices and would like this to actively pull as configs change.
Within Zabbix, under Confguration of Actions, I have the command running on the Zabbix server to run the bash script with {HOST.IP} {HOST.HOST} and was hoping this would pull the ip and hostname automatically from zabbix but doesn't seem to be the case. In Conditions, I have it such that whenever someone wr a configuration, it'll trigger an alarm and should run the script. Can anyone help me out?
#!/bin/bash
#accept host IP and TFTP-server from Zabbix
hostIP=$1
hostName=$2
tftp="x.x.x.x" (where this is an ip)
####iOS strings####
#execute copy run start
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.3.111 i 4 #This specifies type of file to copy from (running config)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.4.111 i 3 #This specifies type of file to copy to (startup config)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.14.111 i 1 #This checks for active status of table entry
#execute copy run tftp $tftp on host and transfer config to TFTP server
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.2.112 i 1 #This uses tftp to push config
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.3.112 i 4 #This specifies type of file to copy from (running config)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.4.112 i 1 #This specifies type of file to copy to (network file)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.5.112 a $tftp
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.6.112 s $hostName #-config
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.14.112 i 1
####CatOS strings####
#execute copy run tftp $tftp on host and transfer config to TFTP server
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.1.0 s $tftp
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.2.0 s $hostName #-config
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.3.0 i 1
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.4.0 i 3
#END
echo "Script completed successfully, please visit TFTP server to find backup"
Was wondering if you could help me out. I'm trying to run a bash script that will pull running configs from hosts to a TFTP server. I have the following script and it works well. The only issue is that where it says hostIP=$1 and hostName=$2 it only works if i manually enter the IP and hostname. Is there anyway I can run this script without having to manually enter the hostname and IP? I have like 3000 devices and would like this to actively pull as configs change.
Within Zabbix, under Confguration of Actions, I have the command running on the Zabbix server to run the bash script with {HOST.IP} {HOST.HOST} and was hoping this would pull the ip and hostname automatically from zabbix but doesn't seem to be the case. In Conditions, I have it such that whenever someone wr a configuration, it'll trigger an alarm and should run the script. Can anyone help me out?
#!/bin/bash
#accept host IP and TFTP-server from Zabbix
hostIP=$1
hostName=$2
tftp="x.x.x.x" (where this is an ip)
####iOS strings####
#execute copy run start
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.3.111 i 4 #This specifies type of file to copy from (running config)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.4.111 i 3 #This specifies type of file to copy to (startup config)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.14.111 i 1 #This checks for active status of table entry
#execute copy run tftp $tftp on host and transfer config to TFTP server
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.2.112 i 1 #This uses tftp to push config
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.3.112 i 4 #This specifies type of file to copy from (running config)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.4.112 i 1 #This specifies type of file to copy to (network file)
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.5.112 a $tftp
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.6.112 s $hostName #-config
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.9.96.1.1.1.1.14.112 i 1
####CatOS strings####
#execute copy run tftp $tftp on host and transfer config to TFTP server
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.1.0 s $tftp
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.2.0 s $hostName #-config
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.3.0 i 1
snmpset -c -v 1 $hostIP 1.3.6.1.4.1.9.5.1.5.4.0 i 3
#END
echo "Script completed successfully, please visit TFTP server to find backup"