当前位置:网站首页>netdata邮件告警配置
netdata邮件告警配置
2022-06-29 12:17:00 【gsls200808】
接上一篇msmtp服务配置完成之后,这篇继续配置邮件告警
1.配置netdata邮件收件人
/etc/netdata/edit-config health_alarm_notify.conf
命令类似vi i进编辑模式,编辑完成 esc输入:wq保存
修改
DEFAULT_RECIPIENT_EMAIL="root" 将root修改成邮件地址,多个地址用空格分开,邮件后可接|critical告警等级,如
DEFAULT_RECIPIENT_EMAIL="[email protected] [email protected]|critical"其中第一个邮件地址接收所有等级的告警,第二个邮件地址接收critical等级的告警结果。
2.配置sendmail的路径为msmtp的路径
修改配置
/etc/netdata/edit-config health_alarm_notify.conf将
sendmail=""改成
sendmail="/usr/bin/msmtp"测试发送
/usr/libexec/netdata/plugins.d/alarm-notify.sh test 第一个邮件地址能收到3封邮件,第二个邮件地址能收到2封邮件,第一个多一个warning邮件。
3.用stress压测cpu
安装stress
yum install epel-release.noarch
yum install stress
压测cpu
stress --cpu 1 --timeout 600
这里使用模拟1个 CPU 使用率 100% 的场景
1是cpu核数,根据你的电脑调整,是几核就改成几,等待10分钟就有critical级别的告警了。
常见问题
1.十分钟后没有发送邮件查找日志
日志错误报
msmtp: account default not found: no configuration file available将.msmtprc文件权限改成644并且剪切到/etc/msmtprc目录下,不要用复制,复制会有配置冲突
chmod 644 ~/.msmtprc
mv ~/.msmtprc /etc/msmtprc2.日志错误报
msmtp: /etc/msmtprc: line 11: account default was already defined解决方法:将/root/.msmtprc文件删除,只保留/etc/msmtprc文件
3.带|critical的收不到告警恢复的clear邮件
查看日志报
touch: /var/cache/netdata/alarm-notify/email/[email protected]/1655974263: Permission denied如果是docker环境,将:/var/cache/netdata目录映射出去就解决了
docker run命令添加
-v netdatacache:/var/cache/netdata \完整命令
docker run -d --name=netdata \
-p 19999:19999 \
-v netdatacache:/var/cache/netdata \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--restart unless-stopped \
--cap-add SYS_PTRACE \
--security-opt apparmor=unconfined \
netdata/netdata实测告警恢复的clear邮件有半小时延迟,critical和warning邮件没有延迟,具体情况还得继续研究。
注意:这里的 -v netdatacache使用的docker数据卷,不能用其他目录如${PWD}/netdatacache代替,否则docker无法启动
5.docker日志和邮件日志时间为utc
查看相关issue发现,netdata会读取/etc/localtime的配置,做一下目录映射就好了
增加映射
-v /etc/localtime:/etc/localtime:ro \完整命令
docker run -d --name=netdata \
-p 19999:19999 \
-v netdatacache:/var/cache/netdata \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /etc/localtime:/etc/localtime:ro \
--restart unless-stopped \
--cap-add SYS_PTRACE \
--security-opt apparmor=unconfined \
netdata/netdata边栏推荐
- Go learning - build a development environment vscode development environment golang
- AcWing 234 放弃测试
- LR、CR纽扣电池对照表
- C # implementation of binary tree non recursive middle order traversal program
- Beifu PLC controls servo through CANopen communication
- C # output the middle order traversal through the clue binary tree
- UI file introduction in QT
- Schiederwerk Power Supply repair smps12 / 50 pfc3800 Analysis
- C # implements the operations of sequence table definition, insertion, deletion and search
- Method area of JVM
猜你喜欢

如何计算win/tai/loss in paired t-test

倍福控制器连接松下EtherCAT伺服注意事项

解决问题:ModuleNotFoundError: No module named ‘pip‘

【云原生】2.4 Kubernetes 核心实战(中)

Understanding of P value

UI file introduction in QT

1. Opencv实现简单颜色识别

Application Service Vulnerability scanning and exploitation of network security skills competition in secondary vocational schools (SSH private key disclosure)

LeetCode_ Double pointer_ Medium_ 328. parity linked list

STK_ Gltf model
随机推荐
Paper reproduction - ac-fpn:attention-guided context feature pyramid network for object detection
STK_GLTF模型
安装typescript环境并开启VSCode自动监视编译ts文件为js文件
If I am in Shenzhen, where can I open an account? In addition, is it safe to open an account online now?
Nacos startup error
C#通過中序遍曆對二叉樹進行線索化
推荐模型复现(二):精排模型DeepFM、DIN
Cocos star meetings at Hangzhou station in 2022
asp.net 项目使用aspnet_compiler.exe发布
C#通过中序遍历对二叉树进行线索化
AcWing 234 放弃测试
【智能QbD风险评估工具】上海道宁为您带来LeanQbD介绍、试用、教程
Introduction to multi project development - business scenario Association basic introduction test payroll
Inferiority complex and transcendence the meaning of life to you
asp. Net project using aspnet_ compiler. Exe Publishing
Recommended model recurrence (I): familiar with torch rechub framework and use
leetcode 903. DI 序列的有效排列
PyGame accurately detects image collision
2022.6.28-----leetcode.324
C # realize the hierarchical traversal of binary tree