Dovecot Plugin

This plugin monitors a Dovecot mail server. It reports the number of active IMAP and POP3 sessions, together with the Dovecot version and host domain, so you can see how many mail clients are connected and spot unusual spikes.

Reported Metrics

MetricDescription
imapNumber of active IMAP sessions.
pop3Number of active POP3 sessions.
metaDovecot version and hostdomain, shown as information about the server.

The session counts are taken from doveadm who, which counts every open connection. A user with a phone and a laptop connected at the same time counts as two IMAP sessions. The values are the current numbers, not totals.

Requirements

  • Dovecot is installed and running.
  • doveadm and dovecot are installed. Check their paths with which doveadm dovecot. Usual paths are /usr/bin/doveadm and /usr/sbin/dovecot.

Allow the agent to run the Dovecot commands

The plugin runs three Dovecot commands through sudo: doveadm who, dovecot --version and dovecot --hostdomain. The agent can't type a password, so it needs a sudoers rule. Create /etc/sudoers.d/agent360-dovecot (mode 0440) with exactly these commands:

agent360 ALL=(root) NOPASSWD: /usr/bin/doveadm who, /usr/sbin/dovecot --version, /usr/sbin/dovecot --hostdomain

If which shows different paths, use those paths. Then check the file:

visudo -cf /etc/sudoers.d/agent360-dovecot

Don't allow doveadm with any arguments. A rule like agent360 ALL=(ALL) NOPASSWD: /usr/bin/doveadm lets the agent user read and delete users' mail, change their data, disconnect users and run other administrative commands as root. Listing the exact who command lets the agent only read the list of connected users.

Configure the plugin

Add the following lines to the /etc/agent360-custom.ini file:

[dovecot]
enabled = yes

There are no other options.

Test the plugin

Run the following command:

sudo -u agent360 agent360 test dovecot

The output should show imap, pop3 and meta. You can compare the numbers with sudo doveadm who. Then restart the agent for the change to take effect:

service agent360 restart

Troubleshooting

  • imap and pop3 are 0, or the version is empty, although users are connected. The plugin can't tell a failed command from no sessions, so a missing sudoers rule or a stopped Dovecot also shows 0. Run the commands as the agent user:
    sudo -u agent360 sudo /usr/bin/doveadm who
    sudo -u agent360 sudo /usr/sbin/dovecot --version
    • If it asks for a password or says it's not allowed, fix the sudoers rule. The path and arguments have to match exactly.
    • If the command isn't found, check the path with which doveadm dovecot.
    • If doveadm who shows no users, then no sessions are open.
  • The numbers are higher than the number of users. Every connection is counted, and one user can have several, for example from different devices.
  • No data in the dashboard. Make sure the [dovecot] section is in /etc/agent360-custom.ini, enabled = yes, and that you restarted the agent.

Did this page help you?