LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 05-11-2009, 03:37 PM   #1
ZiPPygEEk
LQ Newbie
 
Registered: May 2009
Posts: 14

Rep: Reputation: 0
Setting up Nagios with Notification w/ Exchange/Postfix???


Hi all,

I've currently built out a server running Ubuntu and running Nagios on the server. I've managed to get Nagios up and running, but now I am tasked with setting up notifications.

How are people setting up notifications in Nagios when using Microsoft Exchange Server in there environment? I've been doing some Googling and found that people use MailX and Postfix and then forward(discussion in link below) but I'm not familiar in setting this up. As I am also new to Linux.

I know I will probably get flamed and told to Google more, but I keep finding forums with users posting there config files.

Any direction or advice would be much appreciated. I know my issue is still at large and vague, but I would like to discuss the setup with some other Nagios/Linux users.

http://ubuntuforums.org/showthread.php?t=917125


Cheers,

ZiPPy
 
Old 05-11-2009, 04:00 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
Basically you just tell your Mail Transport Agent (MTA) to "relay" to the Exchange server. Usually the Exchange administrator has to configure Exchange to allow such relaying. (It is not allowed by default to prevent spam.)

How to setup "relay" in the MTA depends on which one you're using. I use Sendmail since that's the one that comes with most UNIX/Linux OSes by default. Many prefer Postfix but if you're not receiving mail there seems little reason to use Postfix.

