• 博达交换机镜像检查,镜像丢失自动添加脚本


    check_bd_mirr.sh

    #!/bin/bash
    #/home/tools/check_tools/cfg_bd_mirror/check_bd_mirr.sh   #所在目录文件名
    process_day=`date -d today +"%Y-%m-%d %H:%M:%S"`
    cd /home/tools/check_tools/cfg_bd_mirror/Bdcom_bak
    rm -rf 10.230.*.cfg
    cd /home/tools/check_tools/cfg_bd_mirror/
    ./telnet_bdcom.sh
    #cfg_mir=$(cat /home/tools/check_tools/cfg_bd_mirror/Bdcom_bak/*10.230.87.221*.cfg |grep -E "mirror session 1 source")
    cfg_mir=$(cat /home/tools/check_tools/cfg_bd_mirror/Bdcom_bak/*`date -d today +"%Y%m%d"`*.cfg |grep -E "mirror session 1 source")
    ip_add=$(ls /home/tools/check_tools/cfg_bd_mirror/Bdcom_bak/*10.230.87.221*.cfg |awk -F "-" '{print $2}')
    if [[ -z $cfg_mir ]] ;
    then
       echo ${process_day} "no mirror"
     ./cfg_bd_mir.sh 
    else
       echo ${process_day} "mirror OK"
    fi
     
     
     
    telnet_bdcom.sh
     
    #!/bin/bash
    #/home/tools/check_tools/cfg_bd_mirror/telnet_bdcom.sh  #所在目录文件名
    datetime=`date +%Y%m%d`
    BAKTIME=`date +%Y%m%d%H%M%S`  
    user="admin"                 
    password="123456"              
    back1="enable"
    back2="config"
    back3="show runn"
    BAK_DIR=/home/tools/check_tools/cfg_bd_mirror/Bdcom_bak
    #mkdir $BAK_DIR
    for i in $(cat bdcom_ip_file)
    do
    {
    echo $user;
    sleep 1;                      
    echo $password;               
    sleep 1;                      
    echo $back1;                   
    sleep 1;
    echo $back2;                   
    sleep 1;
    echo $back3;   
    sleep 1;
    echo "
                                                    ";               
    sleep 5;                      
    }|telnet $i > $BAK_DIR/$i-$BAKTIME.cfg
    tail -n +18 $BAK_DIR/$i.cfg > $BAK_DIR/$i.cfg
    rm -rf $BAK_DIR/$i.cfg
    done
     
     
    cfg_bd_mir.sh
     
    #!/bin/bash
    #/home/tools/check_tools/cfg_bd_mirror/cfg_bd_mir.sh  #所在目录文件名
    datetime=`date +%Y%m%d`
    BAKTIME=`date +%Y%m%d%H%M%S`  
    user="admi"                  
    password="123456"              
    back1="enable"
    back2="config"
    back3="mirror session 1 source interface gigaEthernet 0/1 - 32 rx"
    back4="mirror session 1 source interface gigaEthernet 0/33 - 44 rx"
    back5="mirror session 1 destination interface g0/48"
    back6="int g0/13"
    back7="int g0/14"
    back8="int g0/25"
    back9="int g0/26"
    back10="shutdown"
    back11="no shutdown"
    back12="show runn"
    BAK_DIR=/home/tools/check_tools/cfg_bd_mirror/Bdcom_bak
    mkdir $BAK_DIR
    for i in $(cat bdcom_ip_file)
    do
    {
    echo $user;
    sleep 1;                      
    echo $password;               
    sleep 1;                      
    echo $back1;                   
    sleep 1;
    echo $back2;                   
    sleep 1;
    echo $back3;   
    sleep 1;
    echo $back4;
    sleep 1;
    echo $back5;
    sleep 1;
    echo $back6;
    sleep 1;
    echo $back10;
    sleep 1;
    echo $back11;
    sleep 1;
    echo $back7;
    sleep 1;
    echo $back10;
    sleep 1;
    echo $back11;
    sleep 1;
    echo $back8;
    sleep 1;
    echo $back10;
    sleep 1;
    echo $back11;
    sleep 1;
    echo $back9;
    sleep 1;
    echo $back10;
    sleep 1;
    echo $back11;
    sleep 1;
    echo $back12;
    sleep 1;
    echo "
                                                    ";               
    sleep 5;                      
    }|telnet $i > $BAK_DIR/$i-$BAKTIME.log
    tail -n +18 $BAK_DIR/$i-$BAKTIME.log > $BAK_DIR/MY-$i-$BAKTIME.log
    rm -rf $BAK_DIR/$i-$BAKTIME.log
    done
  • 相关阅读:
    Deltix Round, Summer 2021
    CF1558F Strange Sort 题解
    将文本复制到粘贴板上
    Mac安装2021ps
    腾讯云TDSQL-C云原生数据库技术
    腾讯云分布式数据库TDSQL再获认可
    T-TDSQL的核心技术
    TDSQL原创技术的出发点
    拓路前行-TDSQL追求极致体验的这一路
    TDSQL多集群下的自动化和交付
  • 原文地址:https://www.cnblogs.com/xl-892694298/p/11018807.html
Copyright © 2020-2023  润新知