a nagios plugin for monitoring mail server statistics

mailgraph is a good tool at analysing mail server log, it supports many MTA(including sendmail, postfix, exim,etc.), with support for mailscanner,spamassassin,etc.

As a whole, mailgraph can tell mail server statistics like how many messages sent/ received/ bounced/ rejected/ virus/ spam per time interval, which can be used as a sign of mail server healthy.

This plugin includes a patch for mailgraph so that it will also output its statistics counter to an external file(plus the rra file),and a which check the stat counter to see if it’s ok, emit WARN/CRITICAl result if not.It can run on nagios server, or on remote server via NRPE.

see Readme file in the package for install instructions.


This entry was posted in Email, System Administration and tagged , , . Bookmark the permalink.

11 Responses to a nagios plugin for monitoring mail server statistics

  1. Sven P says:

    Hi There,

    a really cool Plugin :) But can you please add Performance Data Output so that i can graph the Mailstats with PNP4Nagios? That wourld be great.

    Thank you very much for that Script and your Answer :)


  2. Curu Wong says:

    I am glad that you like it. I have released the 0.9.1 version, which added perfdata output(and it includes a PNP4Nagios template).

  3. Dan Candea says:

    I made a pnp4nagios template which is similar with the one from mailgraph.cgi. Maybe you want to include it in the package. The data is displayed only in two graphs.

  4. Curu Wong says:

    There was a PNP4Nagios in v0.9.1.
    I want to have a look at your template first, but it seems I can’t get it from the provided link, it shows me a php error,would you please check that?

  5. Hi,
    I don’t use PNP4Nagios but I’m using Centreon
    I’ve modified this script to graph with Centreon
    On line 97 subsitute ” ” by “;”
    like that :
    Replace :

    my $perfdata = sprintf "sent=%-6.2f received=%-6.2f bounced=%-6.2f rejected=%-6.2f virus=%-6.2f spam=%-6.2f", @stat_counter;

    Par :

    my $perfdata = sprintf "sent=%-6.2f;received=%-6.2f;bounced=%-6.2f;rejected=%-6.2f;virus=%-6.2f;spam=%-6.2f", @stat_counter;

    Could you tell me if your script with this modification stay compatible with pnp4nagios ?

    If it’s true, could you update your plugin ?

    Thanks by advance.

  6. Curu Wong says:

    Hi, It may break PNP4Nagios if substitute ” ” by “;”
    Basically, PNP4Nagios uses the same logic as the perl module Nagios::Plugin::Performance when parsing performance data. Reading the source code of that module, you will find that blank character(including space) is used to seperate different perfdata metric, whereas semicolon(;) is used to seprate fields of a single metric.

    If you have read section 2.6 of the Nagios plug-in development guidelines, you will know the recommended format of perf data.

  7. Pingback: DBsysNet # Databases, Systems, Networks » Supervision de postfix via mailgraph avec le plugin via Nagios/Centreon

  8. Dan Candea says:

    @Curu Wong

    it tries to interpret the php. just acces the link without the script
    To save use the right side icon.

  9. Pingback: Databases, Systems, Networks » Supervision de postfix via mailgraph avec le plugin via Nagios/Centreon

  10. Chris says:

    Hi Curu,

    really good plugin :)
    Have you ever thought of writing a plugin for amavis-stats, which works in exactly the same way as your mailstat plugin?

    I think it would be nice, to see pnp drawing all the blocked viruses 😉


  11. Curu Wong says:

    sorry, but I don’t maintain any mail server now, and a little run out of time. maybe you can adjust the plugin for yourself.

Leave a Reply