Some notes on Sendmail setup for relaying (first you have to let it relay to itself because by default it denies relay from local host [ip 127.0.0.1] to the public IP of the host.

Typically Sendmail configuration is in /etc/mail so if I mention a file it is likely there.

Prior to doing anything be sure you back up the directory to another location so you can revert back to where you started if it all goes wrong.

Stop sendmail if it is running (typically there is a sendmail init script to do this in /etc/rc.d/init.d.

First look at sendmail.mc and find line that says something like:
Code:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
Add another line just like it that has your public IP in place of 127.0.0.1 e.g.
Code:
DAEMON_OPTIONS(`Port=smtp,Addr=10.0.20.9, Name=MTA')dnl
Next locate the line in sendmail.mc similar to:
Code:
dnl define(`SMART_HOST', `smtp.your.provider')dnl
Remove the "dnl" from start of line (dnl = do not load) and add your Exhange server in place of smtp.your.provider so it looks similar to:
Code:
define(`SMART_HOST', `yourexhange.yourdomain')dnl
Also while you're add it add other names the Linux server is known by to the access file.
Typically it looks something like:
Code:
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
You'd want to add your fully qaulified domain name (FQDN) and short name to the file. So if your FQDN were yourlinux.yourdomain you'd end up with:
Code:
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
Connect:yourlinux                       RELAY
Connect:yourlinux.yourdomain            RELAY
Once you've finished edit of these files you'd run "make -C /etc/mail" (or whatever directory you found them in) to compile then. The sendmail.mc compile will end up in sendmail.cf and the access file will end up in access.db. Note that sendmail.cf does not have same format as sendmail.mc even though both are readable ascii type files. access.db is a binary hash of the access file.

You'd then want to restart sendmail.

Once you've done all that you should just set notifications in Nagios to use the email address of the intended users (e.g. billbob@yourdomain) and sendmail will relay to Exchange to find them.

Also note you can setup cheap paging from Nagios by sending email to phonenumber@providerdomain (vtext.com for Verizon for example). This sends a text message to the cell phone at the number you used.

Last edited by MensaWater; 05-12-2009 at 10:51 AM.
 
Old 05-12-2009, 03:51 PM   #3
ZiPPygEEk
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Thank you so much for the response jlightner, and the in-depth explanation. I've followed your instructions and successfully compiled. I've ran some tests that I found online to see if the email is being sent out successfully, but I'm having no luck.

What test do you recommend I do to verify if the email is indeed working? I've also changed the email address within Nagios, but still get nothing.

I have tried some CLI tests where I create a .txt file and email that via the command line.

I have tried # echo testing | mail -s bla myemail@domain.com

and I get the following error - null message body; hope that's ok

Any thoughts???

Thanks again for all your help and direction.


Cheers,

ZiPPy

Last edited by ZiPPygEEk; 05-12-2009 at 05:45 PM.
 
Old 05-13-2009, 08:58 AM   #4
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,770
Blog Entries: 4

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
I guess the first thing to verify is that you're running Sendmail. It may be installed but not running. (ps -ef |grep -i sendmail).

Secondly it doesn't make sense that you got the "null body" message. I did a test using your syntax here with both mail and mailx and it went through fine. Trying mailx instead of mail may help. I'd google the message if I were you to find out why it says that given that the body wasn't null (it should have contained the word "testing" since you piped that in). Also note that this didn't say the message failed - it simply said it had a null body - unless the Exchange server filters out null body messages as spam you still should have received it.

Check the mail logs which should be in /var/log to see what it tells you it did with the message. Also you can look in /var/spool/mqueue to see if the message is sitting there. (Note that sometimes you have to bounce sendmail to force it to reread the mqueue if it got hung up.)

You didn't mention the Exchange server - has the admin of that box opened it up to allow relay from the Nagios server?

A basic test of connectivity from Nagios server to Exchange can be done with this information I found found back in 2007 at:
www.yuk-onna.co.uk/email/smtp.html (link no longer seems to work)

Quote:
Telnet - SMTP Commands (sending mail using telnet)
In order to access your mailbox you will need 3 things:

* An active internet connection (an embarrasing stage to miss sometimes!)
* The address of a mail server capable of relaying for you - usually
provided by your dialup provider (e.g. mail.domain.ext)
* A valid email address (e.g. mail@domain.ext)

The first thing to do is to open a connection from your computer to your mail server.
telnet mail.domain.ext 25
You should receive a reply like:
Trying ???.???.???.???...
Connected to mail.domain.ext.
Escape character is '^]'.
220 mail.domain.ext ESMTP Sendmail ?version-number?; ?date+time+gmtoffset?

You will then need to declare where you are sending the email from:
HELO local.domain.name - dont worry too much about your local domain namealthough you really should use your exact fully qualified domain name as seen by the outside world the mail server has no choice but to take your word for it as of RFC822-RFC1123.
This should give you:
250 mail.domain.ext Hello local.domain.name [loc.al.i.p], pleased to meet you

Now give your email address:
MAIL FROM: mail@domain.ext
Should yeild:
250 2.1.0 mail@domain.ext... Sender ok
If it doesn't please see possible problems.

Now give the recipients address:
RCPT TO: mail@otherdomain.ext
Should yeild:
250 2.1.0 mail@otherdomain.ext... Recipient ok
If it doesn't please see possible problems.

To start composing the message issue the command DATA

If you want a subject for your email type Subject:-type subject here- then press enter twice (these are needed to conform to RFC 882)

You may now proceed to type the body of your message (e.g. hello
mail@otherdomain.ext from mail@domain.ext)

To tell the mail server that you have completed the message enter a single
"." on a line on it's own.
The mail server should reply with: 250 2.0.0 ???????? Message accepted for delivery

You can close the connection by issuing the QUIT command.
The mailserver should reply with something like:221 2.0.0 mail.domain.ext
closing connection
Connection closed by foreign host.


Here are a list of problems I've encountered and their fixes
501 nouser@nosuchplace.here... Sender domain must exist
The domain that you are sending from must exist

503 Need MAIL before RCPT
A recipient has been specified before a sender.

550 mail@domain.ext... Relaying Denied
The mail server has refused to relay mail for you, this may be for any number of reasons but typical resons include:
Not using this provider for an internet connection and/or
Not using an email address provided by the owner of the server.

Some things to watch out for:
1. If you type too quickly, sometimes it won't recognise your text (weird!)
2. The backspace key sometimes does not work with some telnet clients (even though it may seem as though it does)

I'll be putting more as and when I get them and figure out how to fix each
problem.
 
Old 05-14-2009, 06:25 PM   #5
ZiPPygEEk
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Sendmail was indeed running, the problem was with the firewall. I created a policy on our firewall to allow open access from the IP of the Nagios server. After I created that policy I started receiving emails.

Thank you so much for your help and direction!!


Cheers mate,

ZiPPy
 
Old 05-19-2009, 10:23 AM   #6
krasl
Member
 
Registered: Nov 2005
Distribution: Fedora 4
Posts: 38

Rep: Reputation: 15
Relay only specific users' mail

Hello. This question is somewhat related to my issue, but let me explain:

I run a webserver/mailserver hosting several different domains. Most of the domains' users are accessing their email via POP/SMTP (dovecot and sendmail) running on this server. However, specific domains wish to use Google's free Google Apps system for their mail. This requires that the MX DNS records be pointed to Google's servers instead of to the local server.
This works fine in most instances, but if a user on one of our domains sends an email to another of our users on a Google Apps domain, our server never tries to relay the message to the Google servers. Instead sendmail tries to deliver the message to the user's local mailbox.
This is causing headaches since it becomes necessary to check both our server's mailbox and the Google Apps mailbox for new mail.

Is there any way to configure Sendmail to relay all messages addressed to a particular domain? For example, any user [username]@xyz.com should NOT be delivered locally, *even if there exists a local user* matching this mailbox.

I tried adding the domain to the /etc/mail/mailertable file and restarting sendmail, but no difference was made.


I have attached my sendmail.mc file if this is helpful.

Running Fedora Core 4
Kernel 2.6.15-1.1833_FC4smp
Sendmail version 8.13.6
Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
TCPWRAPPERS USERDB USE_LDAP_INIT



Thank you!
Attached Files
File Type: txt sendmail.mc.txt (7.1 KB, 34 views)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
E-mail notification with Nagios Hiroyatamoto Linux - Newbie 7 06-30-2009 11:18 AM
Few questions about Nagios - reboot notification, value=x notification. marccmile Linux - Software 5 06-04-2009 06:44 PM
NAGIOS notification ny101880 Linux - Newbie 14 01-04-2009 01:10 AM
help in nagios notification packets Linux - Software 2 10-10-2008 01:01 PM
Nagios E-mail notification Hiroyatamoto Linux - General 5 07-02-2008 03:55 AM


All times are GMT -5. The time now is 05:29 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration