In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use smokeping to achieve nail alarm function", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to use smokeping to achieve nail alarm function" bar!
First: the way to obtain the API of nailing robot
Nail open platform
Second: configure smokeping to call an external script for mail alarm
Vim / opt/smokeping/etc/config*** Alerts * * # to = 88@wsfnk.comto = | / opt/smokeping/bin/mailx_alert.sh # use | to connect the script path and call the external script from = smokealert@company.xy# Note: smokeping will send 5 parameters to the alarm receiving media when the alarm occurs (this is our custom alert script) The parameters in this order are: name-of-alert, target, loss-pattern, rtt-pattern, hostname, corresponding to $1Mutual 5 of the following alarm script
Third, write the alarm script and attach the alarm effect picture.
The alarm effect is as follows
Cat / opt/smokeping/bin/mailx_alert.sh
#! / bin/bash### Script to email a ping report on alert from Smokeping # # parsing variable Alertname=$1Target=$2Losspattern=$3Rtt=$4Hostname=$5Date=$ (date'+% Y-%m-%d% HRV% MRV% S') # this is the type of $1 color created by the smokeping alarm # A1 hightlossvalues B2 = "HK.HK-9S.9s-3 [from template]" # C3 = "loss: 0% 0%, 0%, 0%, 15%, 45%, 40% "# D4 =" rtt: 29ms, 29ms, 29ms, 29ms, 33ms, 33ms, 33ms "# E5 =" 1.1.1.1 "# Note: alarm for nailing robot Reprocess variables because in the nailing robot alarm (the contents of the variables cannot contain spaces) # A = `echo $1 | sed's / g``case "$Alertname" in hightloss) Ablications hightloss-High packet loss ; hostdown) downtime downside; rtt-1) Atroprtttel 1-High delay Esac# processing variable BB= `echo $2 | sed's / g'`B = `echo $B | sed's /\ [fromSH_youfu_CT_Proxy\] / / g'`B = `echo $B | sed's /\ [fromtemplate\] / / g'` # here for the beauty of the alarm content Incidentally, rtt: and loss: erased C = `echo $3 | sed's / g'`C = `echo $C | sed's Universe sed g``D= `echo $4 | sed's / g'`D`D= `echo $D | sed's hash RttRttUniG`E = `echo $5 | sed's / / g'`F = `echo $5 | sed's / / _ / g'`G = unknown category # defines the "function of the target category" () {echo / etc/targets P = `cat-n "$H"-"$X" | grep "host = $E$" | cut-f 1 `cat-n "s/menu = / / g $PP p "$Hkoshi X `} # set the A terminal Z of the alarm value. The default setting here is" AEND= Shenzhen Aliyun, ZEND=DNS "# which computer room is judged to have an alarm if according to the target of the alarm [`echo" $Target "| grep SGP | wc-l`-ne 0]; then ZEND=' Singapore 'X=SGP Mubiao elif [`echo" $Target "| grep PHI | wc-l`-ne 0] Then ZEND=' Philippines' X=PHI Mubiao elif [`echo "$Target" | grep HK | wc-l`-ne 0]; then ZEND=' Hong Kong 'X=HK Mubiao elif [`echo "$Target" | grep LA | wc-l`-ne 0] Then ZEND=' Los Angeles' X=LA Mubiao elif [`echo "$Target" | grep JP | wc-l`-ne 0]; then ZEND=' Japan 'X=JP Mubiao elif [`echo "$Target" | grep KOR | wc-l`-ne 0] Then ZEND=' Korea 'X=KOR Mubiao elif [`echo "$Target" | grep CD-PBS | wc-l`-ne 0]; Dr. then ZEND=' Chengdu' X=TG Mubiao elif [`echo "$Target" | grep BJ-SJQ | wc-l`-ne 0] Then ZEND=' Beijing Sijiqing 'X=TG Mubiao elif [`echo "$Target" | grep SH-YF | wc-l`-ne 0]; then ZEND=' has dual lines' X=TG Mubiao elif [`echo "$Target" | grep SZ-YX | wc-l`-ne 0] Then ZEND=' Shenzhen easy letter 'X=TG Mubiao elif [`Shenzhen "$Target" | grep SZ-PBS | wc-l`-ne 0]; then ZEND=' Shenzhen Peng' X=TG Mubiao elif [`echo "$Target" | grep TG-YN | wc-l`-ne 0] Then ZEND=' Vietnam 'X=TG Mubiao else [`echo "$Target" | grep DNS | wc-l`-ne 0] ZEND='DNS' X=DNS Mubiao fi# determines whether the alarm source location (hostname of smokeping_salve) if is based on the target of the alarm. [`echo "$Target" | grep SH_youfu | wc-l`-ne 0] Then AEND=' has dual-line 'elif [`echo "$Target" | grep template | wc-l`-ne 0] Then AEND=' Shaanxi Unicom 'else AEND=' Shenzhen Aliyun' # mtr-r-n $Hostname > > / tmp/mtr.txt# echo'+'> / tmp/mtr.txt fi# nailing No.2 robot API# https://oapi.dingtalk.com/robot/send?access_token=6c1712241129c425e5385d7d164ffe1ed4d4663b0651c4e# nailing No.3 robot API#https:/ / oapi.dingtalk.com/robot/send?access_token=98ce2cf2925eb0b960745b449ee63a9917571a650f6e7ca4b323f73c7# nailing robot alarm executive part # Note: alarm for nailing robot Reprocess variables Because in the nailing robot alarm (variables cannot contain spaces) curl 'https://oapi.dingtalk.com/robot/send?access_token=6c1712241129c425e5385d7d164ffe1ed4d4663b065b50bf'\-H' Content-Type: application/json'\-d'{"msgtype": "text" "text": {"content": "('$AEND'-'$ZEND') Network warning alarm Policy:'$A' Target Category:'$G' Target name:'$B' packet loss rate:'$C 'delay:' $D' destination address:'$E 'failure time:' $F'"}, "at": {"atMobiles": ["182 lost packets" 8240 "] "isAtAll": false}}'# > > / tmp/dingding-alert.log 2 > & execution part of email alarm call It is not used here for the time being. Only log file # zhuti= "Code ($AEND-$ZEND) Network quality alarm" # messages= `echo-e "alarm policy name:\ t$ Alertname\ nalarm target:\ t$ Target\ npacket loss rate:\ t$ Losspattern\ ndelay time:\ t$ Rtt\ nHost address:\ t$Hostname\ nalarm time:\ t$Date" `# email= "zhsd@www.com" echo "$Date-- $Alertname-- $Target-- $Losspattern-- $Rtt-- $Hostname" > > / tmp/smokeping-baojin#echo "$messages" | mail-s "$zhuti" $email > > / tmp/mailx.log 2 > & 1 Thank you for reading The above is the content of "how to use smokeping to achieve nail alarm function". After the study of this article, I believe you have a deeper understanding of how to use smokeping to achieve nail alarm function, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.