# Switch-Configuration-Backup-and-Change-Detection **Repository Path**: gsls200808/Switch-Configuration-Backup-and-Change-Detection ## Basic Information - **Project Name**: Switch-Configuration-Backup-and-Change-Detection - **Description**: 交换机配置备份及变更检测 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 7 - **Forks**: 1 - **Created**: 2019-09-05 - **Last Updated**: 2022-07-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Switch-Configuration-Backup-and-Change-Detection #### 介绍 交换机配置备份及变更检测 #### 软件架构 python版本支持3.x 使用telent,ssh方式读取交换机配置,telent采用telnetlib方式,ssh采用paramiko方式,对于more处理,暂时采用字符串匹配,不考虑正则。 保存文件分本地和OSS模式,对比采用difflib库 发送邮件使用smtplib库,支持最常使用的QQ邮箱和Yandex邮箱 读取曾考虑netmiko库,但是简化程度太少 #### 安装说明 1. 适用于CentOS7系统的安装命令 ``` mkdir -p /data/app/ cd /data/app git clone https://gitee.com/gsls200808/Switch-Configuration-Backup-and-Change-Detection.git mv Switch-Configuration-Backup-and-Change-Detection switchConfig cd switchConfig # 安装依赖 pip3 install -r requirements.txt # 第二种方式安装依赖 pip3 install paramiko pip3 install oss2 ``` #### 使用说明 1. 安装python3,参考https://www.cnblogs.com/yangzhaon/p/11203395.html 1. 修改QQSendEmail.py或者YandexSendEmail.py配置成你自己的邮箱地址,后续考虑做成可配置化的 2. 修改SwitchConfig.json 配置交换机IP,保存文件名,查看配置命令 终端前缀等信息 3. 执行命令 ``` python3 mainRun.py ``` 4. 若mainRun.py的所在目录目录位于/data/app/switchConfig,也可以执行 ``` chmod +x mainRun.sh ./mainRun.sh ``` 5. 设置定时 ``` crontab -e i进入编辑模式,输入如下内容 30 8 * * * /data/app/switchConfig/mainRun.sh :wq回车保存 ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request