Monit 发送空邮件

Monit 发送空邮件

我配置了 Monit(版本 5.27.1),在重新加载 monit 后,我​​收到了一封“空”邮件。我搜索了好几个小时,却找不到方法……似乎“环境变量”仍然是空的。但为什么呢?(所有个人信息都是假的)

我像这样配置了 /etc/monit/monitrc:

cat > /etc/monit/monitrc << EOF
set daemon 120
with start delay 240


set logfile /var/log/monit.log
set pidfile /var/run/monit.pid


set eventqueue
basedir /var/lib/monit/events
slots 100


set mailserver 127.0.0.1
    with timeout 10 seconds


set mail-format {
    from: Monit Support <monit@vps-msxp453234>
    subject: monit alert -- $EVENT $SERVICE
    message: $EVENT Service $SERVICE
    Date: $DATE
    Action: $ACTION
    Host: $HOST
    Description: $DESCRIPTION
    Your faithful employee,
    Monit
}

set alert [email protected]

set httpd
port 18385
with ssl {
    pemfile: /etc/ssl/private/monit.pem
}
allow Alex_8xws2_admin:p2pp85zl


include /etc/monit/conf.d/*
include /etc/monit/conf-enabled/*
EOF

“$ monit reload”之后我收到这封电子邮件:(日期、操作、主机、描述都是空的。为什么?)

Received: from vps-msxp453234 (localhost [127.0.0.1])
    by vps-msxp453234.vps.domain.net (Postfix) with ESMTP id 40A961
    for <[email protected]>; Fri, 19 Mar 2021 14:29:59 +0100 (CET)
From: "Monit Support" <monit@vps-msxp453234>
To: [email protected]
Subject: monit alert --
Date: Fri, 19 Mar 2021 13:29:59 GMT
X-Mailer: Monit 5.27.1
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Message-Id: <60599.98c9a5@vps-msxp453234>

Service 
Date: 
Action: 
Host: 
Description: 
Your faithful employee,
Monit

以防这是我的“/etc/hosts”:

127.0.0.1       localhost

::1     localhost       ip6-localhost   ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

41.27.221.113   vps-msxp453234.vps.domain.net        vps-msxp453234

我错过了什么?

答案1

您的 shell 只是用$您环境中的值替换以 开头的任何内容。因此,您基本上没有将 写入$monit 的配置文件。

尝试cat /etc/monit/monitrc或查看...该文件将不包含 monitnano替换vim的变量。

解决方案是在前面加上$反斜杠\$或者不使用cat编辑器......

相关内容