Local Server & GMT time in Notification %datetime%
Local Server & GMT time in Notification %datetime%
Dear Nagios Team
Our Notification is working great, currently the timestamp Date/Time: %datetime% is our Local Server but same time some customer need notification time in GMT, how can be achieve? Need both time as below. What have to do to less 3hours (GMTdatetime=LocalDatetime-3hours) in our Local Server Time (just for notification purpose), we do not want to change any server date/time.
Local Time: %datetime%
GMT Time: %GMTdatetime%
Regards
Our Notification is working great, currently the timestamp Date/Time: %datetime% is our Local Server but same time some customer need notification time in GMT, how can be achieve? Need both time as below. What have to do to less 3hours (GMTdatetime=LocalDatetime-3hours) in our Local Server Time (just for notification purpose), we do not want to change any server date/time.
Local Time: %datetime%
GMT Time: %GMTdatetime%
Regards
Last edited by zaji_nms on Sun Feb 21, 2016 3:43 am, edited 2 times in total.
Zajil NMS
Re: Local Server & GMT time in Notification %datetime%
At this time, it's only possible to have your system use one time.
I can file a feature request for this, if I understand correctly - you just want to change the time that is shown on an email notification that goes out?
I can file a feature request for this, if I understand correctly - you just want to change the time that is shown on an email notification that goes out?
Former Nagios Employee
Re: Local Server & GMT time in Notification %datetime%
Dear rKennedy
We want two dates, so its additional request, whatever current datetime, please keep it.
FYI, we have local domestic national customers for them current %datetime% is very okay but same time we have international customers, our international customers required link up/down time in GMT time, so its additional feature. I will call this macro as %GMTdatetime%. This moment only and only we required in Email Notifications. Its very minor feature add.
Host:
Service:
State:
Notification Type:
Info:
Local Time : %datetime%
GMT Time : %GMTdatetime%
Appreciate to file a feature request and any guideline/hint if can play around in our current version : Nagios XI 5.2.3 to achieve this quickly.
Regards
We want two dates, so its additional request, whatever current datetime, please keep it.
FYI, we have local domestic national customers for them current %datetime% is very okay but same time we have international customers, our international customers required link up/down time in GMT time, so its additional feature. I will call this macro as %GMTdatetime%. This moment only and only we required in Email Notifications. Its very minor feature add.
Host:
Service:
State:
Notification Type:
Info:
Local Time : %datetime%
GMT Time : %GMTdatetime%
Appreciate to file a feature request and any guideline/hint if can play around in our current version : Nagios XI 5.2.3 to achieve this quickly.
Regards
Zajil NMS
Re: Local Server & GMT time in Notification %datetime%
*** Note: This will get reverted if you upgrade and will need to be reimplemented.
*** Make sure that you have known-good backups/vm snapshots before making any modifications
*** This will also only use the XI server's timezone to generate the GMT time.
You could edit this file:
Add this code:
Below this code (It's in two places, one for email and one for mobile, around lines 283 and 411):
Now you can use it in your template:
Let me know if that works for you.
*** Make sure that you have known-good backups/vm snapshots before making any modifications
*** This will also only use the XI server's timezone to generate the GMT time.
You could edit this file:
Code: Select all
/usr/local/nagiosxi/html/includes/components/xicore/xicore.inc.phpCode: Select all
$message = preg_replace('/%GMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);Code: Select all
$message = process_notification_text($message, $meta);Code: Select all
%GMTdatetime%
Re: Local Server & GMT time in Notification %datetime%
Dear ssax
Great....thanks its working fine. To be safe side keeping in my mind to avoid any conflict with Global & System variables, we added as below and if you implementing the same way (new feature request), we do not have to do any changes when we will upgrade our NagiosXI.
$message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);
Great....thanks its working fine. To be safe side keeping in my mind to avoid any conflict with Global & System variables, we added as below and if you implementing the same way (new feature request), we do not have to do any changes when we will upgrade our NagiosXI.
$message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);
Zajil NMS
Re: Local Server & GMT time in Notification %datetime%
I'm glad that's working for you, good idea for changing the name. Are we okay to lock this thread and mark it as resolved?
Re: Local Server & GMT time in Notification %datetime%
Dear ssax
Yes you can but one favor as mentioned earlier if possible...........
Yes you can but one favor as mentioned earlier if possible...........
we added as below and if you implementing the same way (new feature request), we do not have to do any changes when we will upgrade our NagiosXI.
$message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);
Zajil NMS
Re: Local Server & GMT time in Notification %datetime%
Let's clarify - you want us to file a new feature request for adding the following line:
to "/usr/local/nagiosxi/html/includes/components/xicore/xicore.inc.php", correct?
Code: Select all
$message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Local Server & GMT time in Notification %datetime%
Yes , lmiltchev
Need to add twice, first time for Service other time for Host.
more /usr/local/nagiosxi/html/includes/components/xicore/xicore.inc.php | grep -n ykGMT
265 if ($notify == 1) {
266 if ($debug == true)
267 echo _("An email notification will be sent") . "...\n\n";
268
269 // get the user's email address
270 $email = get_user_attr($user_id, "email");
271
272 // get the email subject and message
273 if ($nt == "service") {
274 $subject = get_user_service_email_notification_subject($user_id);
275 $message = get_user_service_email_notification_message($user_id);
276 //get the GMT time in email notification
277 $message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);
278 } else {
279 $subject = get_user_host_email_notification_subject($user_id);
280 $message = get_user_host_email_notification_message($user_id);
281 //get the GMT time in email notification
282 $message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);
283 }
Regards
Need to add twice, first time for Service other time for Host.
more /usr/local/nagiosxi/html/includes/components/xicore/xicore.inc.php | grep -n ykGMT
265 if ($notify == 1) {
266 if ($debug == true)
267 echo _("An email notification will be sent") . "...\n\n";
268
269 // get the user's email address
270 $email = get_user_attr($user_id, "email");
271
272 // get the email subject and message
273 if ($nt == "service") {
274 $subject = get_user_service_email_notification_subject($user_id);
275 $message = get_user_service_email_notification_message($user_id);
276 //get the GMT time in email notification
277 $message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);
278 } else {
279 $subject = get_user_host_email_notification_subject($user_id);
280 $message = get_user_host_email_notification_message($user_id);
281 //get the GMT time in email notification
282 $message = preg_replace('/%ykGMTdatetime%/', gmdate('Y-m-d H:i:s'), $message);
283 }
Regards
Zajil NMS
Re: Local Server & GMT time in Notification %datetime%
I filed an internal feature request for adding this functionality (TASK ID 7885). FYI, there is no guarantee when/if this is going to be implemented. Thank you!
Is it safe to lock this thread?
Is it safe to lock this thread?
Be sure to check out our Knowledgebase for helpful articles and solutions!