国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Linux Shell > 正文

一個ping檢測告警函數代碼

2020-07-27 19:25:47
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

#!/bin/bash
 ping_monitor()
    {
    host_=(203 204 205 207 208 209 210 212 213 214 215 216 217 218 219 220 221)
    ping_count=3
    called=(13000000001 13000000002 13000000003)
    calling=13000000000
    callop=1310000000
    #main------------------------------------------------------------
    echo "`date "+%Y%m%d %H:%M:%S"`----->腳本開始執行......">>ping_log
    for host_1 in ${host_[*]};do
       host=192.168.1.$host_1
       echo "-------->開始檢測$host服務器通迅是否正常,ping次數$count"
       ping_result=`ping $host -c $ping_count |tail -2 |head -1`
       #sleep 1
       echo "-------->服務器$host檢測已完成"
       #取成功條數
       succ_ping=`echo ${ping_result:23:1}`
       #取失敗百分比
       loss_ping=`echo ${ping_result:46:4}`
          if [ $succ_ping -eq $ping_count ];then
             echo "本次檢測結果---->$host服務器ping檢測正常"
             echo "`date "+%Y%m%d %H:%M:%S"`--->$host服務器ping檢測正常" >>ping_log
          else
             echo "本次檢測結果---->$host服務器有丟包現象,丟包率為:$loss_ping"
             echo "`date "+%Y%m%d %H:%M:%S"`--->$host服務器有丟包現象,丟包率為:$loss_ping" >>ping_err_log
             #插入短信表―smssend00
             for called in ${telno[*]};do
    mysql -h$dbhost -u$dbuser -p$dbpass -D$dbbase <<GETRECODE
        INSERT INTO $dbtable (servercode,smsservercode,groupid,priority,calling,called,payer,orderdatetime,senddatetime,effectstarttime,
    effectendtime,effectstarttime2,effectendtime2,invaliddatetime,feevalue,iffee,message,hideflag,msgtype,smsfeetype,ifsmsreport,service
    type,morelatetomtflag,reserve,optempid,optuserid,clientprogramtype,optcode,optip,remark)
      VALUES
    (2,2,1,0,'$calling','$called','$callop',Now(),Now(),'00:00:00','23:59:59',NULL,NULL,NULL,0,1,'服務器告警!!$host服務器檢測到有丟包現像,丟包率:$loss_ping',0,1,2,0,'2_2',NULL,NULL,1,668,1,3001,'192.168.1.182',NULL)
    GETRECODE
              done
           fi
    done
       echo "`date "+%Y%m%d %H:%M:%S"`----->腳本運行完畢......">>ping_log
    }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 缙云县| 巨野县| 夹江县| 固始县| 高要市| 晋江市| 邢台市| 射洪县| 将乐县| 塔城市| 新丰县| 新源县| 平利县| 东乡| 株洲市| 麦盖提县| 大港区| 方山县| 交城县| 化隆| 兰州市| 榆中县| 道孚县| 宁陵县| 顺平县| 开江县| 桑日县| 怀安县| 黄龙县| 铁岭市| 石首市| 南郑县| 稷山县| 衡水市| 海门市| 安吉县| 香格里拉县| 松溪县| 梁河县| 越西县| 临泉县|