MogDB/openGauss 自定义snmptrapd告警信息

随笔4小时前发布 靖格睿睿
4 0 0

MogDB/openGauss 自定义 snmptrapd 告警信息
在实际使用中,默认的报警规则信息并不能很好的满足 snmp 服务端的需求,需要定制化报警信息,这里以添加 ip 为例,看似一个简单的将 IP 一行信息单独在报警展示出来,涉及到的配置文件修改还是挺多的。

修改 prometheus.yml 文件
首先需要修改 prometheus.yml 文件,在对应的实例下添加 ip 标签

修改规则报警文件
对应的报警规则文件也同样需要修改,我这里使用的是服务器磁盘使用率做报警测试,所以直接修改 node_rules.yml 文件,添加 ip 信息。

查看 alertmanager web 界面
现在我们就可以在 alertmanager 的界面上看到我们新添加的 ip 标签了,同时报警信息里也带了 ip。

修改 snmp_notifier 模版
altermanager 模块将报警消息推送到 snmp_notifier 后,还需要需改 snmp_notifier 的描述模版 description-template.tpl。

snmptrapd 服务器接受报警信息
添加额外的模版
默认情况下,snmptrapd 只会输出三行模版信息,要添加额外的版本信息需要使用–snmp.extra-field-template 参数,比如添加第 4 行模版则在 snmp_notifier 启动时指定参数–snmp.extra-field-template=4=/opt/snmp_notifier/extra-field-template.tpl,模版 extra-field-template.tpl 可以参考 description-template.tpl 的格式

{{- if .Alerts -}}
{{- range $severity, $alerts := (groupAlertsByLabel .Alerts “severity”) -}}
{{- range $index, $alert := $alerts }}
{{ $alert.Annotations.ip }}
{{ end }}
{{ end }}
{{- end -}}
启动 snmp_notifier
nohup /opt/snmp_notifier/snmp_notifier –snmp.trap-description-template=/opt/snmp_notifier/description-template.tpl –snmp.extra-field-template=4=/opt/snmp_notifier/extra-field-template.tpl > /opt/snmp_notifier/snmp_notifier.log 2>&1 &
再次查看 snmptrapd 服务器接受报警信息

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...