Change setting for Default Last Week in Reporting

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Change setting for Default Last Week in Reporting

Post by nthaler »

HI!

Is there a way to change the default of 'Last Week' reporting time period? The default is Sunday to Monday. We run our week from Monday to Sunday. How can I change this? I want to automatically run a report every Monday for the last week.

Thank you!
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Change setting for Default Last Week in Reporting

Post by tgriep »

To change the This week and Last week to start on Monday instead of Sunday, edit the following file

Code: Select all

/usr/local/nagiosxi/html/includes/utils-reports.inc.php
Go to this section on line 750 (or close to it) and change it from

Code: Select all

        case "thisweek":  
            if (date('D', $now) == 'Sun') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last sunday");
            }
            $end = $now;
            break;
to

Code: Select all

       case "thisweek":  
            if (date('D', $now) == 'Mon') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last monday");
            }
            $end = $now;
            break;
Then go to this section on line 787 (or close to it) and change it from

Code: Select all

        case "lastweek":
            //$start=strtotime("first day of last week");
            //$end=strtotime("first day of this week");
            $start = strtotime("last sunday -7 days");
            $end = strtotime("last sunday");
            break;
to

Code: Select all

        case "lastweek":
            //$start=strtotime("first day of last week");
            //$end=strtotime("first day of this week");
            $start = strtotime("last monday -7 days");
            $end = strtotime("last monday");
            break;
Save the file and that should make the start day Monday instead of Sunday.
FYI, if you upgrade the Nagios XI server, you will have to re-edit the file and put the changes in as the upgrade will over write this file.
Be sure to check out our Knowledgebase for helpful articles and solutions!
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Re: Change setting for Default Last Week in Reporting

Post by nthaler »

tgriep wrote:To change the This week and Last week to start on Monday instead of Sunday, edit the following file

Code: Select all

/usr/local/nagiosxi/html/includes/utils-reports.inc.php
Go to this section on line 750 (or close to it) and change it from

Code: Select all

  case "thisweek":  
            if (date('D', $now) == 'Sun') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last sunday");
            }
            $end = $now;
            break;
to

Code: Select all

       case "thisweek":  
            if (date('D', $now) == 'Mon') {                                                                                                                                                                                         
                $start = strtotime("today");
            } else {
                $start = strtotime("last monday");
            }
            $end = $now;
            break;
.
At line 753 I see this instead of the above. Do I just need to change sunday to monday? I see no if statements.

Code: Select all

    753         case "thisweek":
    754             //$start=strtotime("first day of this week");
    755             $start = strtotime("last sunday");
    756             $end = $now;
    757             break;
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Change setting for Default Last Week in Reporting

Post by tgriep »

Yes, you would just have to change sunday to monday and it should work for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Re: Change setting for Default Last Week in Reporting

Post by nthaler »

Working as expected. Thank you!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Change setting for Default Last Week in Reporting

Post by cdienger »

Glad to hear! Are we okay locking the thread at this point?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
nthaler
Posts: 35
Joined: Fri Jul 08, 2016 11:24 am

Re: Change setting for Default Last Week in Reporting

Post by nthaler »

Yes :)
Locked