cisco-management/README.md

52 lines
1.7 KiB
Markdown

# cisco-management
Wireguard management and monitoring utils.
* [`cisco-port-failover`.py](https://git.hmp.today/pavel.muhortov/cisco-management#cisco-port-failover-py)
____
## `cisco-port-failover`.py
**Description:**
> Cisco ports switching if the target is unreachable.
**Dependencies:**
>
> * 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
```
```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
```
```bash
# watching
tail -f /var/log/cisco-port-failover.log
```