dovecot: Use DERIVE to avoid ugly computations

Using a timed grep with a state computation is usually mostly wrong. The DERIVE
field type is specifically designed for that very purpose.

Closes #264
dovecot: avoid using sort & wc when grepping

egrep has the -c option, that does a wc -l.
Also, there's no need to sort the output prior counting it.