/* This seems to get polluted on startup by an exit_client()
* before any connections have been recorded.
*/
- if (current_load_data.local_count > MAXCONNECTIONS ||
- current_load_data.client_count > MAXCONNECTIONS ||
+ if (current_load_data.client_count > MAXCONNECTIONS ||
current_load_data.conn_count > MAXCONNECTIONS)
memset (¤t_load_data, 0, sizeof (struct current_load_struct));
((now.tv_sec * 1000 + now.tv_usec / 1000 + 5) -
(last.tv_sec * 1000 + last.tv_usec / 1000)) / 10;
- cur_load_entry->local_count = current_load_data.local_count;
cur_load_entry->client_count = current_load_data.client_count;
cur_load_entry->conn_count = current_load_data.conn_count;
#ifdef DEBUGMODE
struct load_entry *cur_load_entry;
struct load_entry *last = NULL;
#ifdef DEBUGMODE
- u_long secs = 0, adj_secs, total[4], adj[4]; /*[local,client,conn,cpu] */
+ u_long secs = 0, adj_secs, total[3], adj[3]; /*[client,conn,cpu] */
int i;
- u_int times[5][4]; /* [min,hour,day,Yest,YYest][local,client,conn,cpu] */
- char what[4][HOSTLEN + 1];
-
- memset (total, 0, 4 * sizeof (u_long));
-#else
- u_long secs = 0, adj_secs, total[3], adj[3]; /*[local,client,conn] */
- int i, times[5][3]; /* [min,hour,day,Yest,YYest][local,client,conn] */
+ u_int times[5][3]; /* [min,hour,day,Yest,YYest][client,conn,cpu] */
char what[3][HOSTLEN + 1];
memset (total, 0, 3 * sizeof (u_long));
+#else
+ u_long secs = 0, adj_secs, total[2], adj[2]; /*[client,conn] */
+ int i, times[5][2]; /* [min,hour,day,Yest,YYest][client,conn] */
+ char what[2][HOSTLEN + 1];
+
+ memset (total, 0, 2 * sizeof (u_long));
#endif
current_load_data.entries = 0;
for (cur_load_entry = load_list_tail; (secs < 6000) &&
(cur_load_entry != NULL); cur_load_entry = cur_load_entry->prev) {
u_long time_incr = cur_load_entry->time_incr;
- total[0] += time_incr * cur_load_entry->local_count;
- total[1] += time_incr * cur_load_entry->client_count;
- total[2] += time_incr * cur_load_entry->conn_count;
+ total[0] += time_incr * cur_load_entry->client_count;
+ total[1] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE
- total[3] += cur_load_entry->cpu_usage;
+ total[2] += cur_load_entry->cpu_usage;
#endif
last = cur_load_entry;
secs += cur_load_entry->time_incr;
}
if ((secs > 6000) && (last != NULL)) {
adj_secs = secs - 6000;
- adj[0] = adj_secs * last->local_count;
- adj[1] = adj_secs * last->client_count;
- adj[2] = adj_secs * last->conn_count;
+ adj[0] = adj_secs * last->client_count;
+ adj[1] = adj_secs * last->conn_count;
#ifdef DEBUGMODE
- times[0][3] =
- total[3] -
+ times[0][2] =
+ total[2] -
(last->cpu_usage * (double) adj_secs / last->time_incr);
}
else {
- adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
- times[0][3] = total[3];
+ adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ times[0][2] = total[2];
}
#else
}
else
- adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ adj_secs = adj[0] = adj[1] = 0;
#endif
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 2; i++) {
times[0][i] =
((total[i] - adj[i]) * 1000 / (secs - adj_secs) + 5) / 10;
}
secs = (secs + 5) / 10;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 2; i++)
total[i] = (total[i] + 5) / 10;
for (; (secs < 36000) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 5) / 10, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) {
u_long time_incr = (cur_load_entry->time_incr + 5) / 10;
- total[0] += time_incr * cur_load_entry->local_count;
- total[1] += time_incr * cur_load_entry->client_count;
- total[2] += time_incr * cur_load_entry->conn_count;
+ total[0] += time_incr * cur_load_entry->client_count;
+ total[1] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE
- total[3] += cur_load_entry->cpu_usage;
+ total[2] += cur_load_entry->cpu_usage;
#endif
last = cur_load_entry;
}
if ((secs > 36000) && (last != NULL)) {
adj_secs = secs - 36000;
- adj[0] = adj_secs * last->local_count;
- adj[1] = adj_secs * last->client_count;
- adj[2] = adj_secs * last->conn_count;
+ adj[0] = adj_secs * last->client_count;
+ adj[1] = adj_secs * last->conn_count;
#ifdef DEBUGMODE
- times[1][3] =
- total[3] -
+ times[1][2] =
+ total[2] -
(last->cpu_usage * (double) adj_secs / last->time_incr);
}
else {
- adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
- times[1][3] = total[3];
+ adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ times[1][2] = total[2];
}
#else
}
else
- adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ adj_secs = adj[0] = adj[1] = 0;
#endif
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 2; i++) {
times[1][i] =
((total[i] - adj[i]) * 100 / (secs - adj_secs) + 5) / 10;
}
secs = (secs + 5) / 10;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 2; i++)
total[i] = (total[i] + 5) / 10;
for (; (secs < 86400) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 50) / 100, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) {
u_long time_incr = (cur_load_entry->time_incr + 50) / 100;
- total[0] += time_incr * cur_load_entry->local_count;
- total[1] += time_incr * cur_load_entry->client_count;
- total[2] += time_incr * cur_load_entry->conn_count;
+ total[0] += time_incr * cur_load_entry->client_count;
+ total[1] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE
- total[3] += cur_load_entry->cpu_usage;
+ total[2] += cur_load_entry->cpu_usage;
#endif
last = cur_load_entry;
}
if ((secs > 86400) && (last != NULL)) {
adj_secs = secs - 86400;
- adj[0] = adj_secs * last->local_count;
- adj[1] = adj_secs * last->client_count;
- adj[2] = adj_secs * last->conn_count;
+ adj[0] = adj_secs * last->client_count;
+ adj[1] = adj_secs * last->conn_count;
#ifdef DEBUGMODE
- times[2][3] =
- total[3] -
+ times[2][2] =
+ total[2] -
(last->cpu_usage * (double) adj_secs / last->time_incr);
}
else {
- adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
- times[2][3] = total[3];
+ adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ times[2][2] = total[2];
}
#else
}
else
- adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ adj_secs = adj[0] = adj[1] = 0;
#endif
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 2; i++) {
times[2][i] = ((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10;
}
#ifdef DEBUGMODE
- memset (total, 0, 4 * sizeof (u_long));
-#else
memset (total, 0, 3 * sizeof (u_long));
+#else
+ memset (total, 0, 2 * sizeof (u_long));
#endif
for (secs = 1; (secs < 86400) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 50) / 100, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) {
u_long time_incr = (cur_load_entry->time_incr + 50) / 100;
- total[0] += time_incr * cur_load_entry->local_count;
- total[1] += time_incr * cur_load_entry->client_count;
- total[2] += time_incr * cur_load_entry->conn_count;
+ total[0] += time_incr * cur_load_entry->client_count;
+ total[1] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE
- total[3] += cur_load_entry->cpu_usage;
+ total[2] += cur_load_entry->cpu_usage;
#endif
last = cur_load_entry;
}
if ((secs > 86400) && (last != NULL)) {
adj_secs = secs - 86400;
- adj[0] = adj_secs * last->local_count;
- adj[1] = adj_secs * last->client_count;
- adj[2] = adj_secs * last->conn_count;
+ adj[0] = adj_secs * last->client_count;
+ adj[1] = adj_secs * last->conn_count;
#ifdef DEBUGMODE
- times[3][3] =
- total[3] -
+ times[3][2] =
+ total[2] -
(last->cpu_usage * (double) adj_secs / last->time_incr);
}
else {
- adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
- times[3][3] = total[3];
+ adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ times[3][2] = total[2];
}
#else
}
else
- adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ adj_secs = adj[0] = adj[1] = 0;
#endif
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 2; i++) {
times[3][i] = ((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10;
}
#ifdef DEBUGMODE
- memset (total, 0, 4 * sizeof (u_long));
-#else
memset (total, 0, 3 * sizeof (u_long));
+#else
+ memset (total, 0, 2 * sizeof (u_long));
#endif
for (secs = 1; (secs < 86400) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 50) / 100, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) {
u_long time_incr = (cur_load_entry->time_incr + 50) / 100;
- total[0] += time_incr * cur_load_entry->local_count;
- total[1] += time_incr * cur_load_entry->client_count;
- total[2] += time_incr * cur_load_entry->conn_count;
+ total[0] += time_incr * cur_load_entry->client_count;
+ total[1] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE
- total[3] += cur_load_entry->cpu_usage;
+ total[2] += cur_load_entry->cpu_usage;
#endif
last = cur_load_entry;
}
if ((secs > 86400) && (last != NULL)) {
adj_secs = secs - 86400;
- adj[0] = adj_secs * last->local_count;
- adj[1] = adj_secs * last->client_count;
- adj[2] = adj_secs * last->conn_count;
+ adj[0] = adj_secs * last->client_count;
+ adj[1] = adj_secs * last->conn_count;
#ifdef DEBUGMODE
- times[4][3] =
- total[3] -
+ times[4][2] =
+ total[2] -
(last->cpu_usage * (double) adj_secs / last->time_incr);
}
else {
- adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
- times[4][3] = total[3];
+ adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ times[4][2] = total[2];
}
#else
}
else
- adj_secs = adj[0] = adj[1] = adj[2] = 0;
+ adj_secs = adj[0] = adj[1] = 0;
#endif
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 2; i++) {
times[4][i] = ((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10;
}
cur_load_entry->prev = NULL;
}
- strcpy (what[0], DOMAINNAME);
- strcat (what[0], " clients");
- strcpy (what[1], "total clients");
- strcpy (what[2], "total connections");
+ strcpy (what[0], "total clients");
+ strcpy (what[1], "total connections");
#ifdef DEBUGMODE
- strcpy (what[3], "CPU usage");
+ strcpy (what[2], "CPU usage");
#endif
sendto_one (sptr,
":%s NOTICE %s :Minute Hour Day Yest. YYest. Userload for:",
me.name, parv);
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 2; i++)
sendto_one (sptr,
":%s NOTICE %s :%3d.%02d %3d.%01d %3d %3d %3d %s",
me.name, parv, times[0][i] / 100, times[0][i] % 100,
sendto_one (sptr,
":%s NOTICE %s :%6.2f%% %5.1f%% %3d%% %3d%% %3d%% %s",
me.name, parv,
- (double) ((double) times[0][3] / (0.6 * CLOCKS_PER_SEC)),
- (double) ((double) times[1][3] / (36 * CLOCKS_PER_SEC)),
- (int) ((double) times[2][3] / (864 * CLOCKS_PER_SEC)),
- (int) ((double) times[3][3] / (864 * CLOCKS_PER_SEC)),
- (int) ((double) times[4][3] / (864 * CLOCKS_PER_SEC)),
- what[3]);
+ (double) ((double) times[0][2] / (0.6 * CLOCKS_PER_SEC)),
+ (double) ((double) times[1][2] / (36 * CLOCKS_PER_SEC)),
+ (int) ((double) times[2][2] / (864 * CLOCKS_PER_SEC)),
+ (int) ((double) times[3][2] / (864 * CLOCKS_PER_SEC)),
+ (int) ((double) times[4][2] / (864 * CLOCKS_PER_SEC)),
+ what[2]);
#endif
}