Glen Pitt-Pladdy :: Blog

Dovecot stats on Cacti (via SNMP)

As promised in the comments about the Postfix stats article, this posting kicks off support for Dovecot stats with Cacti, extending the original Postfix only stats.

This uses my Universal Log Analyser providing a plugin for Dovecot. You will need to get this installed and working before you can use the plugin here, and have it running from a cron job every 5 minutes (or whatever your sample times is for Cacti) so that it can parse the logs.

At this stage I am only producing stats for IMAP, but with the nice consistent log format it should be easy to add POP3 and SIEVE later.

Dovecot Plugin

Throw dovecot.pm in your plugin directory for the Universal Log Analyser, and add "dovecot" as a module to the command line so that this module gets loaded.

Download: Dovecot stats on Cacti tarball 20121115

Not much more to it than that. The remainder of the article assumes your stats file is /var/local/snmp/mail so if it isn't you will need to tweak things to match your install.

It's worth checking the stats file to verify that dovecot stats are in fact being picked up by the plugin.

SNMP Scripts

First, ensure that your SNMP is configured and working as described in my SNMP basics article.

These provide the link for snmpd to pick up the stats and assuming they are in /etc/snmp the config in /etc/snmp/snmpd.conf is:

extend dovecotauth /etc/snmp/dovecot-stats-auth
extend dovecotdeliver /etc/snmp/dovecot-stats-deliver
extend dovecotimapcrypto /etc/snmp/dovecot-stats-imap-crypto
extend dovecotimapdata /etc/snmp/dovecot-stats-imap-data
extend dovecotimapdisconnect /etc/snmp/dovecot-stats-imap-disconnect
extend dovecotimaplogin /etc/snmp/dovecot-stats-imap-login
extend dovecotimaploginmethod /etc/snmp/dovecot-stats-imap-loginmethod
extend dovecotimaploginmethod /etc/snmp/dovecot-stats-imap-loginmethod
extend dovecotpop3crypto /etc/snmp/dovecot-stats-pop3-crypto
extend dovecotpop3data /etc/snmp/dovecot-stats-pop3-data
extend dovecotpop3disconnect /etc/snmp/dovecot-stats-pop3-disconnect
extend dovecotpop3login /etc/snmp/dovecot-stats-pop3-login
extend dovecotpop3loginmethod /etc/snmp/dovecot-stats-pop3-loginmethod
extend dovecotpop3loginmethod /etc/snmp/dovecot-stats-pop3-loginmethod
extend dovecotmanagesievecrypto /etc/snmp/dovecot-stats-managesieve-crypto
extend dovecotmanagesievedata /etc/snmp/dovecot-stats-managesieve-data
extend dovecotmanagesiedisconnect /etc/snmp/dovecot-stats-managesieve-disconnect
extend dovecotmanagesielogin /etc/snmp/dovecot-stats-managesieve-login
extend dovecotmanagesieloginmethod /etc/snmp/dovecot-stats-managesieve-loginmethod
extend dovecotmanagesieloginmethod /etc/snmp/dovecot-stats-managesieve-loginmethod
extend dovecotsessions /etc/snmp/dovecot-stats-sessions

Extension scripts for snmpd are named dovecot-stats-* - put them in a suitable place.... like /etc/snmp

You should be able to run these scripts manually and they should spit back the current info from the stats file. Remember to restart snmpd so that the new config is picked up and we should be ready to go.

Cacti Template

Import this into your Cacti and add graphs as usual.

After that, assuming everything is working then after a couple data samples content should start to appear on the graphs.

If not then check the data at each step: the stats file, SNMP scripts, snmpwalk from the Cacti server, check Cacti Poller log for errors, and try Cacti in debug mode for graphs and data sources to see if that shows anything.

I will post example graphs once my ones are mature enough to have some useful data on them.

The Graphs

Dovecot Crytogrphy Stats with Cacti

Dovecot Data Stats with Cacti

Dovecot Disconnect Stats with Cacti

Dovecot Login Stats with Cacti

Dovecot Login Stats with Cacti

Dovecot Auth Error Stats with Cacti

Dovecot Delivery Stats with Cacti

Comments:

Glen Pitt-Pladdy Image  30/08/2011 08:15 :: Glen Pitt-Pladdy

See some comments on the SNMP basics post regarding tweaking this plugin for different format (dedicated) logs on different systems.

Daniele Palumbo Image  08/02/2012 17:12 :: Daniele Palumbo

hi,

i have this errors:

unknown dovecot: Feb 5 04:03:00 mail dovecot: POP3(xxx@domain.it): Disconnected: Logged out top=0/0, retr=0/0, del=0/0, size=0

unknown dovecot: Feb 8 15:22:58 mail dovecot: pop3-login: Aborted login (auth failed, 1 attempts): user=<postmaster@domain.it>, method=PLAIN, rip=XX.XXX.XXX.X, lip=XXX.XXX.X.XX

the version is:

20110626 (the last i guess).

thanks,

Daniele

Glen Pitt-Pladdy Image  08/02/2012 19:58 :: Glen Pitt-Pladdy

Thanks for the report - I had not tested pop3 on a live setup as my servers only run imap so it is really useful to get these reports. I have released a new version tonight which should understand these lines and adds an additional "login Aborted" graph.

Let me know if you discover any further lines it does not understand.

Daniele Palumbo Image  09/02/2012 15:48 :: Daniele Palumbo

Hi again,

seems only that two errors for dovecot (i will look later at postfix, but anyway strings does not go to stderr).

Instead, i've found a bug in the template, it look for "dovecotpop3isconnect" instead of "dovecotpop3disconnect".

I have already patched the file, but how can i send it to you?

Thanks,

Daniele

Glen Pitt-Pladdy Image  09/02/2012 16:08 :: Glen Pitt-Pladdy

Good to hear that the scripts are working better.

Cacti can be have problems re-importing templates so it's best I make the changes in cacti and re-export the templates. I have found the typos you spotted (well done!) and have released a new template. The new template should have a MD5 checksum of 6e8f655721539da3d17c2a7f22e0b23d - if you keep getting the old one then you may need to force reload without cache (shift-F5 in many browsers).

Alex Image  25/07/2012 18:42 :: Alex

Jul 25 18:22:03 XXXXX dovecot: auth-worker(default): mysql: Connected to localhost (XXXXX)

I don't speak enough PERL for adding the needed code. :(

Can you build an update, please?

Mny Tnx

Alex

Glen Pitt-Pladdy Image  26/07/2012 16:48 :: Glen Pitt-Pladdy

Thanks for submitting the unhandled line. I've just released version 20120726 which should handle those lines.

Tomek Image  03/06/2013 20:13 :: Tomek

Hi, I have one more unhandled line:

Jun 3 20:38:14 chaos dovecot: pop3-login: Login: user=<tomek>, method=PLAIN, rip=192.168.0.135, lip=xx.xx.xx.xx, mpid=24423, TLS, session=<ur1xRETeEADAqACH>

Please help :)




Are you human? (reduces spam)
Note: Identity details will be stored in a cookie. Posts may not appear immediately