mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 00:06:59 +00:00
output: add color support to text output
When --warning or --critical thresholds are defined with text output lines that exceed threshold will be either yellow (warning) or red (critical). Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
48962004b8
commit
344ed2900d
8 changed files with 128 additions and 28 deletions
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
|
|
@ -109,6 +110,7 @@ int main(int argc, char **argv)
|
|||
OPT_MINSIZE,
|
||||
OPT_WARN_COUNT,
|
||||
OPT_CRIT_COUNT,
|
||||
OPT_COLOR,
|
||||
OPT_SET_IPV
|
||||
};
|
||||
int ret_val;
|
||||
|
|
@ -116,6 +118,7 @@ int main(int argc, char **argv)
|
|||
static struct option const long_options[] = {
|
||||
{"config", required_argument, NULL, 'c'},
|
||||
{"leases", required_argument, NULL, 'l'},
|
||||
{"color", required_argument, NULL, OPT_COLOR},
|
||||
{"format", required_argument, NULL, 'f'},
|
||||
{"sort", required_argument, NULL, 's'},
|
||||
{"reverse", no_argument, NULL, 'r'},
|
||||
|
|
@ -152,6 +155,7 @@ int main(int argc, char **argv)
|
|||
config.warn_count = 0x100000000; /* == 2^32 that is the entire IPv4 space */
|
||||
config.crit_count = 0x100000000; /* basically turns off the count criteria */
|
||||
config.perfdata = 0;
|
||||
config.color_mode = color_auto;
|
||||
/* File location defaults */
|
||||
strncpy(config.dhcpdconf_file, DHCPDCONF_FILE, MAXLEN - 1);
|
||||
strncpy(config.dhcpdlease_file, DHCPDLEASE_FILE, MAXLEN - 1);
|
||||
|
|
@ -219,6 +223,11 @@ int main(int argc, char **argv)
|
|||
config.header_limit = return_limit(optarg[0]);
|
||||
config.number_limit = return_limit(optarg[1]);
|
||||
break;
|
||||
case OPT_COLOR:
|
||||
config.color_mode = parse_color_mode(optarg);
|
||||
if (config.color_mode == color_unknown)
|
||||
error(EXIT_FAILURE, errno, "unknown color mode: %s", quote(optarg));
|
||||
break;
|
||||
case OPT_SNET_ALARMS:
|
||||
config.snet_alarms = 1;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue