Page 3 of 5
Re: Recurring downtime scheduling for wrong dates
Posted: Fri Feb 05, 2016 3:03 pm
by hsmith
Thanks for the help, Willem.
Fred Kroeger wrote:However, I'm going to have to wait for the fix.
I wish I could provide an ETA, but I do not have one at this time. Thank you for your patience.

Re: Recurring downtime scheduling for wrong dates
Posted: Sun Feb 07, 2016 9:31 pm
by Fred Kroeger
OK - but you do realise that this is a major problem for Non-US users?
Fred
Re: Recurring downtime scheduling for wrong dates
Posted: Mon Feb 08, 2016 2:50 pm
by ssax
I'll see if I can whip something up.
Re: Recurring downtime scheduling for wrong dates
Posted: Mon Feb 08, 2016 4:31 pm
by ssax
This is for XI 5.2.3.
*** 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
Edit this file:
Code: Select all
/usr/local/nagiosxi/html/includes/components/xicore/downtime.php
Around line 615 you will find this code:
Code: Select all
$start_time = date('m-d-Y H:i:s', strtotime($start_time));
$end_time = date('m-d-Y H:i:s', strtotime($end_time));
Replace it with this code:
Code: Select all
// Get timezone datepicker format
if (isset($_SESSION['date_format']))
$format = $_SESSION['date_format'];
else {
if (is_null($format = get_user_meta(0, 'date_format')))
$format = get_option('default_date_format');
}
// Set the date format to the user's preference so we can convert properly
if ($format == DF_ISO8601) {
$date_format = 'Y-m-d H:i:s';
} else if ($format == DF_US) {
$date_format = 'm/d/Y H:i:s';
} else if ($format == DF_EURO) {
$date_format = 'd/m/Y H:i:s';
}
$start_date = date_create_from_format("$date_format", "$start_time");
$end_date = date_create_from_format("$date_format", "$end_time");
$start_time = date_format($start_date, 'm-d-Y H:i:s');
$end_time = date_format($end_date, 'm-d-Y H:i:s');
That should make it work properly according to your date preferences.
Let me know if this works for you and if you run into any problems.
Thank you
Re: Recurring downtime scheduling for wrong dates
Posted: Mon Feb 08, 2016 8:05 pm
by Fred Kroeger
Applied the changes to my test system - it didn't break but it didn't fix it either for me.
Made the changes to downtime.php & restarted both Nagios & httpd services
I Scheduled downtime via the Advanced Tab of the Host - and just changed the end time year value to 2017
Downtime-Set.PNG
Then looking at scheduled downtime, you can see that the date of the schedule is correct, but the start/end downtime were saved in mm/dd/yyyy
Downtime-View.PNG
Regards... Fred
Re: Recurring downtime scheduling for wrong dates
Posted: Tue Feb 09, 2016 12:00 pm
by ssax
Sorry, I only updated the one for Home > Scheduled Downtime, I'll take a look at that one as well.
Test Home > Scheduled Downtime out to see if it works properly for you there and let me know.
Thank you
Re: Recurring downtime scheduling for wrong dates
Posted: Wed Feb 10, 2016 2:27 am
by Fred Kroeger
Still the same problem via <Home><Scheduled Downtme> - scheduled a downtime for today - 10/02/16 and it shows it as being scheduled for 02/10/16
regards... Fred
Re: Recurring downtime scheduling for wrong dates
Posted: Wed Feb 10, 2016 2:14 pm
by ssax
Please attach your /usr/local/nagiosxi/html/includes/components/xicore/downtime.php file so that I can review it.
Still working on a solution for the other place.
Re: Recurring downtime scheduling for wrong dates
Posted: Thu Feb 11, 2016 1:44 am
by Fred Kroeger
Good News! The downtime problem appears to be fixed! I left the patched file on my Test server and today scheduling downtime works as expected. The only difference that I can identify betwwen last time and this time is that I shutdown my PC in between - so maybe the old php had been cached by my browser? I just tested it with another user and it is also working for them. I will test it on another box and let you know.
While you're looking at the same downtime scheduling problem from the Host/Status details page, can you also review the Recurring Downtime script and see if it is also affected? I've got a user complaining that the Recurring Downtime they had scheduled isn't working anymore. I know that you don't actually insert a date (just Days of Month & Days of Week) but I'm wondering if the swap to MM/DD problem may also be happening with Recurring downtime when it gets scheduled via the cron process.
Just confirmed it's OK on another server - just had to clear my browser cache.
regards... Fred
Re: Recurring downtime scheduling for wrong dates
Posted: Thu Feb 11, 2016 10:19 am
by lmiltchev
I am glad we are moving to the right direction!
I will do a little bit more digging into the recurring downtime, but it will take a while. Meanwhile, I will keep this thread open in case you have some more questions/issues/feedback, etc.