Skip to content

Instantly share code, notes, and snippets.

@trydofor
Created March 8, 2019 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trydofor/46eadcf467a4075ec5e34984cc5c4c97 to your computer and use it in GitHub Desktop.
Save trydofor/46eadcf467a4075ec5e34984cc5c4c97 to your computer and use it in GitHub Desktop.
日志监控配置-钉钉
## this conf value will be replaced by sub-conf ##
NOTICE_PROC(){
confname=$1
textfile=$2
scp $textfile ubuntu@jiayu-release:/data/staticweb/procerr/log/ && rm -rf $textfile
cnt="1"
if [ -f "$path_data/COUNT-$1" ]; then
cnt=`cat $path_data/COUNT-$1`
cnt=$((cnt + 1))
fi
echo $cnt > "$path_data/COUNT-$1"
filename=`basename $textfile`
# 钉钉提醒 https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq
curl 'https://oapi.dingtalk.com/robot/send?access_token=79a118420549b094c935119aa8ff0e5b43815f43e9d1d3b850eb1022ba52b39d' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "link",
"link": {
"text": "规则 '"$confname"' 报警,日志 release:/data/monitor/proc-monitor/log/'"$filename"'",
"title": "'"$MAIL_SUBJ"'-'"$cnt"'",
"picUrl": "http://log.jiayuinc.com/bug.jpg",
"messageUrl": "http://log.jiayuinc.com/log/'"$filename"'"
}
}
'
return 1
}
# mail
MAIL_SUBJ="COMMON ALERT"
# conf
PATH_CONF=./conf
LINE_SEND=100
# scan
# empty value means do nothing
# a file or single command's output(no pipe) to scan
SCAN_FILE_OR_CMND=
# TRUE|FALSE:send warnning mail if $SCAN_FILE_OR_CMND does not have new lines.
SCAN_WARN_IF_STOP=
# SCAN_RULE_IF_*
# file : execute each line on $SCAN_FILE_OR_CMND
# line format:description=command
# command: execute command on $SCAN_FILE_OR_CMND
# SCAN_CMND_IF_*
# command: will be executed if $SCAN_RULE_IF_* matched
# _HAVE: $SCAN_RULE_IF_* get output
# _LOST: $SCAN_RULE_IF_* get no output
# $RULE_RESULT_* for rule result
SCAN_RULE_IF_HAVE=
SCAN_CMND_IF_HAVE=
SCAN_RULE_IF_LOST=
SCAN_CMND_IF_LOST=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment