shell获取数据库日志告警信息
拼接json,发送给server
钉钉实现告警
#!/bin/bash dbid=1 host_ip='测试' alterFile=/root/error.log alertLineFile=/tmp/alertLine message= if [ ! -f "$alertLineFile" ] || [ ! -s "$alertLineFile" ]; then echo 0 > $alertLineFile fi alertLine=$(cat "$alertLineFile") if [ $alertLine -eq 0 ]; then alertLine=$(awk 'END{print NR}' $alterFile) echo $alertLine > $alertLineFile exit else endLine=$(awk 'END{print NR}' $alterFile) [[ $alertLine -gt $endLine ]] && exit message=$(sed -n "$alertLine,$endLine p" $alterFile |grep -E 'ORA-'|grep -v 'ORA-00060'|sed 's/\"//g') let endLine++ echo $endLine > $alertLineFile fi if [ ! -z "$message" ]; then json="{\"dbid\":\"$dbid\",\"host_ip\":\"$host_ip\",\"message\":\"$message\"}" ##send message curl -H "Content-Type: application/json" -X POST --data "$json" http://10.15.49.54:8090/interface/getloginfo fi
分类:
Linux
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY