Skip to content

Sending clean notifications via email #22

@Robert-Redford

Description

@Robert-Redford

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$"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions