Shell

推荐列表 站点导航

当前位置:首页 > 脚本编程 > Shell >

ping检测告警函数的shell脚本

来源:网络整理  作者:  发布时间:2020-12-21 15:46
分享一例shell脚本,使用ping方法检测并告警,为bash实现的一个小函数,分享给大家学习参考下。...
可交互的并发ping检测脚本

#!/usr/bin/bash

代码:
   #sleep 1
分享几个ping主机是否存活的shell脚本(图文)
         echo "`date "+%Y%m%d %H:%M:%S"`--->$host服务器ping检测正常" >>ping_log
定时自动ping主机的shell脚本(图文)
ping_count=3
又一个shell写的ping函数
   loss_ping=`echo ${ping_result:46:4}`
ping所有主机的shell脚本(图文)
    INSERT INTO $dbtable (servercode,smsservercode,groupid,priority,calling,called,payer,orderdatetime,senddatetime,effectstarttime,
}

callop=1310000000
(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)
一个ping检测告警函数

ping_monitor()
effectendtime,effectstarttime2,effectendtime2,invaliddatetime,feevalue,iffee,message,hideflag,msgtype,smsfeetype,ifsmsreport,service
type,morelatetomtflag,reserve,optempid,optuserid,clientprogramtype,optcode,optip,remark)
使用ping命令检测整个网段IP的网络状态的shell脚本(图文)
   ping_result=`ping $host -c $ping_count |tail -2 |head -1`
 

echo "`date "+%Y%m%d %H:%M:%S"`----->脚本开始执行......">>ping_log
   echo "-------->开始检测$host服务器通迅是否正常,ping次数$count"
for host_1 in ${host_[*]};do
         for called in ${telno[*]};do
done
host_=(203 204 205 207 208 209 210 212 213 214 215 216 217 218 219 220 221)

更多有关shell ping函数的文章,请参考:
#site: ym97.com/wenku
   echo "`date "+%Y%m%d %H:%M:%S"`----->脚本运行完毕......">>ping_log
          done
         echo "`date "+%Y%m%d %H:%M:%S"`--->$host服务器有丢包现象,丢包率为:$loss_ping" >>ping_err_log
ping检测告警函数

         echo "本次检测结果---->$host服务器有丢包现象,丢包率为:$loss_ping"

复制代码 代码示例:

         echo "本次检测结果---->$host服务器ping检测正常"
{
mysql -h$dbhost -u$dbuser -p$dbpass -D$dbbase <<GETRECODE
      if [ $succ_ping -eq $ping_count ];then
   host=192.168.1.$host_1
called=(13000000001 13000000002 13000000003)
calling=13000000000
   #取成功条数
在nagios  停用后,目前平台用这个来做为服务器告警机制。

本次完善了之前的ping脚本,做成服务器通用告警函数。

本节内容:
      else
         #插入短信表—smssend00
  VALUES
linux下自动ping命令检测IP地址的shell脚本(图文)
   succ_ping=`echo ${ping_result:23:1}`
GETRECODE
   echo "-------->服务器$host检测已完成"
#main-------------------
       fi
#
   #取失败百分比

相关热词: shell

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/jiaob/shell/6691.shtml

相关文章
最新文章
PHP生成奖状 PHP生成奖状

时间:2021-01-06

python实现输入五个数并求 python实现输入五个数并求

时间:2021-01-06

php检测网站是否正常打开 php检测网站是否正常打开

时间:2021-01-05

python怎么右对齐 python怎么右对齐

时间:2021-01-05

Python3爬虫入门之Python3的安 Python3爬虫入门之Python3的安

时间:2021-01-05

如何用PHP接收http请求头信 如何用PHP接收http请求头信

时间:2021-01-05

数据库怎么连接用php写的 数据库怎么连接用php写的

时间:2021-01-05

php后缀怎么打开 php后缀怎么打开

时间:2021-01-05

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

ping检测告警函数的shell脚本

2020-12-21 编辑:

可交互的并发ping检测脚本

#!/usr/bin/bash

代码:
   #sleep 1
分享几个ping主机是否存活的shell脚本(图文)
         echo "`date "+%Y%m%d %H:%M:%S"`--->$host服务器ping检测正常" >>ping_log
定时自动ping主机的shell脚本(图文)
ping_count=3
又一个shell写的ping函数
   loss_ping=`echo ${ping_result:46:4}`
ping所有主机的shell脚本(图文)
    INSERT INTO $dbtable (servercode,smsservercode,groupid,priority,calling,called,payer,orderdatetime,senddatetime,effectstarttime,
}

callop=1310000000
(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)
一个ping检测告警函数

ping_monitor()
effectendtime,effectstarttime2,effectendtime2,invaliddatetime,feevalue,iffee,message,hideflag,msgtype,smsfeetype,ifsmsreport,service
type,morelatetomtflag,reserve,optempid,optuserid,clientprogramtype,optcode,optip,remark)
使用ping命令检测整个网段IP的网络状态的shell脚本(图文)
   ping_result=`ping $host -c $ping_count |tail -2 |head -1`
 

echo "`date "+%Y%m%d %H:%M:%S"`----->脚本开始执行......">>ping_log
   echo "-------->开始检测$host服务器通迅是否正常,ping次数$count"
for host_1 in ${host_[*]};do
         for called in ${telno[*]};do
done
host_=(203 204 205 207 208 209 210 212 213 214 215 216 217 218 219 220 221)

更多有关shell ping函数的文章,请参考:
#site: ym97.com/wenku
   echo "`date "+%Y%m%d %H:%M:%S"`----->脚本运行完毕......">>ping_log
          done
         echo "`date "+%Y%m%d %H:%M:%S"`--->$host服务器有丢包现象,丢包率为:$loss_ping" >>ping_err_log
ping检测告警函数

         echo "本次检测结果---->$host服务器有丢包现象,丢包率为:$loss_ping"

复制代码 代码示例:

         echo "本次检测结果---->$host服务器ping检测正常"
{
mysql -h$dbhost -u$dbuser -p$dbpass -D$dbbase <<GETRECODE
      if [ $succ_ping -eq $ping_count ];then
   host=192.168.1.$host_1
called=(13000000001 13000000002 13000000003)
calling=13000000000
   #取成功条数
在nagios  停用后,目前平台用这个来做为服务器告警机制。

本次完善了之前的ping脚本,做成服务器通用告警函数。

本节内容:
      else
         #插入短信表—smssend00
  VALUES
linux下自动ping命令检测IP地址的shell脚本(图文)
   succ_ping=`echo ${ping_result:23:1}`
GETRECODE
   echo "-------->服务器$host检测已完成"
#main-------------------
       fi
#
   #取失败百分比

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/jiaob/shell/6691.shtml

相关文章

风云图片

推荐阅读

返回Shell频道首页