Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending clean notifications via email #22

Open
Robert-Redford opened this issue Aug 11, 2020 · 0 comments
Open

Sending clean notifications via email #22

Robert-Redford opened this issue Aug 11, 2020 · 0 comments

Comments

@Robert-Redford
Copy link

Hi to all readers,
I would like to send a clean e-mail with postfix using nagios notifier.As you may have seen, defauts emails are ugly.
I thought bout sending an html email using postfix, shell, and perl. Here are the files i used. 2 files that i have modified (notifier.cfg and a new shell file i created and put in /srv/eyesofnetwork/notifier/etc ) All files have 777 permissions as i am just testing it.
By defaut, i received emails starting with "eyesofnetwork" (please don't count the number of "*", if you are used to EON, you may know what i' talking about). I then added the 2 files below, gave them 777 permissions, and changed the nagios command (see below). I then received a notification starting with "Nagios" (again, please don't count the number or ""). It means EOn wasn't using the same command (eon_host_notifier and notify_by_email_host). Why another command was used ? i still don't know.
I used theses commands in command line interface, using values instead ot arguments ($1 ->9 ) and it worked perfectly.
Where is the problem pleasE ?


**** notifier.pl

0
<log_file>/srv/eyesofnetwork/notifier/log/notifier.log</log_file>


email-host = /srv/eyesofnetwork/notifier/etc/sendmail.sh $NOTIFICATIONTYPE$ $HOSTNAME$ $HOSTSTATE$ $HOSTADDRESS$ $HOSTOUTPUT$ $LONGDATETIME$ $HOSTSTATE$ $HOSTNAME$ $CONTACTEMAIL$


email-service =/srv/eyesofnetwork/notifier/etc/sendmail.sh $NOTIFICATIONTYPE$ $HOSTNAME$ $HOSTSTATE$ $HOSTADDRESS$ $HOSTOUTPUT$ $LONGDATETIME$ $HOSTSTATE$ $HOSTNAME$ $CONTACTEMAIL$



****sendmail.sh
#!/bin/sh

(
echo "To: $9
echo "Subject: Host $7 alert for $8 !"
echo "Content-Type: text/html"
echo "MIME-Version: 1.0"
echo ""
echo -e '

***** EYESOFNETWORK *****

Notification Type: $1
Host: $2
Address: $4
state: $3

Date/time: $5

Additional Info: $6
' ) | /usr/sbin/sendmail -t

****the nagios command
$USER3$/bin/notifier.pl -t host -c $USER3$/etc/notifier.cfg -r $USER3$/etc/notifier.rules -T "$LONGDATETIME$" -h "$HOSTNAME$" -e "$HOSTSTATE$" -i "$HOSTADDRESS$" -n "$NOTIFICATIONTYPE$" -C "$CONTACTEMAIL$" -O "$HOSTOUTPUT$" -A "$HOSTGROUPNAME$" -G "$CONTACTGROUPNAMES$" -X "$TIME$" -Y "$HOSTNOTIFICATIONNUMBER$"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant