Code Monkey home page Code Monkey logo

Comments (3)

phelinor avatar phelinor commented on July 20, 2024

I have not been able either, @JasonRivers any guidance on this topic?

from docker-nagios.

JasonRivers avatar JasonRivers commented on July 20, 2024

I have a custom script for this currently, Perhaps I should include it in the container,

my custom script looks like this:

#!/bin/bash

NOTIFICATION_TYPE=$1


if [ "$NOTIFICATION_TYPE" = "service" ]; then
	## This is a service notification
	SUBJECT="[NAGIOS] ${NAGIOS_NOTIFICATIONTYPE}: ${NAGIOS_SERVICEDESC} on ${NAGIOS_HOSTNAME} is ${NAGIOS_SERVICESTATE}"
	MAILBODY="***** Nagios *****\n\nNotification Type: ${NAGIOS_NOTIFICATIONTYPE}\n\nHost\n\nService: ${NAGIOS_SERVICEDESC}\nHost: ${NAGIOS_HOSTNAME}\nAddress: ${NAGIOS_HOSTADDRESS}\nState: ${SERVICESTATE}\n\nDate/Time: ${NAGIOS_LONGDATETIME}\n\nAdditional Info:\n\n${NAGIOS_SERVICEOUTPUT}"
else
	## This is a host notification
	SUBJECT="[NAGIOS] ${NAGIOS_NOTIFICATIONTYPE}: ${NAGIOS_HOSTNAME} is ${NAGIOS_HOSTSTATE}"
	MAILBODY="***** Nagios *****\n\nNotification Type: $NAGIOS_NOTIFICATIONTYPE\n\nHost: $NAGIOS_HOSTNAME\nAddress: $NAGIOS_HOSTADDRESS\nState: $NAGIOS_HOSTSTATE\n\nDate/Time: $NAGIOS_LONGDATETIME\n\nAdditional Info:\n\n$NAGIOS_HOSTOUTPUT"
fi

if [ ${NAGIOS_CONTACTEMAIL} ]; then

	MAILFROM="Nagios Monitor <[email protected]>"

/usr/sbin/sendmail -t -i -f "$MAILFROM" <<EOF
From: $MAILFROM
To: $NAGIOS_CONTACTEMAIL
Subject: $SUBJECT

$MAILBODY
EOF

fi

My notify_commands.cfg has this:

define command {
        command_name	notify-service-by-email
        command_line	$USER4$/notify_by_email service
}

and the following in contacts.cfg:

define contact {
	contact_name	JasonEmail
	alias		Jason Rivers (Email)
	use		Email
	email		[email protected]
	contact_groups	Admins
        service_notification_period     WorkHours
        host_notification_period        WorkHours
}

I have a separate contact for services that I want to be notified of 24/7, along with XMPP notifications and SMS notifications.

Hopefully this helps get you up and running, I'll see about including the notify_by_email script within the image

from docker-nagios.

phelinor avatar phelinor commented on July 20, 2024

thank you @JasonRivers, I also notice that I was not even able to "sendmail" from the container because it's in a Corporate Network so I also had to update Postfix (/etc/postfix/main.cf) to include
myhostname = [linuxboxURL]
relayhost = [corporateSMTPServerURL]

Hope this also helps other people

from docker-nagios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.