Recurring downtime scheduling for wrong dates

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Recurring downtime scheduling for wrong dates

Post 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. :)
Former Nagios Employee.
me.
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Recurring downtime scheduling for wrong dates

Post by Fred Kroeger »

OK - but you do realise that this is a major problem for Non-US users?

Fred
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Recurring downtime scheduling for wrong dates

Post by ssax »

I'll see if I can whip something up.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Recurring downtime scheduling for wrong dates

Post 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
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Recurring downtime scheduling for wrong dates

Post 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
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Recurring downtime scheduling for wrong dates

Post 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
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Recurring downtime scheduling for wrong dates

Post 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
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Recurring downtime scheduling for wrong dates

Post 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.
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Recurring downtime scheduling for wrong dates

Post 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
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Recurring downtime scheduling for wrong dates

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked