Ad Widget

Collapse

Adding last month to IT services view

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jhgrc
    Member
    • Jun 2009
    • 52

    #1

    Adding last month to IT services view

    I guess nobody just wants to see last 30 days of SLA. Typically the SLA is viewed monthly basis, which means on today (11th feb) the interesting SLA figure is "last month" (1st jan - 31st jan).

    This patch does it, unfortunately only en_gb locale:

    Add to: include/locales/en_gb.inc.php
    Code:
    'S_LAST_MONTH'=>                        'Last month',
    Change srv_status.php
    - it adds last_month which uses conditional assignment to fetch last month. I could not get strtotime ("last month first day midnight") to work properly.
    - in theory you could remove 1 second from $period_end but I didn't see it worthwhile of it (adding -1 ..
    Code:
                    $periods = array(
                            'today' => S_TODAY,
                            'week' => S_THIS_WEEK,
                            'month' => S_THIS_MONTH,
                            'year' => S_THIS_YEAR,
                            24 => S_LAST_24_HOURS,
                            24*7 => S_LAST_7_DAYS,
                            24*30 => S_LAST_30_DAYS,
                            'last_month' => S_LAST_MONTH,
                            24*365 => S_LAST_365_DAYS,
                    );
    
                    $period = get_request('period', 7*24);
                    $period_end = time();
    
                    switch($period){
                            case 'today':
                                    $period_start = mktime(0, 0, 0, date('n'), date('j'), date('Y'));
                            break;
                            case 'week':
                                    $period_start = strtotime('last sunday');
                            break;
                            case 'month':
                                    $period_start = mktime(0, 0, 0, date('n'), 1, date('Y'));
                            break;
                            case 'last_month':
                                    $period_end = mktime(0, 0, 0, date('n'), 1, date('Y'));
                                    $period_start = mktime(0, 0, 0, (date('n')-1)<1?12:(date('n')-1),1, (date('n')-1)<1?(date('Y')-1):date('Y'));
                            break;
                            case 'year':
                                    $period_start = mktime(0, 0, 0, 1, 1, date('Y'));
                            break;
                            case 24:
                            case 24*7:
                            case 24*30:
                            case 24*365:
    Good thing would be adding dates of which the SLA figure is drawn. The method of generating pages is too complicated for me to add such stuff. What I am thinking is:

    SLA period: $period_start - $period-end

    (naturally above epoch values converted to human readable timestamps)
  • emilode
    Junior Member
    Zabbix Certified Specialist
    • Jul 2009
    • 7

    #2
    Superb. Please include this in next version zabbix admins!

    Comment

    Working...