2023-11-23 12:04:03 +03:00
|
|
|
# cisco-management
|
2023-11-13 19:02:45 +03:00
|
|
|
|
2023-11-23 12:04:03 +03:00
|
|
|
Wireguard management and monitoring utils.
|
2023-11-13 19:02:45 +03:00
|
|
|
|
2023-11-23 12:04:03 +03:00
|
|
|
* [`cisco-port-failover`.py](https://git.hmp.today/pavel.muhortov/cisco-management#cisco-port-failover-py)
|
2023-11-13 19:02:45 +03:00
|
|
|
|
|
|
|
____
|
|
|
|
|
2023-11-23 12:04:03 +03:00
|
|
|
## `cisco-port-failover`.py
|
2023-11-13 19:02:45 +03:00
|
|
|
|
|
|
|
**Description:**
|
2023-11-23 12:04:03 +03:00
|
|
|
> Cisco ports switching if the target is unreachable.
|
2023-11-13 19:02:45 +03:00
|
|
|
|
|
|
|
**Dependencies:**
|
|
|
|
>
|
2023-11-23 12:04:03 +03:00
|
|
|
> * privileged rights
|
|
|
|
> * [Python 3](https://www.python.org/downloads/) (tested version 3.9.5 on [Debian GNU/Linux 11](http://ftp.debian.org/debian/dists/bullseye/))
|
|
|
|
> * [paramiko](https://www.paramiko.org/) 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:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# 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
|
2023-11-13 19:02:45 +03:00
|
|
|
```
|
|
|
|
|
2023-11-23 12:04:03 +03:00
|
|
|
```bash
|
|
|
|
# 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
|
2023-11-13 19:02:45 +03:00
|
|
|
```
|
|
|
|
|
2023-11-23 12:04:03 +03:00
|
|
|
```bash
|
|
|
|
# watching
|
|
|
|
tail -f /var/log/cisco-port-failover.log
|
2023-11-13 19:02:45 +03:00
|
|
|
```
|