mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 15:57:00 +00:00
backup counting: fix output regression
The backup count was not printed at all. This bug was introduced in version 2.17 (May 2012) when the uthash was taken in use. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
3471c91796
commit
f1411858cb
4 changed files with 23 additions and 26 deletions
|
|
@ -120,6 +120,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* Default sort order is by IPs small to big */
|
/* Default sort order is by IPs small to big */
|
||||||
config.reverse_order = false;
|
config.reverse_order = false;
|
||||||
|
config.backups_found = false;
|
||||||
|
|
||||||
/* Parse command line options */
|
/* Parse command line options */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
|
# include <stdbool.h>
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
|
@ -101,6 +102,7 @@ struct configuration_t {
|
||||||
int reverse_order;
|
int reverse_order;
|
||||||
char *output_file;
|
char *output_file;
|
||||||
int output_limit[2];
|
int output_limit[2];
|
||||||
|
bool backups_found;
|
||||||
double warning;
|
double warning;
|
||||||
double critical;
|
double critical;
|
||||||
};
|
};
|
||||||
|
|
@ -173,12 +175,6 @@ struct range_t *ranges;
|
||||||
unsigned int num_ranges;
|
unsigned int num_ranges;
|
||||||
/* \var leases Pointer holding all leases. */
|
/* \var leases Pointer holding all leases. */
|
||||||
struct leases_t *leases;
|
struct leases_t *leases;
|
||||||
/* \var num_leases FIXME: not in use, remove */
|
|
||||||
unsigned long int num_leases;
|
|
||||||
/* \var num_touches FIXME: not in use, remove */
|
|
||||||
unsigned long int num_touches;
|
|
||||||
/* \var num_backups FIXME: not in use, remove */
|
|
||||||
unsigned long int num_backups;
|
|
||||||
|
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
int prepare_memory(void);
|
int prepare_memory(void);
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,6 @@ int parse_leases(void)
|
||||||
int ethernets = false;
|
int ethernets = false;
|
||||||
struct leases_t *lease;
|
struct leases_t *lease;
|
||||||
|
|
||||||
num_touches = num_leases = num_backups = 0;
|
|
||||||
|
|
||||||
dhcpd_leases = fopen(config.dhcpdlease_file, "r");
|
dhcpd_leases = fopen(config.dhcpdlease_file, "r");
|
||||||
if (dhcpd_leases == NULL) {
|
if (dhcpd_leases == NULL) {
|
||||||
err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
|
err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
|
||||||
|
|
@ -180,6 +178,7 @@ int parse_leases(void)
|
||||||
delete_lease(lease);
|
delete_lease(lease);
|
||||||
}
|
}
|
||||||
add_lease(&addr, BACKUP);
|
add_lease(&addr, BACKUP);
|
||||||
|
config.backups_found = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ethernets && (xstrstr(line, " hardware ethernet", 19))) {
|
if (ethernets && (xstrstr(line, " hardware ethernet", 19))) {
|
||||||
|
|
|
||||||
37
src/output.c
37
src/output.c
|
|
@ -45,6 +45,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
@ -90,7 +91,7 @@ int output_txt(void)
|
||||||
max_ipaddr_length,
|
max_ipaddr_length,
|
||||||
"last ip",
|
"last ip",
|
||||||
"max", "cur", "percent", "touch", "t+c", "t+c perc");
|
"max", "cur", "percent", "touch", "t+c", "t+c perc");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, " bu bu perc");
|
fprintf(outfile, " bu bu perc");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
@ -121,7 +122,7 @@ int output_txt(void)
|
||||||
(float)(100 *
|
(float)(100 *
|
||||||
(range_p->touched +
|
(range_p->touched +
|
||||||
range_p->count)) / range_size);
|
range_p->count)) / range_size);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, "%7lu %8.3f",
|
fprintf(outfile, "%7lu %8.3f",
|
||||||
range_p->backups,
|
range_p->backups,
|
||||||
(float)(100 * range_p->backups) /
|
(float)(100 * range_p->backups) /
|
||||||
|
|
@ -140,7 +141,7 @@ int output_txt(void)
|
||||||
fprintf(outfile, "Shared networks:\n");
|
fprintf(outfile, "Shared networks:\n");
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"name max cur percent touch t+c t+c perc");
|
"name max cur percent touch t+c t+c perc");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, " bu bu perc");
|
fprintf(outfile, " bu bu perc");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
@ -159,7 +160,7 @@ int output_txt(void)
|
||||||
(shared_p->touched +
|
(shared_p->touched +
|
||||||
shared_p->used)) /
|
shared_p->used)) /
|
||||||
shared_p->available);
|
shared_p->available);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, "%7lu %8.3f",
|
fprintf(outfile, "%7lu %8.3f",
|
||||||
shared_p->backups,
|
shared_p->backups,
|
||||||
(float)(100 * shared_p->backups) /
|
(float)(100 * shared_p->backups) /
|
||||||
|
|
@ -178,7 +179,7 @@ int output_txt(void)
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"name max cur percent touch t+c t+c perc");
|
"name max cur percent touch t+c t+c perc");
|
||||||
|
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, " bu bu perc");
|
fprintf(outfile, " bu bu perc");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
@ -197,7 +198,7 @@ int output_txt(void)
|
||||||
shared_networks->used)) /
|
shared_networks->used)) /
|
||||||
shared_networks->available);
|
shared_networks->available);
|
||||||
|
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, "%7lu %8.3f",
|
fprintf(outfile, "%7lu %8.3f",
|
||||||
shared_networks->backups,
|
shared_networks->backups,
|
||||||
(float)(100 * shared_networks->backups) /
|
(float)(100 * shared_networks->backups) /
|
||||||
|
|
@ -710,7 +711,7 @@ int output_html(void)
|
||||||
output_line(outfile, "th", "ralign", "touch");
|
output_line(outfile, "th", "ralign", "touch");
|
||||||
output_line(outfile, "th", "ralign", "t+c");
|
output_line(outfile, "th", "ralign", "t+c");
|
||||||
output_line(outfile, "th", "ralign", "t+c perc");
|
output_line(outfile, "th", "ralign", "t+c perc");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
output_line(outfile, "th", "ralign", "bu");
|
output_line(outfile, "th", "ralign", "bu");
|
||||||
output_line(outfile, "th", "ralign", "bu perc");
|
output_line(outfile, "th", "ralign", "bu perc");
|
||||||
}
|
}
|
||||||
|
|
@ -742,7 +743,7 @@ int output_html(void)
|
||||||
(float)(100 *
|
(float)(100 *
|
||||||
(range_p->touched +
|
(range_p->touched +
|
||||||
range_p->count)) / range_size);
|
range_p->count)) / range_size);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
output_long(outfile, "td", range_p->backups);
|
output_long(outfile, "td", range_p->backups);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
(float)(100 *
|
(float)(100 *
|
||||||
|
|
@ -766,7 +767,7 @@ int output_html(void)
|
||||||
output_line(outfile, "th", "ralign", "touch");
|
output_line(outfile, "th", "ralign", "touch");
|
||||||
output_line(outfile, "th", "ralign", "t+c");
|
output_line(outfile, "th", "ralign", "t+c");
|
||||||
output_line(outfile, "th", "ralign", "t+c perc");
|
output_line(outfile, "th", "ralign", "t+c perc");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
output_line(outfile, "th", "ralign", "bu");
|
output_line(outfile, "th", "ralign", "bu");
|
||||||
output_line(outfile, "th", "ralign", "bu perc");
|
output_line(outfile, "th", "ralign", "bu perc");
|
||||||
}
|
}
|
||||||
|
|
@ -790,7 +791,7 @@ int output_html(void)
|
||||||
(shared_p->touched +
|
(shared_p->touched +
|
||||||
shared_p->used)) /
|
shared_p->used)) /
|
||||||
shared_p->available);
|
shared_p->available);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
output_long(outfile, "td", shared_p->backups);
|
output_long(outfile, "td", shared_p->backups);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
(float)(100 *
|
(float)(100 *
|
||||||
|
|
@ -811,7 +812,7 @@ int output_html(void)
|
||||||
output_line(outfile, "th", "ralign", "touch");
|
output_line(outfile, "th", "ralign", "touch");
|
||||||
output_line(outfile, "th", "ralign", "t+c");
|
output_line(outfile, "th", "ralign", "t+c");
|
||||||
output_line(outfile, "th", "ralign", "t+c perc");
|
output_line(outfile, "th", "ralign", "t+c perc");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
output_line(outfile, "th", "ralign", "bu");
|
output_line(outfile, "th", "ralign", "bu");
|
||||||
output_line(outfile, "th", "ralign", "bu perc");
|
output_line(outfile, "th", "ralign", "bu perc");
|
||||||
}
|
}
|
||||||
|
|
@ -834,7 +835,7 @@ int output_html(void)
|
||||||
(shared_networks->touched +
|
(shared_networks->touched +
|
||||||
shared_networks->used)) /
|
shared_networks->used)) /
|
||||||
shared_networks->available);
|
shared_networks->available);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
output_long(outfile, "td", shared_networks->backups);
|
output_long(outfile, "td", shared_networks->backups);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
(float)(100 *
|
(float)(100 *
|
||||||
|
|
@ -889,7 +890,7 @@ int output_csv(void)
|
||||||
fprintf
|
fprintf
|
||||||
(outfile,
|
(outfile,
|
||||||
"\"shared net name\",\"first ip\",\"last ip\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
|
"\"shared net name\",\"first ip\",\"last ip\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
@ -914,7 +915,7 @@ int output_csv(void)
|
||||||
(float)(100 *
|
(float)(100 *
|
||||||
(range_p->touched +
|
(range_p->touched +
|
||||||
range_p->count)) / range_size);
|
range_p->count)) / range_size);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, ",\"%lu\",\"%.3f\"",
|
fprintf(outfile, ",\"%lu\",\"%.3f\"",
|
||||||
range_p->backups,
|
range_p->backups,
|
||||||
(float)(100 * range_p->backups) /
|
(float)(100 * range_p->backups) /
|
||||||
|
|
@ -931,7 +932,7 @@ int output_csv(void)
|
||||||
fprintf(outfile, "\"Shared networks:\"\n");
|
fprintf(outfile, "\"Shared networks:\"\n");
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
|
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
@ -951,7 +952,7 @@ int output_csv(void)
|
||||||
(shared_p->touched +
|
(shared_p->touched +
|
||||||
shared_p->used)) /
|
shared_p->used)) /
|
||||||
shared_p->available);
|
shared_p->available);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, ",\"%lu\",\"%.3f\"",
|
fprintf(outfile, ",\"%lu\",\"%.3f\"",
|
||||||
shared_p->backups,
|
shared_p->backups,
|
||||||
(float)(100 * shared_p->backups) /
|
(float)(100 * shared_p->backups) /
|
||||||
|
|
@ -966,7 +967,7 @@ int output_csv(void)
|
||||||
fprintf(outfile, "\"Sum of all ranges:\"\n");
|
fprintf(outfile, "\"Sum of all ranges:\"\n");
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
|
"\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\"");
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
@ -985,7 +986,7 @@ int output_csv(void)
|
||||||
(shared_networks->touched +
|
(shared_networks->touched +
|
||||||
shared_networks->used)) /
|
shared_networks->used)) /
|
||||||
shared_networks->available);
|
shared_networks->available);
|
||||||
if (0 < num_backups) {
|
if (config.backups_found == true) {
|
||||||
fprintf(outfile, "%7lu %8.3f",
|
fprintf(outfile, "%7lu %8.3f",
|
||||||
shared_networks->backups,
|
shared_networks->backups,
|
||||||
(float)(100 * shared_networks->backups) /
|
(float)(100 * shared_networks->backups) /
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue