[ZBX-1076] IT Services SLA for "this month, week, year" not calculated correctly. Created: 2009 Oct 08  Updated: 2017 May 30  Resolved: 2009 Oct 09

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 1.6.6, 1.9.0 (alpha)
Fix Version/s: None

Type: Incident report Priority: Major
Reporter: Edward Rudd Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS 4 running PHP 5.1.6 on mysql 5.0


Attachments: File zabbix-1.6.6-sla.diff    

 Description   

While reviewing the srv_status.php in order to patch in "previous week/month/year" functionality I noticed a rather odd thing.

the value of $period_start_sec is inconsistent. for the "today, this week/month/year" a absolute unix timestamp is stored in the variable.

However, for the "last 7/30/365 days" options a "relative" value is stored in the variable.

Later on when the extents of the SLA are calculated (the $start and $end variables) the $period_start_sec is treated as a relative instead of an absolute.

Thus, if you choose "this month" you actually get EVERYTHING. as $start is calculated as $now-(time for beginning of month) So for example..

$now = time(); // assume 2009-10-30 14:00 localtime;
$period_start_sec = mktime(0,0,0,date('n'), 1, date('Y')); // this would generate timestamp for 2009-10-01 00:00:00 local time

now when $start is calculated it is this

$start = $now - $period_start_sec;
which results in $start being the # of seconds since the first of the month until "now". which when treated as a unix stamp is 1970-01-30 14:00.

this results in pulling in ALL sla history all the time (as no one has sla alarm data for 1970)

I have a patch I'll attach that fixes this issue.



 Comments   
Comment by Edward Rudd [ 2009 Oct 08 ]

this is a patch based on Zabbix 1.6.6 that resolves the incorrect SLA calculations for "today, this week / month / year"

It also takes an approach that allows the $end to be altered by the "selection" so future time periods like "previous month" can easily be added in.

Comment by Alexey Fukalov [ 2009 Oct 09 ]

fixed in 1.6 branch 8053

Comment by richlv [ 2009 Nov 10 ]

close old, resolved issues

Generated at Fri Apr 26 16:05:28 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.