|
@@ -124,9 +124,9 @@ size_t pyfcgi_stats_format()
|
124
|
124
|
int pyfcgi_stats_avg(const int data[PYFCGI_STATS_SZ], int *idx_nxt, int *last,
|
125
|
125
|
double avgs[4])
|
126
|
126
|
{
|
127
|
|
- double r15, r10, r5, r1, rtmp;
|
|
127
|
+ double r15, r10, r5, r1, rtmp, dmax;
|
128
|
128
|
unsigned long stmp; // stores a 60s req sum
|
129
|
|
- int i, cur, idx, first;
|
|
129
|
+ int i, cur, idx, first, idiv;
|
130
|
130
|
int uptime, max;
|
131
|
131
|
|
132
|
132
|
uptime = time(NULL) - PyFCGI_conf.context.uptime;
|
|
@@ -154,21 +154,22 @@ int pyfcgi_stats_avg(const int data[PYFCGI_STATS_SZ], int *idx_nxt, int *last,
|
154
|
154
|
i++;
|
155
|
155
|
continue;
|
156
|
156
|
}
|
157
|
|
- rtmp = (long double)stmp / ((max < 60)?max:60);
|
158
|
|
- if(i==60) { r1 = rtmp; }
|
159
|
|
- if(i<5*60) { r5 += rtmp; }
|
160
|
|
- if(i<10*60) { r10 += rtmp; }
|
161
|
|
- if(i<15*60) { r15 += rtmp; }
|
|
157
|
+ rtmp = (long double)stmp / ((i%60)?i%60:60);
|
|
158
|
+ if(i<=60) { r1 = rtmp; }
|
|
159
|
+ else if(i%60) { rtmp = (double)rtmp / (60.0 / (i%60)); }
|
|
160
|
+ if(i<=5*60) { r5 += rtmp; }
|
|
161
|
+ if(i<=10*60) { r10 += rtmp; }
|
|
162
|
+ if(i<=15*60) { r15 += rtmp; }
|
162
|
163
|
stmp = cur;
|
163
|
164
|
i++;
|
164
|
165
|
}while(i<max);
|
165
|
166
|
//Restore interrupt/ALARM ??
|
166
|
167
|
*last = data[*idx_nxt-1];
|
167
|
|
- rtmp = max?rtmp:((double)*last);
|
168
|
|
- r1 = (uptime <= 60)?rtmp:r1;
|
169
|
|
- r5 /= 5;
|
170
|
|
- r10 /= 10;
|
171
|
|
- r15 /= 15;
|
|
168
|
+
|
|
169
|
+ dmax = (max<=60)?1:(double)max/60;
|
|
170
|
+ r5 /= (max >= 300)?5:dmax;
|
|
171
|
+ r10 /= (max >= 600)?10:dmax;
|
|
172
|
+ r15 /= (max >= 900)?15:dmax;
|
172
|
173
|
avgs[0] = r1;
|
173
|
174
|
avgs[1] = r5;
|
174
|
175
|
avgs[2] = r10;
|