Notifications

Extended PHP mails

Description:

Reliable and flexible way to do notifications to e-mail (via php-mail) without setup sendmail or postfix. You can turn off sendmail or postfix.

Current Version

1.0

Last Release Date

2016-09-14

Compatible With

  • Nagios 4.x

Owner


Project Files
Project Photos
Project Notes
Reliable and flexible way to do notifications to e-mail (via php-mail) without setup sendmail or postfix. 1. You can use different mailboxes and mail servers to notify different recipients. Just specify it in nagios templates (see below in Setup part). 2. You need only one script (nagios_mail2) to send messages as for hosts and for services. 3. Embeded links to nagios GUI for hosts and services (see screenshot). 4. Embeded field with Service or Host Notes (Visible if not empty). 5. Embeded pnp4nagios graph (Visible if exist for given service). 6. Successful and failed attempts log in /usr/local/nagios/var. Setup: 1. Download attached zip. It contains 3 files: class.phpmailer.php, class.smtp.php and nagios_mail2. 2. Extract archive and put these files to /usr/local/nagios/sbin (or where you want). 3. Give execute rights to nagios_mail2: # chmod +x /usr/local/nagios/sbin/nagios_mail2 # chown nagios:nagios /usr/local/nagios/sbin/nagios_mail2 4. Go to your commands.cfg and define command as I did: define command{ command_name notify-service-by-email-bs command_line /usr/local/nagios/sbin/nagios_mail2 "SERVICE" "nagios.mydomain.by:80" "nagios@mydomain.by" "smtp.mydomain.by" "587" "mailpw" "tls" "Nagios" "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$SERVICEOUTPUT$" "$SHORTDATETIME$" "$SERVICEDESC$" "$SERVICESTATE$" "$SERVICENOTES$" "$NOTIFICATIONRECIPIENTS$" "$SERVICEACTIONURL$" "$CONTACTEMAIL$" } define command{ command_name notify-host-by-email-bs command_line /usr/local/nagios/sbin/nagios_mail2 "HOST" "nagios.mydomain.by:80" "nagios@mydomain.by" "smtp.mydomain.by" "587" "mailpw" "tls" "Nagios" "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$HOSTOUTPUT$" "$SHORTDATETIME$" "$HOSTNOTES$" "$NOTIFICATIONRECIPIENTS$" "$CONTACTEMAIL$" } ------------------------- Arguments description: "HOST"/"SERVICE" - mark for script nagios_mail2 to recognize which section use when building the message. "nagios.mydomain.by:80" - URL to nagios GUI. "nagios@mydomain.by" - From address. "smtp.mydomain.by" - SMTP server. "587" - SMTP port. "mailpw" - specify your mail password here. "tls"/"notls" - mark for script nagios_mail2 to recognize whether to use TLS or not. "Nagios" - Name of sender (see screenshot). ------------------------- 5. Go to your templates.cfg and specify configured above commands to needed contact-template. Example: define contact{ name generic-contact-bs use generic-contact service_notification_commands notify-service-by-email-bs host_notification_commands notify-host-by-email-bs register 0 } 6. Finally specify the contact template for needed contact in contacts.cfg. Example: define contact{ contact_name nagiosadmin use generic-contact-bs alias Nagios Admin email myemail@mydomain.info } Check and Apply new configuration. Now try to send notification (CUSTOM for example) and see under /usr/local/nagios/log for log messages. Hope it will be usefull for somebody.
Reviews (0) Add a Review
Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
0 (0)
Favorites
0
Views
8,179