0

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 alexandre.gigoga@gmail.com

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 <alexandre.gigoga@gmail.com>; Fri, 19 Mar 2021 14:29:59 +0100 (CET)
From: "Monit Support" <monit@vps-msxp453234>
To: alexandre.gigoga@gmail.com
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?

FlipFlap
  • 1
  • 1
  • You should remove confidential and personnal information, such as password and email – DevOps Mar 19 '21 at 15:16
  • What is the version of Monit ? – DevOps Mar 19 '21 at 15:17
  • If you goal is only to override the "from" field, you can only override this field with set mail-format { from: monit@foo.bar } – DevOps Mar 19 '21 at 15:22
  • @DevOps All personnal informations are false. My question is why Date, Action, Host, Description are empty in the email I received ? (Monit version 5.27.1) – FlipFlap Mar 19 '21 at 16:00

1 Answers1

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...

boppy
  • 476
  • 2
  • 5