check_mailq of postfix in icinga2

Please read about the latest changes and upgrade.

Please note that your newly registered account needs to be manually activated by an admin. Just be patient, you cannot post to any forum before this happens. This is thanks to the unfortunate event of spammers recently. More details here.

  • I think this may be the old question but here it is. I want to check email queue of different servers from icinga2 server. what I did is


    Code
    1. icinga2 repository service add name=mailq host_name=example.com check_command=mailq
    2. icinga2 repository service add name=mailq host_name=example2.com check_command=mailq
    3. icinga2 repository commit
    4. icinga2 daemon -C
    5. systemctl reload icinga2


    It shows mailq empty as icinga2 server have no emails in queue but I want to check mailq of another servers (example.com, example2.com). There is no options like -H so that I can give hostname of another server.


    Code
    1. # /usr/lib64/nagios/plugins/check_mailq
    2. Usage: check_mailq -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose]

    * I do not use nrpe client.

  • If you have configured these servers as command endpoint it shouldn't be a problem:


    Define a apply rule for example:


    Code
    1. object Host "example.com" {
    2. import "std-host"
    3. address = "192.168.0.23"
    4. vars.os = "Linux"
    5. vars.client_endpoint = "example.com"
    6. }


    Link to doc: http://docs.icinga.org/icinga2…monitoring-master-clients

  • Thanks for reply. what I did was


    in icinga2 server:


    /etc/icinga2/conf.d/services.conf

    Code
    1. apply Service "mailq" {
    2. import "generic-service"
    3. check_command = "mailq"
    4. assign where host.name == NodeName
    5. }

    restarted icinga2


    inserted same in client server
    restarted icinga2


    Now I see following error:
    Error: Non-optional macro 'mailq_critical' used in argument '-c' is missing.


    I inserted following in /usr/share/icinga2/include/command-plugins.conf

    Code
    1. vars.mailq_warning = "100"
    2. vars.mailq_critical = "300"


    but it didn't solved it.


    I used your suggestion but it showed me errors.

  • I now inserted following in /etc/icinga2/conf.d/services.conf file and error is gone.


    vars.mailq_warning = "100"
    vars.mailq_critical = "300"


    But it is showing "mailq is ok" which is not. There are number of emails in queue and it is showing just OK.

  • I inserted following in /usr/share/icinga2/include/command-plugins.conf

    Please dont change the file at this location.


    you should add the parameters to the service apply:

    apply Service "mailq" {
    import "generic-service"
    check_command = "mailq"
    assign where host.name == NodeName
    }


    I used your suggestion but it showed me errors.

    What error did you got ?

  • @birkch @dnsmichi
    I totally forgot about this.


    Here is what I have done.


    In client server I have added following in /etc/icinga2/conf.d/services.conf


    Code
    1. apply Service "mailq" {
    2. import "generic-service"
    3. check_command = "mailq"
    4. assign where host.name == NodeName
    5. }



    In master server ran following command:


    Code
    1. # icinga2 node update-config


    and got following error:


    Error: Non-optional macro 'mailq_critical' used in argument '-c' is missing.


    I know I am missing vars.mailq_critical and vars.mailq_warning but where should I put it? Where should I put it so that it will be default for all other client servers'.


    Additional question: How s it possible to define default services so that whenever I install icinga2 for first time it will check all custom services I need (predefined services)

  • Here is what I did.


    Added variables in /etc/icinga2/conf.d/services.conf (in client server) - confused if this is right or not.

    Code
    1. apply Service "mailq" {
    2. import "generic-service"
    3. check_command = "mailq"
    4. assign where host.name == NodeName
    5. vars.mailq_warning = "100"
    6. vars.mailq_critical = "300"
    7. }


    check_mailq command was showing Mailqueue empty. Since we were using exim I replaced it with check_eximmailqueue
    inserted following at end of /etc/sudoers file


    Code
    1. Defaults:icinga !requiretty
    2. icinga ALL=NOPASSWD:/usr/sbin/exim

    restarted sshd and icinga2.



    One unusual thing is I am unable to forcefully check from icingaweb2 with "check_now".