mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 15:57:00 +00:00
use bitmap for booleans and other config that has known size
Bitmaps are more c style than bool coming from c++ land. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
5ed9958b69
commit
b524296016
4 changed files with 72 additions and 72 deletions
|
|
@ -42,7 +42,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
@ -77,6 +76,15 @@ int (*output_analysis) (void);
|
||||||
void (*add_lease) (union ipaddr_t *ip, enum ltype type);
|
void (*add_lease) (union ipaddr_t *ip, enum ltype type);
|
||||||
struct leases_t *(*find_lease) (union ipaddr_t *ip);
|
struct leases_t *(*find_lease) (union ipaddr_t *ip);
|
||||||
|
|
||||||
|
static int return_limit(const char c)
|
||||||
|
{
|
||||||
|
if ('0' <= c && c < '8')
|
||||||
|
return c - '0';
|
||||||
|
clean_up();
|
||||||
|
error(EXIT_FAILURE, 0, "return_limit: output mask '%s' is illegal", optarg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*! \brief Start of execution. Parse options, and call other other
|
/*! \brief Start of execution. Parse options, and call other other
|
||||||
* functions one after another. At the moment adding threading support
|
* functions one after another. At the moment adding threading support
|
||||||
* would be difficult, but there does not seem to be valid reason to
|
* would be difficult, but there does not seem to be valid reason to
|
||||||
|
|
@ -142,9 +150,9 @@ int main(int argc, char **argv)
|
||||||
strncpy(config.dhcpdconf_file, DHCPDCONF_FILE, MAXLEN - 1);
|
strncpy(config.dhcpdconf_file, DHCPDCONF_FILE, MAXLEN - 1);
|
||||||
strncpy(config.dhcpdlease_file, DHCPDLEASE_FILE, MAXLEN - 1);
|
strncpy(config.dhcpdlease_file, DHCPDLEASE_FILE, MAXLEN - 1);
|
||||||
tmp = OUTPUT_LIMIT;
|
tmp = OUTPUT_LIMIT;
|
||||||
config.output_limit[0] = (*tmp - '0');
|
config.header_limit = (*tmp - '0');
|
||||||
tmp++;
|
tmp++;
|
||||||
config.output_limit[1] = (*tmp - '0');
|
config.number_limit = (*tmp - '0');
|
||||||
/* Make sure some output format is selected by default */
|
/* Make sure some output format is selected by default */
|
||||||
strncpy(config.output_format, OUTPUT_FORMAT, (size_t)1);
|
strncpy(config.output_format, OUTPUT_FORMAT, (size_t)1);
|
||||||
/* Default sort order is by IPs small to big */
|
/* Default sort order is by IPs small to big */
|
||||||
|
|
@ -200,15 +208,8 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
/* Specification what will be printed */
|
/* Specification what will be printed */
|
||||||
for (i = 0; i < 2; i++) {
|
config.header_limit = return_limit(optarg[0]);
|
||||||
if (optarg[i] >= '0' && optarg[i] < '8')
|
config.number_limit = return_limit(optarg[1]);
|
||||||
config.output_limit[i] = optarg[i] - '0';
|
|
||||||
else {
|
|
||||||
clean_up();
|
|
||||||
error(EXIT_FAILURE, 0,
|
|
||||||
"main: output mask `%s' is illegal", optarg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case OPT_SNET_ALARMS:
|
case OPT_SNET_ALARMS:
|
||||||
config.snet_alarms = true;
|
config.snet_alarms = true;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@
|
||||||
|
|
||||||
# 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>
|
||||||
|
|
@ -198,16 +197,18 @@ struct configuration_t {
|
||||||
char *dhcpdlease_file;
|
char *dhcpdlease_file;
|
||||||
char output_format[2];
|
char output_format[2];
|
||||||
struct output_sort *sorts;
|
struct output_sort *sorts;
|
||||||
bool reverse_order;
|
|
||||||
char *output_file;
|
char *output_file;
|
||||||
int output_limit[2];
|
|
||||||
bool backups_found;
|
|
||||||
bool snet_alarms;
|
|
||||||
double warning;
|
double warning;
|
||||||
double critical;
|
double critical;
|
||||||
double warn_count;
|
double warn_count;
|
||||||
double crit_count;
|
double crit_count;
|
||||||
double minsize;
|
double minsize;
|
||||||
|
unsigned int
|
||||||
|
reverse_order:1,
|
||||||
|
backups_found:1,
|
||||||
|
snet_alarms:1,
|
||||||
|
header_limit:3,
|
||||||
|
number_limit:3;
|
||||||
};
|
};
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
/* \var prefix_length Length of each prefix. */
|
/* \var prefix_length Length of each prefix. */
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
||||||
107
src/output.c
107
src/output.c
|
|
@ -45,7 +45,6 @@
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
#include <math.h>
|
#include <math.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>
|
||||||
|
|
@ -82,7 +81,7 @@ int output_txt(void)
|
||||||
range_size = get_range_size(range_p);
|
range_size = get_range_size(range_p);
|
||||||
shared_p = shared_networks;
|
shared_p = shared_networks;
|
||||||
|
|
||||||
if (config.output_limit[0] & R_BIT) {
|
if (config.header_limit & R_BIT) {
|
||||||
fprintf(outfile, "Ranges:\n");
|
fprintf(outfile, "Ranges:\n");
|
||||||
fprintf
|
fprintf
|
||||||
(outfile,
|
(outfile,
|
||||||
|
|
@ -92,12 +91,12 @@ int output_txt(void)
|
||||||
"first ip",
|
"first ip",
|
||||||
max_ipaddr_length,
|
max_ipaddr_length,
|
||||||
"last ip", "max", "cur", "percent", "touch", "t+c", "t+c perc");
|
"last ip", "max", "cur", "percent", "touch", "t+c", "t+c perc");
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, " bu bu perc");
|
fprintf(outfile, " bu bu perc");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & R_BIT) {
|
if (config.number_limit & R_BIT) {
|
||||||
for (i = 0; i < num_ranges; i++) {
|
for (i = 0; i < num_ranges; i++) {
|
||||||
if (range_p->shared_net) {
|
if (range_p->shared_net) {
|
||||||
fprintf(outfile, "%-20s", range_p->shared_net->name);
|
fprintf(outfile, "%-20s", range_p->shared_net->name);
|
||||||
|
|
@ -119,7 +118,7 @@ int output_txt(void)
|
||||||
range_p->touched,
|
range_p->touched,
|
||||||
range_p->touched + range_p->count,
|
range_p->touched + range_p->count,
|
||||||
(float)(100 * (range_p->touched + range_p->count)) / range_size);
|
(float)(100 * (range_p->touched + range_p->count)) / range_size);
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, "%7g %8.3f",
|
fprintf(outfile, "%7g %8.3f",
|
||||||
range_p->backups,
|
range_p->backups,
|
||||||
(float)(100 * range_p->backups) / range_size);
|
(float)(100 * range_p->backups) / range_size);
|
||||||
|
|
@ -129,19 +128,19 @@ int output_txt(void)
|
||||||
range_size = get_range_size(range_p);
|
range_size = get_range_size(range_p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & R_BIT && config.output_limit[0] & S_BIT) {
|
if (config.number_limit & R_BIT && config.header_limit & S_BIT) {
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[0] & S_BIT) {
|
if (config.header_limit & S_BIT) {
|
||||||
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 (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, " bu bu perc");
|
fprintf(outfile, " bu bu perc");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & S_BIT) {
|
if (config.number_limit & S_BIT) {
|
||||||
for (i = 0; i < num_shared_networks; i++) {
|
for (i = 0; i < num_shared_networks; i++) {
|
||||||
shared_p++;
|
shared_p++;
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
|
|
@ -154,7 +153,7 @@ int output_txt(void)
|
||||||
shared_p->available ==
|
shared_p->available ==
|
||||||
0 ? -NAN : ((float)(100 * (shared_p->touched + shared_p->used)) /
|
0 ? -NAN : ((float)(100 * (shared_p->touched + shared_p->used)) /
|
||||||
shared_p->available));
|
shared_p->available));
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, "%7g %8.3f",
|
fprintf(outfile, "%7g %8.3f",
|
||||||
shared_p->backups,
|
shared_p->backups,
|
||||||
(float)(100 * shared_p->backups) / shared_p->available);
|
(float)(100 * shared_p->backups) / shared_p->available);
|
||||||
|
|
@ -163,20 +162,20 @@ int output_txt(void)
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & S_BIT && config.output_limit[0] & A_BIT) {
|
if (config.number_limit & S_BIT && config.header_limit & A_BIT) {
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[0] & A_BIT) {
|
if (config.header_limit & A_BIT) {
|
||||||
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 (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, " bu bu perc");
|
fprintf(outfile, " bu bu perc");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & A_BIT) {
|
if (config.number_limit & A_BIT) {
|
||||||
fprintf(outfile, "%-20s %5g %5g %10.3f %7g %6g %9.3f",
|
fprintf(outfile, "%-20s %5g %5g %10.3f %7g %6g %9.3f",
|
||||||
shared_networks->name,
|
shared_networks->name,
|
||||||
shared_networks->available,
|
shared_networks->available,
|
||||||
|
|
@ -190,7 +189,7 @@ int output_txt(void)
|
||||||
(shared_networks->touched +
|
(shared_networks->touched +
|
||||||
shared_networks->used)) / shared_networks->available);
|
shared_networks->used)) / shared_networks->available);
|
||||||
|
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, "%7g %8.3f",
|
fprintf(outfile, "%7g %8.3f",
|
||||||
shared_networks->available == 0 ? -NAN : shared_networks->backups,
|
shared_networks->available == 0 ? -NAN : shared_networks->backups,
|
||||||
(float)(100 * shared_networks->backups) /
|
(float)(100 * shared_networks->backups) /
|
||||||
|
|
@ -254,7 +253,7 @@ int output_xml(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.output_limit[1] & R_BIT) {
|
if (config.number_limit & R_BIT) {
|
||||||
for (i = 0; i < num_ranges; i++) {
|
for (i = 0; i < num_ranges; i++) {
|
||||||
fprintf(outfile, "<subnet>\n");
|
fprintf(outfile, "<subnet>\n");
|
||||||
if (range_p->shared_net) {
|
if (range_p->shared_net) {
|
||||||
|
|
@ -275,7 +274,7 @@ int output_xml(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.output_limit[1] & S_BIT) {
|
if (config.number_limit & S_BIT) {
|
||||||
for (i = 0; i < num_shared_networks; i++) {
|
for (i = 0; i < num_shared_networks; i++) {
|
||||||
shared_p++;
|
shared_p++;
|
||||||
fprintf(outfile, "<shared-network>\n");
|
fprintf(outfile, "<shared-network>\n");
|
||||||
|
|
@ -289,7 +288,7 @@ int output_xml(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.output_limit[0] & A_BIT) {
|
if (config.header_limit & A_BIT) {
|
||||||
fprintf(outfile, "<summary>\n");
|
fprintf(outfile, "<summary>\n");
|
||||||
fprintf(outfile, "\t<location>%s</location>\n", shared_networks->name);
|
fprintf(outfile, "\t<location>%s</location>\n", shared_networks->name);
|
||||||
fprintf(outfile, "\t<defined>%g</defined>\n", shared_networks->available);
|
fprintf(outfile, "\t<defined>%g</defined>\n", shared_networks->available);
|
||||||
|
|
@ -367,7 +366,7 @@ int output_json(void)
|
||||||
sep++;
|
sep++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.output_limit[1] & R_BIT) {
|
if (config.number_limit & R_BIT) {
|
||||||
if (sep) {
|
if (sep) {
|
||||||
fprintf(outfile, ",\n");
|
fprintf(outfile, ",\n");
|
||||||
}
|
}
|
||||||
|
|
@ -399,7 +398,7 @@ int output_json(void)
|
||||||
sep++;
|
sep++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.output_limit[1] & S_BIT) {
|
if (config.number_limit & S_BIT) {
|
||||||
if (sep) {
|
if (sep) {
|
||||||
fprintf(outfile, ",\n");
|
fprintf(outfile, ",\n");
|
||||||
}
|
}
|
||||||
|
|
@ -422,7 +421,7 @@ int output_json(void)
|
||||||
sep++;
|
sep++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.output_limit[0] & A_BIT) {
|
if (config.header_limit & A_BIT) {
|
||||||
if (sep) {
|
if (sep) {
|
||||||
fprintf(outfile, ",\n");
|
fprintf(outfile, ",\n");
|
||||||
}
|
}
|
||||||
|
|
@ -618,7 +617,7 @@ int output_html(void)
|
||||||
html_header(outfile);
|
html_header(outfile);
|
||||||
newsection(outfile, "Sum of all");
|
newsection(outfile, "Sum of all");
|
||||||
table_start(outfile, "a", "all");
|
table_start(outfile, "a", "all");
|
||||||
if (config.output_limit[0] & A_BIT) {
|
if (config.header_limit & A_BIT) {
|
||||||
start_tag(outfile, "thead");
|
start_tag(outfile, "thead");
|
||||||
start_tag(outfile, "tr");
|
start_tag(outfile, "tr");
|
||||||
output_line(outfile, "th", "name");
|
output_line(outfile, "th", "name");
|
||||||
|
|
@ -628,14 +627,14 @@ int output_html(void)
|
||||||
output_line(outfile, "th", "touch");
|
output_line(outfile, "th", "touch");
|
||||||
output_line(outfile, "th", "t+c");
|
output_line(outfile, "th", "t+c");
|
||||||
output_line(outfile, "th", "t+c perc");
|
output_line(outfile, "th", "t+c perc");
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
output_line(outfile, "th", "bu");
|
output_line(outfile, "th", "bu");
|
||||||
output_line(outfile, "th", "bu perc");
|
output_line(outfile, "th", "bu perc");
|
||||||
}
|
}
|
||||||
end_tag(outfile, "tr");
|
end_tag(outfile, "tr");
|
||||||
end_tag(outfile, "thead");
|
end_tag(outfile, "thead");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & A_BIT) {
|
if (config.number_limit & A_BIT) {
|
||||||
start_tag(outfile, "tbody");
|
start_tag(outfile, "tbody");
|
||||||
start_tag(outfile, "tr");
|
start_tag(outfile, "tr");
|
||||||
output_line(outfile, "td", shared_networks->name);
|
output_line(outfile, "td", shared_networks->name);
|
||||||
|
|
@ -653,7 +652,7 @@ int output_html(void)
|
||||||
+
|
+
|
||||||
shared_networks->used))
|
shared_networks->used))
|
||||||
/ shared_networks->available);
|
/ shared_networks->available);
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
output_double(outfile, "td", shared_networks->backups);
|
output_double(outfile, "td", shared_networks->backups);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
shared_networks->available == 0 ? -NAN : (float)(100 *
|
shared_networks->available == 0 ? -NAN : (float)(100 *
|
||||||
|
|
@ -666,7 +665,7 @@ int output_html(void)
|
||||||
table_end(outfile);
|
table_end(outfile);
|
||||||
newsection(outfile, "Shared networks");
|
newsection(outfile, "Shared networks");
|
||||||
table_start(outfile, "s", "snet");
|
table_start(outfile, "s", "snet");
|
||||||
if (config.output_limit[0] & S_BIT) {
|
if (config.header_limit & S_BIT) {
|
||||||
start_tag(outfile, "thead");
|
start_tag(outfile, "thead");
|
||||||
start_tag(outfile, "tr");
|
start_tag(outfile, "tr");
|
||||||
output_line(outfile, "th", "name");
|
output_line(outfile, "th", "name");
|
||||||
|
|
@ -676,14 +675,14 @@ int output_html(void)
|
||||||
output_line(outfile, "th", "touch");
|
output_line(outfile, "th", "touch");
|
||||||
output_line(outfile, "th", "t+c");
|
output_line(outfile, "th", "t+c");
|
||||||
output_line(outfile, "th", "t+c perc");
|
output_line(outfile, "th", "t+c perc");
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
output_line(outfile, "th", "bu");
|
output_line(outfile, "th", "bu");
|
||||||
output_line(outfile, "th", "bu perc");
|
output_line(outfile, "th", "bu perc");
|
||||||
}
|
}
|
||||||
end_tag(outfile, "tr");
|
end_tag(outfile, "tr");
|
||||||
end_tag(outfile, "thead");
|
end_tag(outfile, "thead");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & S_BIT) {
|
if (config.number_limit & S_BIT) {
|
||||||
start_tag(outfile, "tbody");
|
start_tag(outfile, "tbody");
|
||||||
for (i = 0; i < num_shared_networks; i++) {
|
for (i = 0; i < num_shared_networks; i++) {
|
||||||
shared_p++;
|
shared_p++;
|
||||||
|
|
@ -702,7 +701,7 @@ int output_html(void)
|
||||||
(shared_p->touched +
|
(shared_p->touched +
|
||||||
shared_p->used)) /
|
shared_p->used)) /
|
||||||
shared_p->available);
|
shared_p->available);
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
output_double(outfile, "td", shared_p->backups);
|
output_double(outfile, "td", shared_p->backups);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
shared_p->available == 0 ? -NAN : (float)(100 *
|
shared_p->available == 0 ? -NAN : (float)(100 *
|
||||||
|
|
@ -716,7 +715,7 @@ int output_html(void)
|
||||||
table_end(outfile);
|
table_end(outfile);
|
||||||
newsection(outfile, "Ranges");
|
newsection(outfile, "Ranges");
|
||||||
table_start(outfile, "r", "ranges");
|
table_start(outfile, "r", "ranges");
|
||||||
if (config.output_limit[0] & R_BIT) {
|
if (config.header_limit & R_BIT) {
|
||||||
start_tag(outfile, "thead");
|
start_tag(outfile, "thead");
|
||||||
start_tag(outfile, "tr");
|
start_tag(outfile, "tr");
|
||||||
output_line(outfile, "th", "shared net name");
|
output_line(outfile, "th", "shared net name");
|
||||||
|
|
@ -728,14 +727,14 @@ int output_html(void)
|
||||||
output_line(outfile, "th", "touch");
|
output_line(outfile, "th", "touch");
|
||||||
output_line(outfile, "th", "t+c");
|
output_line(outfile, "th", "t+c");
|
||||||
output_line(outfile, "th", "t+c perc");
|
output_line(outfile, "th", "t+c perc");
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
output_line(outfile, "th", "bu");
|
output_line(outfile, "th", "bu");
|
||||||
output_line(outfile, "th", "bu perc");
|
output_line(outfile, "th", "bu perc");
|
||||||
}
|
}
|
||||||
end_tag(outfile, "tr");
|
end_tag(outfile, "tr");
|
||||||
end_tag(outfile, "thead");
|
end_tag(outfile, "thead");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & R_BIT) {
|
if (config.number_limit & R_BIT) {
|
||||||
start_tag(outfile, "tbody");
|
start_tag(outfile, "tbody");
|
||||||
for (i = 0; i < num_ranges; i++) {
|
for (i = 0; i < num_ranges; i++) {
|
||||||
start_tag(outfile, "tr");
|
start_tag(outfile, "tr");
|
||||||
|
|
@ -754,7 +753,7 @@ int output_html(void)
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
(float)(100 *
|
(float)(100 *
|
||||||
(range_p->touched + range_p->count)) / range_size);
|
(range_p->touched + range_p->count)) / range_size);
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
output_double(outfile, "td", range_p->backups);
|
output_double(outfile, "td", range_p->backups);
|
||||||
output_float(outfile, "td",
|
output_float(outfile, "td",
|
||||||
(float)(100 * range_p->backups) / range_size);
|
(float)(100 * range_p->backups) / range_size);
|
||||||
|
|
@ -803,17 +802,17 @@ int output_csv(void)
|
||||||
range_p = ranges;
|
range_p = ranges;
|
||||||
range_size = get_range_size(range_p);
|
range_size = get_range_size(range_p);
|
||||||
shared_p = shared_networks;
|
shared_p = shared_networks;
|
||||||
if (config.output_limit[0] & R_BIT) {
|
if (config.header_limit & R_BIT) {
|
||||||
fprintf(outfile, "\"Ranges:\"\n");
|
fprintf(outfile, "\"Ranges:\"\n");
|
||||||
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 (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & R_BIT) {
|
if (config.number_limit & R_BIT) {
|
||||||
for (i = 0; i < num_ranges; i++) {
|
for (i = 0; i < num_ranges; i++) {
|
||||||
if (range_p->shared_net) {
|
if (range_p->shared_net) {
|
||||||
fprintf(outfile, "\"%s\",", range_p->shared_net->name);
|
fprintf(outfile, "\"%s\",", range_p->shared_net->name);
|
||||||
|
|
@ -829,7 +828,7 @@ int output_csv(void)
|
||||||
range_p->touched,
|
range_p->touched,
|
||||||
range_p->touched + range_p->count,
|
range_p->touched + range_p->count,
|
||||||
(float)(100 * (range_p->touched + range_p->count)) / range_size);
|
(float)(100 * (range_p->touched + range_p->count)) / range_size);
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, ",\"%g\",\"%.3f\"",
|
fprintf(outfile, ",\"%g\",\"%.3f\"",
|
||||||
range_p->backups,
|
range_p->backups,
|
||||||
(float)(100 * range_p->backups) / range_size);
|
(float)(100 * range_p->backups) / range_size);
|
||||||
|
|
@ -841,16 +840,16 @@ int output_csv(void)
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[0] & S_BIT) {
|
if (config.header_limit & S_BIT) {
|
||||||
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 (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & S_BIT) {
|
if (config.number_limit & S_BIT) {
|
||||||
|
|
||||||
for (i = 0; i < num_shared_networks; i++) {
|
for (i = 0; i < num_shared_networks; i++) {
|
||||||
shared_p++;
|
shared_p++;
|
||||||
|
|
@ -865,7 +864,7 @@ int output_csv(void)
|
||||||
(shared_p->touched +
|
(shared_p->touched +
|
||||||
shared_p->used)) /
|
shared_p->used)) /
|
||||||
shared_p->available);
|
shared_p->available);
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, ",\"%g\",\"%.3f\"",
|
fprintf(outfile, ",\"%g\",\"%.3f\"",
|
||||||
shared_p->backups,
|
shared_p->backups,
|
||||||
shared_p->available ==
|
shared_p->available ==
|
||||||
|
|
@ -877,16 +876,16 @@ int output_csv(void)
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[0] & A_BIT) {
|
if (config.header_limit & A_BIT) {
|
||||||
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 (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
fprintf(outfile, ",\"bu\",\"bu perc\"");
|
||||||
}
|
}
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & A_BIT) {
|
if (config.number_limit & A_BIT) {
|
||||||
|
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"",
|
"\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"",
|
||||||
|
|
@ -900,7 +899,7 @@ int output_csv(void)
|
||||||
0 ? -NAN : (float)(100 *
|
0 ? -NAN : (float)(100 *
|
||||||
(shared_networks->touched +
|
(shared_networks->touched +
|
||||||
shared_networks->used)) / shared_networks->available);
|
shared_networks->used)) / shared_networks->available);
|
||||||
if (config.backups_found == true) {
|
if (config.backups_found == 1) {
|
||||||
fprintf(outfile, "%7g %8.3f",
|
fprintf(outfile, "%7g %8.3f",
|
||||||
shared_networks->backups,
|
shared_networks->backups,
|
||||||
shared_networks->available ==
|
shared_networks->available ==
|
||||||
|
|
@ -948,7 +947,7 @@ int output_alarming(void)
|
||||||
outfile = stdout;
|
outfile = stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.output_limit[1] & R_BIT) {
|
if (config.number_limit & R_BIT) {
|
||||||
for (i = 0; i < num_ranges; i++) {
|
for (i = 0; i < num_ranges; i++) {
|
||||||
if (config.snet_alarms && range_p->shared_net != shared_networks) {
|
if (config.snet_alarms && range_p->shared_net != shared_networks) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -968,7 +967,7 @@ int output_alarming(void)
|
||||||
range_size = get_range_size(range_p);
|
range_size = get_range_size(range_p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config.output_limit[1] & S_BIT) {
|
if (config.number_limit & S_BIT) {
|
||||||
for (i = 0; i < num_shared_networks; i++) {
|
for (i = 0; i < num_shared_networks; i++) {
|
||||||
shared_p++;
|
shared_p++;
|
||||||
if (config.minsize < shared_p->available) {
|
if (config.minsize < shared_p->available) {
|
||||||
|
|
@ -994,19 +993,19 @@ int output_alarming(void)
|
||||||
else
|
else
|
||||||
ret_val = STATE_OK;
|
ret_val = STATE_OK;
|
||||||
|
|
||||||
if ((0 < rc && config.output_limit[1] & R_BIT)
|
if ((0 < rc && config.number_limit & R_BIT)
|
||||||
|| (0 < sc && config.output_limit[1] & S_BIT)) {
|
|| (0 < sc && config.number_limit & S_BIT)) {
|
||||||
fprintf(outfile, "CRITICAL: %s:", program_name);
|
fprintf(outfile, "CRITICAL: %s:", program_name);
|
||||||
} else if ((0 < rw && config.output_limit[1] & R_BIT)
|
} else if ((0 < rw && config.number_limit & R_BIT)
|
||||||
|| (0 < sw && config.output_limit[1] & S_BIT)) {
|
|| (0 < sw && config.number_limit & S_BIT)) {
|
||||||
fprintf(outfile, "WARNING: %s:", program_name);
|
fprintf(outfile, "WARNING: %s:", program_name);
|
||||||
} else {
|
} else {
|
||||||
if (config.output_limit[1] & A_BIT)
|
if (config.number_limit & A_BIT)
|
||||||
fprintf(outfile, "OK:");
|
fprintf(outfile, "OK:");
|
||||||
else
|
else
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
if (config.output_limit[0] & R_BIT) {
|
if (config.header_limit & R_BIT) {
|
||||||
fprintf(outfile, " Ranges - crit: %d warn: %d ok: %d", rc, rw, ro);
|
fprintf(outfile, " Ranges - crit: %d warn: %d ok: %d", rc, rw, ro);
|
||||||
if (ri != 0) {
|
if (ri != 0) {
|
||||||
fprintf(outfile, " ignored: %d", ri);
|
fprintf(outfile, " ignored: %d", ri);
|
||||||
|
|
@ -1019,7 +1018,7 @@ int output_alarming(void)
|
||||||
} else {
|
} else {
|
||||||
fprintf(outfile, " ");
|
fprintf(outfile, " ");
|
||||||
}
|
}
|
||||||
if (config.output_limit[0] & S_BIT) {
|
if (config.header_limit & S_BIT) {
|
||||||
fprintf(outfile, "Shared nets - crit: %d warn: %d ok: %d", sc, sw, so);
|
fprintf(outfile, "Shared nets - crit: %d warn: %d ok: %d", sc, sw, so);
|
||||||
if (si != 0) {
|
if (si != 0) {
|
||||||
fprintf(outfile, " ignored: %d", si);
|
fprintf(outfile, " ignored: %d", si);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue