|
@@ -65,7 +65,7 @@ void pyfcgi_stats_collector(int signum)
|
65
|
65
|
pyfcgi_log(LOG_DEBUG, "s#%d %d req/s", pyfcgi_stats.cur_req,
|
66
|
66
|
pyfcgi_stats.reqs[stats->cur_req]);
|
67
|
67
|
stats->cur_req++;
|
68
|
|
- stats->cur_req %= PYFCGI_STATS_REQS_SAMPLES;
|
|
68
|
+ stats->cur_req %= PYFCGI_STATS_SZ;
|
69
|
69
|
|
70
|
70
|
return;
|
71
|
71
|
}
|
|
@@ -114,16 +114,15 @@ size_t pyfcgi_stats_format()
|
114
|
114
|
do
|
115
|
115
|
{
|
116
|
116
|
ret = pyfcgi_stats_avg(pyfcgi_stats.reqs,
|
117
|
|
- &(pyfcgi_stats.cur_req), PYFCGI_STATS_REQS_SAMPLES,
|
118
|
|
- &last_rs, avgs);
|
|
117
|
+ &(pyfcgi_stats.cur_req), &last_rs, avgs);
|
119
|
118
|
} while(ret < 0 && errno == EINTR);
|
120
|
119
|
pyfcgi_stats_buffprintf("Requests stats :\n1s:%dr/s 1m:%.2fr/s 5m:%.2fr/s 10m:%.2fr/s 15m:%.2fr/s\n",
|
121
|
120
|
last_rs, avgs[0], avgs[1], avgs[2], avgs[3]);
|
122
|
121
|
return pyfcgi_stats.buff_ptr;
|
123
|
122
|
}
|
124
|
123
|
|
125
|
|
-int pyfcgi_stats_avg(const int data[], int *idx_first, int len,
|
126
|
|
- int *last, double avgs[4])
|
|
124
|
+int pyfcgi_stats_avg(const int data[PYFCGI_STATS_SZ], int *idx_nxt, int *last,
|
|
125
|
+ double avgs[4])
|
127
|
126
|
{
|
128
|
127
|
double r15, r10, r5, r1, rtmp;
|
129
|
128
|
unsigned long stmp; // stores a 60s req sum
|
|
@@ -131,23 +130,23 @@ int pyfcgi_stats_avg(const int data[], int *idx_first, int len,
|
131
|
130
|
int uptime, max;
|
132
|
131
|
|
133
|
132
|
uptime = time(NULL) - PyFCGI_conf.context.uptime;
|
134
|
|
- max = (uptime > len) ? len:uptime;
|
|
133
|
+ max = (uptime > PYFCGI_STATS_SZ) ? PYFCGI_STATS_SZ:uptime;
|
135
|
134
|
|
136
|
|
- r15 = r10 = r5 = r1 = stmp = 0;
|
137
|
|
- first = *idx_first;
|
|
135
|
+ r15 = r10 = r5 = r1 = stmp = rtmp = 0;
|
|
136
|
+ first = *idx_nxt;
|
138
|
137
|
|
139
|
138
|
//Block interrupt/ALARM ??
|
140
|
139
|
i = 0;
|
141
|
140
|
do
|
142
|
141
|
{
|
143
|
|
- if(first != *idx_first)
|
|
142
|
+ if(first != *idx_nxt)
|
144
|
143
|
{
|
145
|
144
|
errno = EINTR;
|
146
|
145
|
return -1;
|
147
|
146
|
}
|
148
|
|
- idx = (*idx_first- i - 1);
|
149
|
|
- idx = (idx<0)?len + idx:idx;
|
150
|
|
- idx %= len;
|
|
147
|
+ idx = (*idx_nxt- i - 1);
|
|
148
|
+ idx = (idx<0)?PYFCGI_STATS_SZ + idx:idx;
|
|
149
|
+ idx %= PYFCGI_STATS_SZ;
|
151
|
150
|
cur = data[idx];
|
152
|
151
|
if((!i || i%60) && i < max-1)
|
153
|
152
|
{
|
|
@@ -164,7 +163,7 @@ int pyfcgi_stats_avg(const int data[], int *idx_first, int len,
|
164
|
163
|
i++;
|
165
|
164
|
}while(i<max);
|
166
|
165
|
//Restore interrupt/ALARM ??
|
167
|
|
- *last = data[*idx_first-1];
|
|
166
|
+ *last = data[*idx_nxt-1];
|
168
|
167
|
rtmp = max?rtmp:((double)*last);
|
169
|
168
|
r1 = (uptime <= 60)?rtmp:r1;
|
170
|
169
|
r5 /= 5;
|