Monit send empty mail
I configured Monit (version 5.27.1) and after a reload of monit I received an "empty" mail. I searched since many hours and I can't fiind the way... It seems that "environment variables" remains empty. But why ? (all personnal informations are false)
I configured /etc/monit/monitrc like this :
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
After "$ monit reload" I received this email : (Date, Action, Host, Description are empty. Why ?)
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
Just in case this is my '/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
What am I missing?
Solution 1:
Your shell simply replaces anything starting with $
with its value from your env. So you are basically not writing a $
into monit's config file.
Try cat /etc/monit/monitrc
or view the in nano
or vim
... The file will not contain the variables monit replaces.
Solution would be to prepend any $
with a backslash \$
or not to use cat
but an editor...