mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-15 23:36:59 +00:00
analyze: bug fix shared networks counts
This also fixes backup state counts that were added to shared networks twice, making the numbers to be much greater than they really where. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
7cd381ed83
commit
d25e7afa1c
2 changed files with 20 additions and 35 deletions
|
|
@ -60,7 +60,8 @@ void do_counting(struct conf_t *state)
|
|||
{
|
||||
struct range_t *restrict range_p = state->ranges;
|
||||
const struct leases_t *restrict l = state->leases;
|
||||
unsigned long i, k, block_size;
|
||||
unsigned long i;
|
||||
double block_size;
|
||||
|
||||
/* Walk through ranges */
|
||||
for (i = 0; i < state->num_ranges; i++) {
|
||||
|
|
@ -83,38 +84,22 @@ void do_counting(struct conf_t *state)
|
|||
range_p->backups++;
|
||||
break;
|
||||
}
|
||||
if (range_p->shared_net) {
|
||||
switch (l->type) {
|
||||
case FREE:
|
||||
range_p->shared_net->touched++;
|
||||
break;
|
||||
case ACTIVE:
|
||||
range_p->shared_net->used++;
|
||||
break;
|
||||
case BACKUP:
|
||||
range_p->shared_net->backups++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Size of range, shared net & all networks */
|
||||
/* Size of range size. */
|
||||
block_size = get_range_size(range_p);
|
||||
if (range_p->shared_net)
|
||||
range_p->shared_net->available += block_size;
|
||||
range_p++;
|
||||
}
|
||||
/* FIXME: During count of other shared networks default network
|
||||
* and all networks got mixed together semantically. The below
|
||||
* fixes the problem, but is not elegant. */
|
||||
state->shared_networks->available = 0;
|
||||
state->shared_networks->used = 0;
|
||||
state->shared_networks->touched = 0;
|
||||
range_p = state->ranges;
|
||||
for (k = 0; k < state->num_ranges; k++) {
|
||||
state->shared_networks->available += get_range_size(range_p);
|
||||
state->shared_networks->used += range_p->count;
|
||||
state->shared_networks->touched += range_p->touched;
|
||||
state->shared_networks->backups += range_p->backups;
|
||||
/* Count together ranges within shared network block. */
|
||||
range_p->shared_net->available += block_size;
|
||||
range_p->shared_net->used += range_p->count;
|
||||
range_p->shared_net->touched += range_p->touched;
|
||||
range_p->shared_net->backups += range_p->backups;
|
||||
/* When shared network is not 'all networks' add it as well. */
|
||||
if (range_p->shared_net != state->shared_networks) {
|
||||
state->shared_networks->available += block_size;
|
||||
state->shared_networks->used += range_p->count;
|
||||
state->shared_networks->touched += range_p->touched;
|
||||
state->shared_networks->backups += range_p->backups;
|
||||
}
|
||||
/* Next range. */
|
||||
range_p++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ Summary:
|
|||
percent: 43
|
||||
touch_count: 43
|
||||
touch_percent: 43
|
||||
backup_count: 3
|
||||
backup_percent: 3
|
||||
backup_count: 2
|
||||
backup_percent: 2
|
||||
status: 0
|
||||
|
||||
--- skip ok ---
|
||||
|
|
@ -185,7 +185,7 @@ Summary:
|
|||
percent: 43
|
||||
touch_count: 43
|
||||
touch_percent: 43
|
||||
backup_count: 3
|
||||
backup_percent: 3
|
||||
backup_count: 2
|
||||
backup_percent: 2
|
||||
status: 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue