+ Post New Thread
Results 1 to 9 of 9
*nix Thread, nagios email and cell notifications in Technical; Hello Forum: I am trying to set up nagios to send email and text (to cell phone) notifications. I have ...
  1. #1

    Join Date
    Nov 2008
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    nagios email and cell notifications

    Hello Forum:

    I am trying to set up nagios to send email and text (to cell phone) notifications.
    I have installed nagios 3.0.3 on Centos 5 and it is working well. I also installed ssmtp.

    Regarding the ssmtp.conf file, I am not sure if I have it configured correctly.
    These are my settings in the ssmtp.conf file:

    mailhub=me@myemail.com
    RewriteDomain=nagios monitoring system
    hostname=penguin
    I tried the following from the command line, but nothing happens:

    [root@penguin ssmtp]# mail -s "Test" root
    Cc: me@myemail.com.
    Null message body; hope that's ok
    You have new mail in /var/spool/mail/root

    My command.cfg is as follows:

    define command{
    command_name notify-host-by-email
    command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/ssmtp -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
    }


    define command{
    command_name notify-service-by-email
    command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/ssmtp -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
    }

    I have looked at various threads about this, but none really explains me how to get this working. Some of the threads I have seen are:

    Nagios -> Email Arghhhh! by ICTNUT

    Re: Installing Nagios... what do you want to know?

    and
    Quick Nagios Problem


    Please someone help me.
    Thanks.
    wbens

  2. #2


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    I tried the following from the command line, but nothing happens:

    [root@penguin ssmtp]# mail -s "Test" root
    Cc: me@myemail.com.
    Null message body; hope that's ok
    You have new mail in /var/spool/mail/root
    something did happen, you have an empty email in /var/spool/mail/root
    have a look by reading that file ( cat /var/spool/mail/root )

    If it looks like your getting what you want then you probably just need to setup your Mail Transfer Agent (MTA) The default is sendmail on centos, but I usually replace it with postfix.

    yum remove sendmail
    yum install postfix

    take a look here
    Postfix Basic Configuration
    you probably just need to configure a relay (relayhost = xxx.xxx.xxx.xxx) in main.cf and maybe add an alias in /etc/aliases but it will depend on your local config. sorry I can't remember sendmail, and I don't know about ssmtp

    edit: ok I just googled ssmtp, try the cat /var/spool/mail/root to see if nagios is ok
    Last edited by CyberNerd; 13th November 2008 at 10:21 PM.

  3. #3

    Join Date
    Nov 2008
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hello there:

    Thanks for your response.
    I am trying to get emails using both ssmtp or mailx. Whichever works first, I am sticking to it.

    This is what I am running on the command line as a test:

    [root@penguin etc]# /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: NOTIFICATIONTYPE\nHost: HOSTNAME\nState: HOSTSTATE\nAddress: HOSTADDRESS\nInfo: HOSTOUTPUT\n\nDate/Time: LONGDATETIME\n" | /bin/mail -s "** NOTIFICATIONTYPE Host Alert: HOSTNAME is HOSTSTATE **" willie@myemail.com
    [root@penguin etc]#


    This does not show any errors. It just returns to the prompt.

    Using ssmtp, this is what I get:

    [root@penguin etc]# /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: NOTIFICATIONTYPE\nHost: HOSTNAME\nState: HOSTSTATE\nAddress: HOSTADDRESS\nInfo: HOSTOUTPUT\n\nDate/Time: LONGDATETIME\n" | /usr/sbin/ssmtp -s "** NOTIFICATIONTYPE Host Alert: HOSTNAME is HOSTSTATE **" willie@myemail.com
    ssmtp: Cannot open willie@myemail:25
    [root@penguin etc]#
    I am completely clueless. Please, please, please help.

  4. #4

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,697
    Thank Post
    664
    Thanked 1,632 Times in 1,460 Posts
    Rep Power
    423
    ssmtp: Cannot open willie@myemail:25

    Should that not relate to your upstream smtp relay and not an email address?

    Ben

  5. #5


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    probably the ssmtp is broken, as plexer says - you need to point ssmtp (or whatever) at the smtp relay in order for you to be able to send email.


    when this works, the nagios should to.

    Code:
    /usr/sbin/ssmtp -s TEST willie@myemail.com < /dev/null

  6. #6

    Join Date
    Oct 2008
    Location
    Hedge End, Southampton
    Posts
    56
    Thank Post
    1
    Thanked 10 Times in 10 Posts
    Rep Power
    13
    Indeed, your MTA is unconfigured, you need to fix that first before nagios is going to be able to send you mail.

    Currently you're sendmail is doing local mail only, you'll probably want to configure it to use a smarthost (unless you can make direct SMTP connections). If you stick with sendmail edit /etc/mail/sendmail.mc, find the line which looks something like:
    Code:
    dnl # Uncomment and edit the following line if your outgoing mail needs to
    dnl # be sent out through an external mail server:
    dnl # 
    define(`SMART_HOST',`some.smart.host')
    And edit it with your smarthost, for instance I've got:
    Code:
    define(`SMART_HOST',`mail.wildern.hants.sch.uk')
    You then need to compile(?) your config using m4, do something like:
    Code:
    jim@veestar:~$ m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
    Then reload the MTA config
    Code:
    jim@veestar:~$ /etc/init.d/sendmail reload
    Incidentily, nagios should send you mail out of the box if your MTA is working, and you might want to specify some aliases.

    Code:
    jim@veestar:~$ cat /etc/aliases | grep root
    ...
    root:           serverlogs@wildern.hants.sch.uk
    And use
    Code:
    newaliases
    to load the modifications.

  7. #7

    Join Date
    Nov 2008
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hello Guys:

    Thanks a lot for your feedback on this matter. I have followed your instructions, but I think it is not yet working.

    Here are the things I have done on the command line:

    [root@penguin mail]# /etc/init.d/sendmail reload
    reloading sendmail: [ OK ]
    reloading sm-client: [ OK ]
    [root@penguin mail]# /usr/sbin/ssmtp -s TEST willie@myemail.com < /dev/null
    ssmtp: Cannot open willie@myemail.com:25
    I then check on port 25:

    [root@penguin mail]# lsof -i tcp:25
    COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
    sendmail 25003 root 4u IPv4 6455510 TCP penguin.com:smtp (LISTEN)
    and killed the process:

    [root@penguin mail]# kill -9 25003
    Same result again:

    [root@penguin mail]# /usr/sbin/ssmtp -s TEST willie@myemail.com < /dev/null
    ssmtp: Cannot open willie@myemail.com:25
    Check on port 25, and nothing was listening on it:

    [root@penguin mail]# lsof -i tcp:25
    Restarted services:

    [root@penguin mail]# /etc/init.d/sendmail restart
    Shutting down sm-client: [ OK ]
    Shutting down sendmail: [FAILED]
    Starting sendmail: [ OK ]
    Starting sm-client: [ OK ]
    Check on port 25 one more time, and things were listening on it:

    [root@penguin mail]# lsof -i tcp:25
    COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
    sendmail 25074 root 4u IPv4 6456172 TCP penguin.com:smtp (LISTEN)
    sendmail 25075 root 10u IPv6 6456209 TCP penguin.com:tappi-boxnet->mx00.perfora.net:smtp (ESTABLISHED)
    sendmail 25075 root 11u IPv6 6456209 TCP penguin.com:tappi-boxnet->mx00.perfora.net:smtp (ESTABLISHED)
    sendmail 25075 root 12u IPv6 6456213 TCP penguin.com:maincontrol->mx01.perfora.net:smtp (ESTABLISHED)
    sendmail 25075 root 15u IPv6 6456213 TCP penguin.com:maincontrol->mx01.perfora.net:smtp (ESTABLISHED)
    Followed one of your commands and got the ssmtp: Cannot open willie@myemail.com:25 response:

    [root@penguin mail]# /usr/sbin/ssmtp -s TEST willie@myemail.com < /dev/null
    ssmtp: Cannot open willie@myemail.com:25
    I then tried testing this nagios command:

    [root@penguin mail]# /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: NOTIFICATIONTYPE\nHost: HOSTNAME\nState: HOSTSTATE\nAddress: HOSTADDRESS\nInfo: HOSTOUTPUT\n\nDate/Time: LONGDATETIME\n" | /bin/mail -s "** NOTIFICATIONTYPE Host Alert: HOSTNAME is HOSTSTATE **" willie@myemail.com
    [root@penguin mail]#
    However, I did not get any email.

    This is my sendmail.cf file:

    divert(-1)dnl
    dnl #
    dnl # make -C /etc/mail
    dnl #
    include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
    VERSIONID(`setup for linux')dnl
    OSTYPE(`linux')dnl
    dnl #
    dnl # Do not advertize sendmail version.
    dnl #
    dnl define(`confSMTP_LOGIN_MSG', `$j Sendmail; $b')dnl
    dnl define(`confLOG_LEVEL', `9')dnl
    dnl define(`SMART_HOST', `smtp.1and1.com')dnl

    define(`confDEF_USER_ID', ``8:12'')dnl
    dnl define(`confAUTO_REBUILD')dnl
    define(`confTO_CONNECT', `1m')dnl
    define(`confTRY_NULL_MX_LIST', `True')dnl
    define(`confDONT_PROBE_INTERFACES', `True')dnl
    define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl
    define(`ALIAS_FILE', `/etc/aliases')dnl
    define(`STATUS_FILE', `/var/log/mail/statistics')dnl
    define(`UUCP_MAILER_MAX', `2000000')dnl
    define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
    define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
    define(`confAUTH_OPTIONS', `A')dnl

    dnl define(`confAUTH_OPTIONS', `A p')dnl

    dnl TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

    dnl define(`confCACERT_PATH', `/etc/pki/tls/certs')dnl
    dnl define(`confCACERT', `/etc/pki/tls/certs/ca-bundle.crt')dnl
    dnl define(`confSERVER_CERT', `/etc/pki/tls/certs/sendmail.pem')dnl
    dnl define(`confSERVER_KEY', `/etc/pki/tls/certs/sendmail.pem')dnl

    dnl define(`confDONT_BLAME_SENDMAIL', `groupreadablekeyfile')dnl

    dnl define(`confTO_QUEUEWARN', `4h')dnl
    dnl define(`confTO_QUEUERETURN', `5d')dnl
    dnl define(`confQUEUE_LA', `12')dnl
    dnl define(`confREFUSE_LA', `18')dnl
    define(`confTO_IDENT', `0')dnl
    dnl FEATURE(delay_checks)dnl
    FEATURE(`no_default_msa', `dnl')dnl
    FEATURE(`smrsh', `/usr/sbin/smrsh')dnl
    FEATURE(`mailertable', `hash -o /etc/mail/mailertable.db')dnl
    FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
    FEATURE(redirect)dnl
    FEATURE(always_add_domain)dnl
    FEATURE(use_cw_file)dnl
    FEATURE(use_ct_file)dnl

    dnl define(`confMAX_DAEMON_CHILDREN', `20')dnl
    dnl define(`confCONNECTION_RATE_THROTTLE', `3')dnl

    FEATURE(local_procmail, `', `procmail -t -Y -a $h -d $u')dnl
    FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl
    FEATURE(`blacklist_recipients')dnl
    EXPOSED_USER(`root')dnl

    dnl define(`confLOCAL_MAILER', `cyrusv2')dnl
    dnl define(`CYRUSV2_MAILER_ARGS', `FILE /var/lib/imap/socket/lmtp')dnl

    DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
    dnl DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl

    dnl DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl
    dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')dnl

    dnl DAEMON_OPTIONS(`Name=MTA-v4, Family=inet, Name=MTA-v6, Family=inet6')
    FEATURE(`accept_unresolvable_domains')dnl

    dnl FEATURE(`relay_based_on_MX')dnl
    LOCAL_DOMAIN(`localhost.localdomain')dnl

    dnl MASQUERADE_AS(`mydomain.com')dnl
    dnl FEATURE(masquerade_envelope)dnl
    dnl FEATURE(masquerade_entire_domain)dnl

    dnl MASQUERADE_DOMAIN(localhost)dnl
    dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
    dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
    dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
    MAILER(smtp)dnl
    MAILER(procmail)dnl
    dnl MAILER(cyrusv2)dnl
    I followed all the steps you guys instructed me. Do you have any idea as to why this is not working yet?

    Thanks guys.
    --Willie
    Last edited by wbens; 14th November 2008 at 11:47 PM.

  8. #8

    Join Date
    Nov 2008
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hello again:

    I have made a couple of changes on my ssmtp.conf file. Here they are:

    root=admin
    mailhub=smtp.1and1.com
    RewriteDomain=1and1.com
    FromLineOverride=YES
    Then I restart sendmail, and when I ran the command, here is the response I got:
    [root@penguin ssmtp]# /usr/sbin/ssmtp -s TEST willie@myemail.com < /dev/null
    ssmtp: RCPT TO:<TEST@1and1.com> (550 must be authenticated)
    I will google for this to see what I come up with, but if you have any ideas, please let me know.

    Thanks.

  9. #9

    Join Date
    Nov 2008
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hello Guys:

    This is to let you know that I am getting email sent from nagios to my hotmail address. However, when I send to my outlook address (my email at work), I do not get anything. I guess that should be a problem with my outlook configuration.

    Now, I am working on getting messages sent to cell phones. If you have any suggestions on this, please let me know.

    Thanks.
    --Willie

SHARE:
+ Post New Thread

Similar Threads

  1. Nagios -> Email Arghhhh!
    By ICTNUT in forum *nix
    Replies: 15
    Last Post: 27th April 2009, 10:41 AM
  2. Moodle forum and 60,000 email notifications
    By CyberNerd in forum Virtual Learning Platforms
    Replies: 1
    Last Post: 10th November 2008, 10:33 PM
  3. Cell Phone signal.
    By laserblazer in forum General Chat
    Replies: 10
    Last Post: 27th June 2008, 09:12 AM
  4. Excel Cell colour changes
    By wesleyw in forum How do you do....it?
    Replies: 3
    Last Post: 20th December 2006, 10:01 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •