Nagios Email Config with Qmail?


I have nagios up and running perfect, but I cannot get emails. The same server is a qmail server and I cannot switch to postfix unless for some reason I can run both if I have to for it to work with nagios. My commands.cfg file:

This is the config I was told I needed for qmail to work. However, no emails ever hit the logs. I can telnet on port 25 and send test emails, etc. All that works fine. Any advice on getting this working?


whgat happens if you run the following?

usr/bin/printf "%b" "test mail\n" | /var/qmail/bin/sendmail -s "test subject" [email protected]

and why is the command written twice in your quoted part?


with that above I get:

[email protected]:/var/log# usr/bin/printf "%b" "test mail\n" | /var/qmail/bin/sendmail -s "test subject" [email protected] bash: usr/bin/printf: No such file or directory sendmail: illegal option -- s sendmail: usage: sendmail -t ] -fsender ] -Fname ] -bp ] -bs ] arg ... ]

Not sure why it’s in there twice. How should it look?


ok we missed a / at the start of the line…

try /usr/bin/printf… :wink:

we also have a sendmail error about that -s flag so i’d try without it… sorry i don’t have alternatives to offer as i don’t have a Qmail install to try it…


similar error:

[email protected]:/var/log/qmail# /usr/bin/printf "%b" "test mail\n" | /var/qmail/bin/sendmail -s "test subject" [email protected]
sendmail: illegal option -- s
sendmail: usage: sendmail  -t ]  -fsender ]  -Fname ]  -bp ]  -bs ]  arg ... ]


As i said above, try removing the -s flag from the sendmail command and try playing arouns with the options until you can get a mail delivered… then you can rebould the nagios command from there.


okay that works, but you said something about it being in there twice?

usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /var/qmail/bin/sendmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ -> /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /var/qmail/bin/sendmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

i think that should be

usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /var/qmail/bin/sendmail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

keep in mind you need to correct the first missing slash and the sendmail command :slight_smile:


how do I modify the from email address? I don’t want it to be root.


have fun with the qmail documentation… :slight_smile:


okay so I see it hit the log but I never get the email. I am relaying to the exchange server and this works because I can telnet on port 25 to that server from the nagios server and get the email. Thoughts?


It doens’t look like you want help anymore, it looks more like you want to be spoon fed.
Sorry, I have no time for that.

Read the logs. Use google. Help yourself.

And yes, i know i have a bad attitude dont’ bother telling me.


not sure how asking that question is asking to be spoon fed. Isn’t questions what forums are for? Then again, maybe that’s why your running phpbb3


this is not my forum. sorry to ruin your theory :slight_smile:


I’m not trying to cause a problem, are you done helping me? I brought down a AP that is my host and it never hits the logs. I would assume that means my commands.cfg is still no good. Oh and just so you know I don’t mind donating for your help :wink:


that’s not the point… you wouldn’t be donating to me so no need to tell me :stuck_out_tongue:

Why do i get some impression about being spoon fed? well let’s start from the missing slash in the beginnning of your command, then the part where you missed the -s flag plus the duplicate definition of the command. You have a qmail you can’t change but you don’t know how to set it up to work correctly… enough?

Anyway as i said i don’t know qmail. you need to look for a smarthost or relay configuration option, this might break your present configuration as you probably have something already running there…
Is nagios showing the host status correctly? is the mail getting in the queue? yuoou should see it in the logs. Do you get an error in the logs?


Now like I said before, it is relaying fine to the exchange server. I simply missed the slash, why bash me? I have the smarthost setup and it has been working since day one. Setting up nagios has nothing to do with configuring qmail. I simply need to know why the commands.cfg isn’t working when I see the alert in the nagios.



i thought you had that fixed.

if you got the email from command line there really isnothing more to do than modify your first command basing ont he command lien you used to send the mail.
tehre really were only two modifications… one slash and the removal of the -s flag…


yeah that is all done. I rebooted an AP that is being monitored. I saw the alert history show it was down and states from the gui that an email is sent. However, it never hits the server with an email. The command line works perfect.


Well, cehck the qmail logs and see where it hangs… not much more you can do.