Page 1 of 1

Email alert not showing full data

Posted: Tue Jul 28, 2015 12:50 am
by yunushaikh
Hello Experts,

I have Disk I/O alerts and when I get email I have email like

***** Nagios *****

Notification Type: RECOVERY

Service: Check Disk IO
Host: XXXXX
Address: XX.XX.XX.XX
State: OK

Date/Time: Tue Jul 28 00:32:37 CDT 2015

Additional Info:

DISKIO OK - sdm - No Problems found (Write 0 MB/s)


But actually my output is large as below,

DISKIO OK - sdm - No Problems found (Write 0 MB/s)
DISKIO OK - dm-0 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-1 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-2 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-3 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-4 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-5 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-6 - No Problems found (Write 1 MB/s)
DISKIO OK - dm-7 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-8 - No Problems found (Write 2 MB/s)
DISKIO OK - dm-9 - No Problems found (Write 1 MB/s)
DISKIO OK - dm-10 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-11 - No Problems found (Write 16 MB/s)
DISKIO OK - dm-12 - No Problems found (Write 1 MB/s)
DISKIO OK - dm-13 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-14 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-15 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-16 - No Problems found (Write 2 MB/s)
DISKIO OK - dm-17 - No Problems found (Write 1 MB/s)
DISKIO OK - dm-18 - No Problems found (Write 16 MB/s)
DISKIO OK - dm-19 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-20 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-21 - No Problems found (Write 0 MB/s)
DISKIO OK - dm-22 - No Problems found (Write 0 MB/s)

I am not getting proper alert data. I am only getting first line . Above data which I have shown is an example. It does not have any critical alerts. But even there is any critical alert I am getting same email as given above. Only first line of the data is present in the additional information. Please advise.

Re: Email alert not showing full data

Posted: Tue Jul 28, 2015 9:12 am
by jdalrymple
Your existing notify-service-by-email command probably looks something like this:

Code: Select all

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
Make it look like this:

Code: Select all

/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

Re: Email alert not showing full data

Posted: Tue Jul 28, 2015 11:32 am
by yunushaikh
Hello Sir,

I only want this for a single service

Is it possible for making this change for one service only.

Re: Email alert not showing full data

Posted: Tue Jul 28, 2015 12:39 pm
by jdalrymple
Not really.

You could write a wrapper script that adds that component into the mail string if the service matches.

You could create a 2nd contact (could use the same E-mail address) that uses the alternative notification command.

There are quite a number of ways you could work around what you want, but there is no straightforward way since the command is defined on the contact and not the service. I would probably choose whichever of the above 2 methods works for you.

Re: Email alert not showing full data

Posted: Wed Jul 29, 2015 7:21 am
by yunushaikh
Hello Sir,

Is there any way you can help me in setting up another contact or any document to that?
I am new to this so still trying to understand the whole logic?
Very thankful to you for your help

Re: Email alert not showing full data

Posted: Wed Jul 29, 2015 11:06 am
by jdalrymple
Right now you might have 1 contact - nagiosadmin. That contact has a few options that have to be set, here is a basic contact for nagiosadmin:

Code: Select all

define contact {
        contact_name                            nagiosadmin
        alias                                   Nagios Administrator
        host_notification_period                nagiosadmin_notification_times
        service_notification_period             nagiosadmin_notification_times
        host_notification_options               d,u,r,f,s
        service_notification_options            w,u,c,r,f,s
        host_notification_commands              notify-host-by-email
        service_notification_commands           notify-service-by-email
        email                                   [email protected]
        }
All you need to do is create a 2nd contact that looks similar but has the alternative notification command configured:

Code: Select all

define contact {
        contact_name                            nagiosadmin2
        alias                                   Nagios Administrator
        host_notification_period                nagiosadmin_notification_times
        service_notification_period             nagiosadmin_notification_times
        host_notification_options               d,u,r,f,s
        service_notification_options            w,u,c,r,f,s
        host_notification_commands              notify-host-by-email
        service_notification_commands           notify-service-by-email-longoutput
        email                                   [email protected]
        }
Then for any services you want to see long output in notifications, simply substitute in the alternative contact. Does this make sense?

Re: Email alert not showing full data

Posted: Mon Aug 10, 2015 4:02 am
by yunushaikh
Hello Sir,

I was able to do it successfully.
Thanks a lot for your help.
You can lock this thread.

Sir I have one question. Will this threads stay as it is ? so whenever I want to refer this threads I can refer to it. Or else I would have to note down all this things which I learnt from you guys.
If this threads will never get deleted then It would be great help for me

Re: Email alert not showing full data

Posted: Mon Aug 10, 2015 7:44 am
by jdalrymple
As long as these forums exist, the thread will remain part of them. We even have some threads in these forums imported from the mailing list that existed before the forums!

Locking it up now, happy to help.