接外包,有相关需求的可以联系我:Telegram | Email

NETDATA 监控面板邮件配置

该文章创建(更新)于12/11/2020,请注意文章的时效性!

自己上午搭建好NETDATA并配置好Telegram预警后就尝试了一下配置EMAIL,教程如下!

NETDATA配置

请参考NETDATA

邮件信息获取

这个没啥好说的!我自己用域名搭建了了一个邮件服务器!如果是其它邮件请自行搜索!这里的配置是不能有SSL协议的,docker里面的cert有问题!

进入NETDATA DOCKER 环境

注意替换为你自己服务器分配的CONTAINER ID

docker ps
docker exec -it bab6e102f429 /bin/bash

配置msmtp

配置

vi /root/.msmtprc
  • 配置文件参考(请按照配置说明和自己服务器情况自行更改,不要做只会从copy的脑残)如下:

原参考地址https://marlam.de/msmtp/msmtprc.txt

# Example for a user configuration file ~/.msmtprc
#
# This file focusses on TLS and authentication. Features not used here include
# logging, timeouts, SOCKS proxies, TLS parameters, Delivery Status Notification
# (DSN) settings, and more.


# Set default values for all following accounts.
defaults

# Use the mail submission port 587 instead of the SMTP port 25.
port 587

# Always use TLS.
tls on

# Set a list of trusted CAs for TLS. The default is to use system settings, but
# you can select your own file.
#tls_trust_file /etc/ssl/certs/ca-certificates.crt


# A freemail service
account freemail

# Host name of the SMTP server
host smtp.freemail.example

# As an alternative to tls_trust_file, you can use tls_fingerprint
# to pin a single certificate. You have to update the fingerprint when the
# server certificate changes, but an attacker cannot trick you into accepting
# a fraudulent certificate. Get the fingerprint with
# $ msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.freemail.example
#tls_fingerprint 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33

# Envelope-from address
from [email protected]

# Authentication. The password is given using one of five methods, see below.
auth on
user joe.smith

# Password method 1: Add the password to the system keyring, and let msmtp get
# it automatically. To set the keyring password using Gnome's libsecret:
# $ secret-tool store --label=msmtp \
#   host smtp.freemail.example \
#   service smtp \
#   user joe.smith

# Password method 2: Store the password in an encrypted file, and tell msmtp
# which command to use to decrypt it. This is usually used with GnuPG, as in
# this example. Usually gpg-agent will ask once for the decryption password.
passwordeval gpg2 --no-tty -q -d ~/.msmtp-password.gpg

# Password method 3: Store the password directly in this file. Usually it is not
# a good idea to store passwords in cleartext files. If you do it anyway, at
# least make sure that this file can only be read by yourself.
#password secret123

# Password method 4: Store the password in ~/.netrc. This method is probably not
# relevant anymore.

# Password method 5: Do not specify a password. Msmtp will then prompt you for
# it. This means you need to be able to type into a terminal when msmtp runs.


# A second mail address at the same freemail service
account freemail2 : freemail
from [email protected]


# The SMTP server of your ISP
account isp
host mail.isp.example
from [email protected]
auth on
user 12345


# Set a default account
account default : freemail
  • 我的配置
defaults
port 465
tls off
account freemail
host xxx.
from [email protected]
auth login  # 这里不能用on,否则会报错
user [email protected]
password xxxxxxxxxx
account default : freemail

测试配置

msmtp [email protected]

请注意替换为你收件邮箱,回车后输入发送内容,按CTRL+D发送。若邮件接收成功则配置成功,若失败则有相关提示信息!

配置NETDATA发送邮件

  • 修改配置文件
vi /etc/netdata/health_alarm_notify.conf
  • 把sendmail的参数指向msmtp
sendmail="/usr/bin/msmtp"
  • 配置收件人信息 | 如下图

  • 更改msmtprc的文件权限
chmod 600 ~/.msmtprc

最终测试

如收到相关邮件则配置成功!

# enable debugging info on the console
export NETDATA_ALARM_NOTIFY_DEBUG=1

# send test alarms to sysadmin
/usr/libexec/netdata/plugins.d/alarm-notify.sh test

# send test alarms to any role
/usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE"

后续更新 | 2020-12-13

经过一晚上的观察,发现邮件提醒虽然测试能够使用,但实际没法正常工作,后续找到了解决办法!具体原因不详,都弄一下吧!

docker exec -it --user root <container id> /bin/bash
  • 更改配置文件为644(官方教程为600,具体没测试)
chmod 644 ~/.msmtprc
  • 复制配置文件
cp ~/.msmtprc /etc/msmtprc

要不赞赏一下?

微信
支付宝
PayPal
Bitcoin

版权声明 | Copyright

除非特别说明,本博客所有作品均采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。转载请注明转自-
https://www.emperinter.info/2020/12/11/config-email-notifications-of-netdata/


要不聊聊?

我相信你准备留下的内容是经过思考的!【勾选防爬虫,未勾选无法留言】

*

*



YouTube | B站

微信公众号

优惠码

阿里云国际版20美元
Vultr10美元
搬瓦工 | Bandwagon应该有折扣吧?
Just My SocksJMS9272283 【注意手动复制去跳转】
域名 | namesiloemperinter(1美元)
币安 币安