Hello Team,
i am configured nagios mail alert. it is working fine.
***** Nagios *****
Notification Type: PROBLEM
Host: Test_Linux
State: DOWN
Address: 10.10.2.45
Info: PING CRITICAL - Packet loss = 100%
Date/Time: Wed Feb 8 22:31:56 +0530 2017
but i want Duration also. please share the comment.
Nagios mail Notification with Duration
Nagios mail Notification with Duration
- Attachments
-
- dur.PNG (1.45 KiB) Viewed 3751 times
Re: Nagios mail Notification with Duration
Take a look at how your notification commands are defined, for example -
You can add to the message by appending to the first part of what's being printed, using any of the variables allowed to customize it further. The general list is here - https://assets.nagios.com/downloads/nag ... olist.html
For your case, I believe you're after either $SERVICEDURATION$ or $HOSTDURATION$
Code: Select all
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /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 $NOTIFICATIONCOMMENT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
For your case, I believe you're after either $SERVICEDURATION$ or $HOSTDURATION$
Former Nagios Employee
Re: Nagios mail Notification with Duration
Thanks for your support.
please share both command definition.
1.notify-host-by-email
2.notify-service-by-email
please share both command definition.
1.notify-host-by-email
2.notify-service-by-email
Re: Nagios mail Notification with Duration
The information has been provided above - you'll want to customize the commands based on your requirements.
Former Nagios Employee
Re: Nagios mail Notification with Duration
Hello Team,
Thanks for support.
one problem.
***** Nagios *****
Notification Type: RECOVERY
Host: TestLinux
State: UP
Address: 10.10.4.1
Duration: 0d 0h 0m 0s
Info: PING OK - Packet loss = 28%, RTA = 2156.19 ms
Date/Time: Thu Feb 9 19:38:19 +0530 2017
it is show current status. i want last down duration.
please suggest.
Thanks for support.
one problem.
***** Nagios *****
Notification Type: RECOVERY
Host: TestLinux
State: UP
Address: 10.10.4.1
Duration: 0d 0h 0m 0s
Info: PING OK - Packet loss = 28%, RTA = 2156.19 ms
Date/Time: Thu Feb 9 19:38:19 +0530 2017
it is show current status. i want last down duration.
please suggest.
Re: Nagios mail Notification with Duration
The notification you posted is for a recovery in an OK status, if this were a warning / critical email then I'd expect it to show 0d 0h 0m 0s right away, but as your notifications send in further this number should increase.Pradhap wrote:Hello Team,
Thanks for support.
one problem.
***** Nagios *****
Notification Type: RECOVERY
Host: TestLinux
State: UP
Address: 10.10.4.1
Duration: 0d 0h 0m 0s
Info: PING OK - Packet loss = 28%, RTA = 2156.19 ms
Date/Time: Thu Feb 9 19:38:19 +0530 2017
it is show current status. i want last down duration.
please suggest.
I don't believe this is possible currently based on the macros -
Code: Select all
$HOSTDURATION$ A string indicating the amount of time that the host has spent in its current state. Format is "XXh YYm ZZs", indicating hours, minutes and seconds.
$HOSTDURATIONSEC$ A number indicating the number of seconds that the host has spent in its current state.
Former Nagios Employee
Re: Nagios mail Notification with Duration
Hi Team,
thanks for support.
am used $LASTHOSTDOWN$ and $LASTHOSTUP$
but am getting the result not time formate
Last Host up: 1452567
Last Host Down: 1465234
please suggest.
thanks for support.
am used $LASTHOSTDOWN$ and $LASTHOSTUP$
but am getting the result not time formate
Last Host up: 1452567
Last Host Down: 1465234
please suggest.
Re: Nagios mail Notification with Duration
See the documentation for what the variables are referencing. If you're looking for these to output otherwise, you'll need to write a wrapper to process the math.
Code: Select all
$LASTHOSTUP$ This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the host was last detected as being in an UP state.
$LASTHOSTDOWN$ This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the host was last detected as being in a DOWN state.
Former Nagios Employee
Re: Nagios mail Notification with Duration
Just checking in since we have not heard from you in a while. Did @rkennedy's post clear things up or has the issue otherwise been resolved?
Former Nagios employee