Page 1 of 2
date/time 12 hour format in nagios xi notification
Posted: Thu Jan 24, 2019 2:45 am
by gcrodaje
Hi,
Is there a way to change the notification date/time to 12 hour format?
example:
from
Date/Time: 2019-01-23 15:29:33 HKT
to
Date/Time: 2019-01-23 03:29:33 PM HKT
Thank you.
Re: date/time 12 hour format in nagios xi notification
Posted: Thu Jan 24, 2019 1:59 pm
by lmiltchev
This question has been asked before. It's not so easy to change to format to 12 hour in Nagios Core. See the discussions below:
https://support.nagios.com/forum/viewto ... =7&t=41438
Having said that, there could be a way to modify the notification command and/or the notification messages somehow to convert the format. From the command line, you could use something like this:
Code: Select all
date +"%F %r %Z"
2019-01-24 12:57:37 PM CST
but I haven't been able to use that in Nagios XI to change the format, at least not yet. I will keep the topic open in case someone wants to chime in and offer a better solution.
Re: date/time 12 hour format in nagios xi notification
Posted: Fri Jan 25, 2019 12:47 am
by gcrodaje
Hi lmiltchev ,
I will try to replace the $LONGDATETIME$ with date +"%F %r %Z" as suggested. Will let you know the result.
Thank you very much.
Re: date/time 12 hour format in nagios xi notification
Posted: Fri Jan 25, 2019 10:00 am
by lmiltchev
We will keep this topic open for the time being. Let us know if you had any luck with converting the date/time format. Thank you!
Re: date/time 12 hour format in nagios xi notification
Posted: Sun Jan 27, 2019 8:50 am
by gcrodaje
Hi lmiltchev,
No effect on the time format. I also tried to use date +"%c", but i have no luck.
May i know if the Nagios XI is dependent on the NMS system clock? In my case, i used CentOS 7 for my NMS which i'm trying a several research on how to change the default system clock to 12-hour clock format, though the gnome desktop is already set to 12-hour format, but when i use the terminal, it always print the 24-hour.
Also, is there a way to create a new command to use as macro like $LONGDATETIME$ so i can change it to date +"%c".
Another thing, how to post on the customer support section because we have this client who already renewed their nagios subscription but i have no idea how to escalate an issue to nagios support.
For your kind advise, please.
Thank you very much.
Re: date/time 12 hour format in nagios xi notification
Posted: Mon Jan 28, 2019 1:55 pm
by lmiltchev
No effect on the time format. I also tried to use date +"%c", but i have no luck.
After doing some more testing, I found out that converting the time format would be possible ONLY if you used a custom notification handler. For example, you could modify the Nagios Core notification handlers, (e.g. "notify-host-by-email" and "notify-service-by-email"), and used these instead of the "default" xi handlers ("xi_host_notification_handler" and "xi_service_notification_handler").
Example:
1. I set up a user macro in the /usr/local/nagios/etc/resource.cfg file:
2. I modified the "notify-host-by-email" command as such:
Code: Select all
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $USER9$\n" | /bin/mail -r [email protected] -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
3. The notification that I received looked like this:
Code: Select all
***** Nagios Monitor XI Alert *****
Notification Type: PROBLEM
Host: MyTestHost
State: DOWN
Address: 192.168.x.x
Info: test
Date/Time: 2019-01-28 12:35:51 PM CST
May i know if the Nagios XI is dependent on the NMS system clock? In my case, i used CentOS 7 for my NMS which i'm trying a several research on how to change the default system clock to 12-hour clock format, though the gnome desktop is already set to 12-hour format, but when i use the terminal, it always print the 24-hour.
I am not familiar with NMS, but we use whatever php uses as time settings for the system clock.
Also, is there a way to create a new command to use as macro like $LONGDATETIME$ so i can change it to date +"%c".
Yes, you could use a custom command with a user macro, placed in the resource.cfg file (as shown above).
Another thing, how to post on the customer support section because we have this client who already renewed their nagios subscription but i have no idea how to escalate an issue to nagios support.
Please contact our sales team at
[email protected]. They will be able to add you to the Customer Only support forum.
Re: date/time 12 hour format in nagios xi notification
Posted: Tue Jan 29, 2019 11:56 pm
by gcrodaje
Hi lmiltchev,
Thank you for your prompt response.
I will try to set up a user macro as suggested. Will let you know the result.
Thank you very much!

Re: date/time 12 hour format in nagios xi notification
Posted: Wed Jan 30, 2019 10:26 am
by lmiltchev
You are welcome! Let us know how it went.
Re: date/time 12 hour format in nagios xi notification
Posted: Thu Jan 31, 2019 1:44 am
by gcrodaje
Hi lmiltchev,
I tried these steps, but it didn't work for me. Please see action taken below.
1. I set up a user macro in the /usr/local/nagios/etc/resource.cfg file:
Is it ` or ' ?
example:
$USER9$=`date +"%F %r %Z"` or
$USER9$='date +"%F %r %Z"'
either way, I tried both, but no effect.
2. I modified the "notify-host-by-email" command as such:
Code: Select all
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $USER9$\n" | /bin/mail -r [email protected] -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
I modified the "notify-host-by-email" as well as the "notify-service-by-email".
3. In the core config manager, select services, select config name and then check settings > enable event handler then select notify-service-by-email. (I also tried to select other like xi-service-notification-handler which I also modify the command from $LONGDATETIME$ to $USER9$) and then save settings.
4. Check service status > advanced > then send custom notification.
This is what I get.
Code: Select all
***** Information Technology Alert *****
***** SERVICE ALERT *****
Date/Time: 01/31/2019 14:14:20
Notification Type: CUSTOM
State: WARNING
Host: testhost
Address: 192.168.x.x
Service Affected: Drive C: Disk Usage
Additional Info:
C:\ - total: 232.79 Gb - used: 197.83 Gb (85%) - free 34.96 Gb (15%)
***** Nagios Monitoring System *****
***** Centos ver. 7; NagiosXI ver 5.5.7*****
As you notice, the date/time still the same. I tried also to restart the services, but same output.
Thank you.
Re: date/time 12 hour format in nagios xi notification
Posted: Thu Jan 31, 2019 2:49 am
by gcrodaje
btw, for additional information, we're using SMTP and not sendmail in the managed email settings in Nagios XI.
Based on
https://assets.nagios.com/downloads/nag ... Mailer.pdf
Core Notification Handlers:
Nagios Core notification commands - notify-host-by-email and notify-service-by-email. The handlers use sendmail exclusively and will not work with the XI SMTP settings.
XI Notification Handlers:
Nagios XI notification commands - xi_host_notification_handler and xi_service_notification_handler. These handlers use the Nagios XI SMTP settings but require that the contact was created as an XI User Contact.
Thank you very much.