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
| Metric | Description |
|---|---|
imap | Number of active IMAP sessions. |
pop3 | Number of active POP3 sessions. |
meta | Dovecot 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.
doveadmanddovecotare installed. Check their paths withwhich doveadm dovecot. Usual paths are/usr/bin/doveadmand/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-dovecotDon't allow
doveadmwith any arguments. A rule likeagent360 ALL=(ALL) NOPASSWD: /usr/bin/doveadmlets the agent user read and delete users' mail, change their data, disconnect users and run other administrative commands as root. Listing the exactwhocommand 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 = yesThere are no other options.
Test the plugin
Run the following command:
sudo -u agent360 agent360 test dovecotThe 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 restartTroubleshooting
imapandpop3are0, 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 shows0. 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 whoshows 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.
Updated about 15 hours ago