generated from pavel.muhortov/template-python
.gitignore | ||
cisco-port-failover.py | ||
LICENSE | ||
README.md |
cisco-management
Wireguard management and monitoring utils.
cisco-port-failover
.py
Description:
Cisco ports switching if the target is unreachable.
Dependencies:
- privileged rights
- Python 3 (tested version 3.9.5 on Debian GNU/Linux 11)
- paramiko Python 3 module (tested version 3.1.0)
PARAMETERS | DESCRIPTION | DEFAULT |
---|---|---|
[--host] | cisco host address | REQUIRED |
[--port] | cisco ssh port | 22 |
[--user] | cisco ssh username | cisco |
[--pass] | cisco ssh password | cisco |
[--p_en] | cisco enable mode password | the same ssh password |
[--check] | ping target host | None |
[--iface] | cisco target interface | None |
[--wait] | delay in seconds between commands | 0.05 |
[--log_root] | path to log directory | the same script path |
[--log_level] | DEBUG, INFO, WARNING, ERROR, CRITICAL | INFO |
Example usage with cron:
# install dependencies
sudo pip install paramiko
# download
sudo wget https://git.hmp.today/pavel.muhortov/cisco-management/raw/branch/master/cisco-port-failover.py -O /usr/local/bin/cisco-port-failover.py
sudo chmod +x /usr/local/bin/cisco-port-failover.py
# sudo crontab -e
*/2 * * * * /usr/bin/python3 /usr/local/bin/cisco-port-failover.py --host 10.0.0.1 --user USER --pass PASS --check 10.0.1.1 --check 10.0.1.2 --check 10.0.1.3 --iface Gi1/0/1 --iface Gi1/0/2 --log_root /var/log
# watching
tail -f /var/log/cisco-port-failover.log