use external smtp server nagios alert.pdf

Embed Size (px)

Citation preview

  • 8/10/2019 use external smtp server nagios alert.pdf

    1/8

    Rico's Tech Memoabout programming, computer & stuff

    HomeAbout Me

    Type text to search here... Home > nagios , sendEmail > Use external smtp server to send nagios alerts

    Use external smtp server to send nagios alerts

    April 18, 2012 ricoch3n Leave a comment Go to comments

    By default Nagios uses localhost to send out email, this would be a problem if the nagios servers IP isnot designated to send emails. A quick solution is to use utilities that support sending emails throughexternal smtp server, heres a nice one:

    http://caspian.dotconf.net/menu/Software/SendEmail/

    Steps (Assuming Nagios version is 3):1) Download the zip file from http://caspian.dotconf.net/menu/Software/SendEmail/#download , unzipand copy sendEmail.pl to /usr/local/bin

    2) Modify comm ands.c fg so the notif y-host-by-ema il and notify-service-by-email are similar to the

    followings:define command{command_name notify-host-by-emailcommand_ li ne /u s r/bin/p rintf "%b" "***** Nagios *****\n\nNotification Type:$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo:$HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -fnagios_notification@your_domain.com -s smtp.server.ip_or_hostname -u "** $NOTIFICATIONTYPE$Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -t $CONTACTEMAIL$}

    define command{command_name notify-service-by-emailcommand_line /usr/bin/printf "%b " "***** Nagios *****\n\nNotification Type:$NOTIFICATIONTYPE$\n\nService: $ SERVICEDESC$\nHost: $HOSTALIAS$\nAddress:$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditionalInfo:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -f nagios_notification@your_domain.com -ssmtp.server.ip_or_hostname -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$is $SERVICESTATE$ **" -t $CONTACTEMAIL$}

    change nagios_notification@your_domain.com and smtp.server.ip_or_hostname to suit your need of course. Consult http://caspian.dotconf.net/menu/Software/SendEmail/#download for more command lineoptions if the smtp server requires authentication, for example.

    3) Make sure the new configuration is syntax-error free:

    http://ricochen.wordpress.com/author/ricoch3n/http://ricochen.wordpress.com/http://ricochen.wordpress.com/category/nagios/http://ricochen.wordpress.com/category/sendemail/http://ricochen.wordpress.com/http://ricochen.wordpress.com/http://caspian.dotconf.net/menu/Software/SendEmail/#downloadhttp://caspian.dotconf.net/menu/Software/SendEmail/#downloadhttp://caspian.dotconf.net/menu/Software/SendEmail/http://ricochen.wordpress.com/author/ricoch3n/http://ricochen.wordpress.com/category/sendemail/http://ricochen.wordpress.com/category/nagios/http://ricochen.wordpress.com/http://ricochen.wordpress.com/about-me/http://ricochen.wordpress.com/http://ricochen.wordpress.com/
  • 8/10/2019 use external smtp server nagios alert.pdf

    2/8

    You May Like

    1.

    Like

    Be the first to like this.

    Follow

    Follow Rico's TechMemoGet every new post deliveredto your Inbox.

    Enter your email address

    Sign me up

    Powered by WordPress.com

    https://wordpress.com/?ref=lofhttp://void%280%29/http://wallstcheatsheet.com/entertainment/10-actors-who-died-during-production.html/
  • 8/10/2019 use external smtp server nagios alert.pdf

    3/8

    hi,m not having /var/log/sendEmail file . do i need to create dis.

    ricoch3nJanuary 8, 2013 at 7:12 amReply

    Please see my note #1, you only need to do this if you need to debug.

    3.adarshJanuary 8, 2013 at 8:13 amReply

    my %conf = (## General

    programName => $0, ## The name of this programversion => 1.56, ## The version of this programauthorName => Brandon Zehm, ## Authors NameauthorEmail => [email protected], ## Authors Email Addresstimezone => +0000, ## We always use +0000 for the time zonehostname => changeme, ## Used in printmsg() for all output (is updated later in the script).debug => 0, ## Default debug levelerror => , ## Error messages will often be stored here

    ## Loggingstdout => 1,logging => 0, ## If this is true the printmsg function prints to the log filelogfile => , ## If this is specified (form the command line via -l) this file will be used for logging.

    ## Network server => localhost, ## Default SMTP server port => 25, ## Default portbindaddr => , ## Default local bind addressalarm => , ## Default timeout for connects and reads, this gets set from $opt{timeout}tls_client => 0, ## If TLS is supported by the client (us)tls_server => 0, ## If TLS is supported by the remote SMTP server

    ## Emaildelimiter => -MIME delimiter for sendEmail- ## MIME Delimiter . rand(1000000), ## Add some randomness to the delimiter Message-ID => rand(1000000) . -sendEmail, ## Message-ID for email header

    );

    This is my /var/log/sendmail.pl file. could you pls tell in detail that where do i need to edit.I m new to this.

    http://ricochen.wordpress.com/2012/04/18/use-external-smtp-server-to-send-nagios-alerts/?replytocom=1016#respondhttp://ricochen.wordpress.com/2012/04/18/use-external-smtp-server-to-send-nagios-alerts/?replytocom=1015#respondhttp://ricochen.wordpress.com/
  • 8/10/2019 use external smtp server nagios alert.pdf

    4/8

    Thanks in advance.

    ricoch3nJanuary 9, 2013 at 5:39 amReply

    logging => 1, ## If this is true the printmsg function prints to the log filelogfile => /var/log/sendEmail, ## If this is specified (form the command line via -l) thisfile will be used for logging.

    Make sure /var/log/sendEmail exists and its mode is set to 666(touch /var/log/sendEmail &&chmod 666 /var/log/sendEmail).

    4. prashanthiMarch 14, 2013 at 1:08 pm

    Reply

    I have done the ablve the steps and able to run sendEmail. But even when i stopped nagios servicealso sendEmail is not giving any errors and it is able to send the mails.Please help me in understanding this.

    ricoch3nMarch 16, 2013 at 12:22 pmReply

    I dont understand what you meant by But even when i stopped nagios service alsosendEmail is not giving any errors and it is able to send the mails. Did you mean that after you shut down nagios, you are getting mail from sendEmail? If so, by what sender? Werethey real alerts generated by nagios before you shutdown nagios process? How did youshutdown nagios? Can you verify that its shutdown successfully? If sendMail is sending outemail, whats wrong with that? Did you enable logging?

    1. No trackbacks yet.

    Leave a Reply

    How-to: Lower html email spam score using swift mailer backbone.js learning note [1]RSS feed

    Enter your comment here...

    http://ricochen.wordpress.com/feed/http://ricochen.wordpress.com/2012/04/05/backbone-js-learning-note-1/http://ricochen.wordpress.com/2012/04/19/how-to-lower-html-email-spam-score-using-swift-mailer/http://ricochen.wordpress.com/2012/04/18/use-external-smtp-server-to-send-nagios-alerts/?replytocom=1063#respondhttp://ricochen.wordpress.com/http://ricochen.wordpress.com/2012/04/18/use-external-smtp-server-to-send-nagios-alerts/?replytocom=1062#respondhttp://ricochen.wordpress.com/2012/04/18/use-external-smtp-server-to-send-nagios-alerts/?replytocom=1017#respondhttp://ricochen.wordpress.com/
  • 8/10/2019 use external smtp server nagios alert.pdf

    5/8

    Recent Posts

    Hackintosh iMessage login error fixUsing twilio without a public web server howtoA few zsh tricks Ive learned so far Mac OS X Lion zsh installation with brew guideArray min, max with CoffeescriptYet another must have node.js module underscore-cliCalling initialization function only once with this js trick

    Dualboot Mountain Lion + Ubuntu 12.04 LTS on the same hard drive howtoInstall node.js on Raspberry PI in two simple stepsInstall Postgres on Mac OS X Lion with homebrew howto

    Categories

    10.7.3androidapachearp_poisoning

    backbone.jsBash

    benchmarking boot_loader browser compatibilitycipher coffeescriptcrontabcsscustom_romdatabase

    Debiandebuggingdesktop_environmentdircolor directfbdjangodual displayemailingfile copyflotgdb

    http://ricochen.wordpress.com/category/gdb/http://ricochen.wordpress.com/category/flot/http://ricochen.wordpress.com/category/file-copy/http://ricochen.wordpress.com/category/emailing/http://ricochen.wordpress.com/category/dual-display/http://ricochen.wordpress.com/category/django/http://ricochen.wordpress.com/category/directfb/http://ricochen.wordpress.com/category/dircolor/http://ricochen.wordpress.com/category/desktop_environment/http://ricochen.wordpress.com/category/debugging/http://ricochen.wordpress.com/category/debian/http://ricochen.wordpress.com/category/database/http://ricochen.wordpress.com/category/custom_rom/http://ricochen.wordpress.com/category/css/http://ricochen.wordpress.com/category/crontab/http://ricochen.wordpress.com/category/coffeescript/http://ricochen.wordpress.com/category/cipher/http://ricochen.wordpress.com/category/browser-compatibility/http://ricochen.wordpress.com/category/boot_loader/http://ricochen.wordpress.com/category/benchmarking/http://ricochen.wordpress.com/category/bash/http://ricochen.wordpress.com/category/backbone-js/http://ricochen.wordpress.com/category/arp_poisoning/http://ricochen.wordpress.com/category/apache/http://ricochen.wordpress.com/category/android/http://ricochen.wordpress.com/category/10-7-3/http://ricochen.wordpress.com/2012/07/20/install-postgres-on-mac-os-x-lion-with-homebrew-howto/http://ricochen.wordpress.com/2012/07/24/install-node-js-on-raspberry-pi-in-two-simple-steps/http://ricochen.wordpress.com/2012/09/04/dualboot-mountain-lion-ubuntu-12-04-lts-on-the-same-hard-drive-howto/http://ricochen.wordpress.com/2012/09/12/calling-initialization-function-only-once-with-this-js-trick/http://ricochen.wordpress.com/2012/09/12/yet-another-must-have-node-js-module-underscore-cli/http://ricochen.wordpress.com/2012/09/19/array-min-max-with-coffeescript/http://ricochen.wordpress.com/2012/09/30/mac-os-x-lion-zsh-installation-with-brew-guide/http://ricochen.wordpress.com/2012/09/30/a-few-zsh-tricks-ive-learned-so-far/http://ricochen.wordpress.com/2012/10/07/using-twilio-without-a-public-web-server-howto/http://ricochen.wordpress.com/2013/02/21/hackintosh-imessage-login-error-fix/
  • 8/10/2019 use external smtp server nagios alert.pdf

    6/8

    http://ricochen.wordpress.com/category/spam-score/http://ricochen.wordpress.com/category/socket-io/http://ricochen.wordpress.com/category/shinken/http://ricochen.wordpress.com/category/sheevaplug/http://ricochen.wordpress.com/category/sendemail/http://ricochen.wordpress.com/category/security/http://ricochen.wordpress.com/category/ruby/http://ricochen.wordpress.com/category/rsync/http://ricochen.wordpress.com/category/rounded_corner/http://ricochen.wordpress.com/category/redis/http://ricochen.wordpress.com/category/rdiff/http://ricochen.wordpress.com/category/raspberry-pi/http://ricochen.wordpress.com/category/python/http://ricochen.wordpress.com/category/programming/http://ricochen.wordpress.com/category/postgresql/http://ricochen.wordpress.com/category/plugcomputer/http://ricochen.wordpress.com/category/phpredis/http://ricochen.wordpress.com/category/php/http://ricochen.wordpress.com/category/perl/http://ricochen.wordpress.com/category/pdf/http://ricochen.wordpress.com/category/password-generator/http://ricochen.wordpress.com/category/oracle/http://ricochen.wordpress.com/category/openvpn/http://ricochen.wordpress.com/category/nvm/http://ricochen.wordpress.com/category/node-js/http://ricochen.wordpress.com/category/networking/http://ricochen.wordpress.com/category/nagios/http://ricochen.wordpress.com/category/mysql/http://ricochen.wordpress.com/category/mqseries/http://ricochen.wordpress.com/category/moutain-lion/http://ricochen.wordpress.com/category/mountain-lion/http://ricochen.wordpress.com/category/mac-osx/http://ricochen.wordpress.com/category/mac/http://ricochen.wordpress.com/category/lion/http://ricochen.wordpress.com/category/linux/http://ricochen.wordpress.com/category/jslint/http://ricochen.wordpress.com/category/jquery/http://ricochen.wordpress.com/category/javascript/http://ricochen.wordpress.com/category/imessage/http://ricochen.wordpress.com/category/html2text/http://ricochen.wordpress.com/category/html/http://ricochen.wordpress.com/category/hp-probook/http://ricochen.wordpress.com/category/howto/http://ricochen.wordpress.com/category/homebrew/http://ricochen.wordpress.com/category/gtk/http://ricochen.wordpress.com/category/grub2/http://ricochen.wordpress.com/category/goodies/http://ricochen.wordpress.com/category/gnome/http://ricochen.wordpress.com/category/git/http://ricochen.wordpress.com/category/gentoo/
  • 8/10/2019 use external smtp server nagios alert.pdf

    7/8

    sqlsshsslswift_mailer tablesorter Terminaltime_synchronizationTip

    tmuxtony mac osxtunnelblick twilioubuntuUncategorizedunderscoreunsolvedvariable_substitutionvimvirtualboxweb developmentwebframework web_proxywgetwifi_tether windows7xcodeyiizsh

    Blogroll

    Blog at WordPress.com .Blog at WordPress.com .

    Archives

    February 2013October 2012September 2012

    July 2012June 2012May 2012April 2012March 2012February 2012January 2012December 2011

    November 2011October 2011September 2011

    http://ricochen.wordpress.com/2011/09/http://ricochen.wordpress.com/2011/10/http://ricochen.wordpress.com/2011/11/http://ricochen.wordpress.com/2011/12/http://ricochen.wordpress.com/2012/01/http://ricochen.wordpress.com/2012/02/http://ricochen.wordpress.com/2012/03/http://ricochen.wordpress.com/2012/04/http://ricochen.wordpress.com/2012/05/http://ricochen.wordpress.com/2012/06/http://ricochen.wordpress.com/2012/07/http://ricochen.wordpress.com/2012/09/http://ricochen.wordpress.com/2012/10/http://ricochen.wordpress.com/2013/02/https://wordpress.com/?ref=footer_bloghttps://wordpress.com/?ref=footer_bloghttp://ricochen.wordpress.com/category/zsh/http://ricochen.wordpress.com/category/yii/http://ricochen.wordpress.com/category/xcode/http://ricochen.wordpress.com/category/windows7/http://ricochen.wordpress.com/category/wifi_tether/http://ricochen.wordpress.com/category/wget/http://ricochen.wordpress.com/category/web_proxy/http://ricochen.wordpress.com/category/webframework/http://ricochen.wordpress.com/category/web-development/http://ricochen.wordpress.com/category/virtualbox/http://ricochen.wordpress.com/category/vim/http://ricochen.wordpress.com/category/variable_substitution/http://ricochen.wordpress.com/category/unsolved/http://ricochen.wordpress.com/category/underscore/http://ricochen.wordpress.com/category/uncategorized/http://ricochen.wordpress.com/category/ubuntu/http://ricochen.wordpress.com/category/twilio/http://ricochen.wordpress.com/category/tunnelblick/http://ricochen.wordpress.com/category/tony-mac-osx/http://ricochen.wordpress.com/category/tmux/http://ricochen.wordpress.com/category/tip/http://ricochen.wordpress.com/category/time_synchronization/http://ricochen.wordpress.com/category/terminal/http://ricochen.wordpress.com/category/tablesorter/http://ricochen.wordpress.com/category/swift_mailer/http://ricochen.wordpress.com/category/ssl/http://ricochen.wordpress.com/category/ssh/http://ricochen.wordpress.com/category/sql/
  • 8/10/2019 use external smtp server nagios alert.pdf

    8/8

    August 2011July 2011June 2011May 2011April 2011March 2011February 2011January 2011

    December 2010October 2010September 2010August 2010June 2010May 2010April 2010January 2010December 2009October 2009September 2009August 2009July 2009June 2009

    Meta

    Register Log in

    Top

    Blog at WordPress.com . The INove Theme .

    https://wordpress.com/themes/inove/https://wordpress.com/?ref=footer_bloghttps://ricochen.wordpress.com/wp-login.phphttps://en.wordpress.com/signup/?ref=wploginhttp://ricochen.wordpress.com/2009/06/http://ricochen.wordpress.com/2009/07/http://ricochen.wordpress.com/2009/08/http://ricochen.wordpress.com/2009/09/http://ricochen.wordpress.com/2009/10/http://ricochen.wordpress.com/2009/12/http://ricochen.wordpress.com/2010/01/http://ricochen.wordpress.com/2010/04/http://ricochen.wordpress.com/2010/05/http://ricochen.wordpress.com/2010/06/http://ricochen.wordpress.com/2010/08/http://ricochen.wordpress.com/2010/09/http://ricochen.wordpress.com/2010/10/http://ricochen.wordpress.com/2010/12/http://ricochen.wordpress.com/2011/01/http://ricochen.wordpress.com/2011/02/http://ricochen.wordpress.com/2011/03/http://ricochen.wordpress.com/2011/04/http://ricochen.wordpress.com/2011/05/http://ricochen.wordpress.com/2011/06/http://ricochen.wordpress.com/2011/07/http://ricochen.wordpress.com/2011/08/