diff options
author | Jan Wagner <waja@cyconet.org> | 2017-01-04 14:53:16 +0100 |
---|---|---|
committer | Jan Wagner <waja@cyconet.org> | 2017-01-04 14:53:16 +0100 |
commit | 3fc149f4990358a91ca945f8b649a4c511722e73 (patch) | |
tree | d63d3f02ecdea017d91e8fe902b6e30561313e39 /plugins/check_apt.c | |
parent | d9a1fb15dd60935cf1655e6b9786b28e899c8dc8 (diff) | |
parent | bf18dc42dd16811a3e0f42d4591604a4213afb3e (diff) | |
download | monitoring-plugins-3fc149f4990358a91ca945f8b649a4c511722e73.tar.gz |
Merge remote-tracking branch 'upstream/pr/1457'
Diffstat (limited to 'plugins/check_apt.c')
-rw-r--r-- | plugins/check_apt.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/check_apt.c b/plugins/check_apt.c index a639a411..c90b3df7 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c | |||
@@ -73,6 +73,7 @@ char* add_to_regexp(char *expr, const char *next); | |||
73 | /* configuration variables */ | 73 | /* configuration variables */ |
74 | static int verbose = 0; /* -v */ | 74 | static int verbose = 0; /* -v */ |
75 | static int do_update = 0; /* whether to call apt-get update */ | 75 | static int do_update = 0; /* whether to call apt-get update */ |
76 | static int only_critical = 0; /* whether to warn about non-critical updates */ | ||
76 | static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ | 77 | static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ |
77 | static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ | 78 | static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ |
78 | static char *update_opts = NULL; /* options to override defaults for update */ | 79 | static char *update_opts = NULL; /* options to override defaults for update */ |
@@ -110,7 +111,7 @@ int main (int argc, char **argv) { | |||
110 | 111 | ||
111 | if(sec_count > 0){ | 112 | if(sec_count > 0){ |
112 | result = max_state(result, STATE_CRITICAL); | 113 | result = max_state(result, STATE_CRITICAL); |
113 | } else if(packages_available > 0){ | 114 | } else if(packages_available > 0 && only_critical == 0){ |
114 | result = max_state(result, STATE_WARNING); | 115 | result = max_state(result, STATE_WARNING); |
115 | } else if(result > STATE_UNKNOWN){ | 116 | } else if(result > STATE_UNKNOWN){ |
116 | result = STATE_UNKNOWN; | 117 | result = STATE_UNKNOWN; |
@@ -148,12 +149,13 @@ int process_arguments (int argc, char **argv) { | |||
148 | {"include", required_argument, 0, 'i'}, | 149 | {"include", required_argument, 0, 'i'}, |
149 | {"exclude", required_argument, 0, 'e'}, | 150 | {"exclude", required_argument, 0, 'e'}, |
150 | {"critical", required_argument, 0, 'c'}, | 151 | {"critical", required_argument, 0, 'c'}, |
152 | {"only-critical", no_argument, 0, 'o'}, | ||
151 | {"input-file", required_argument, 0, INPUT_FILE_OPT}, | 153 | {"input-file", required_argument, 0, INPUT_FILE_OPT}, |
152 | {0, 0, 0, 0} | 154 | {0, 0, 0, 0} |
153 | }; | 155 | }; |
154 | 156 | ||
155 | while(1) { | 157 | while(1) { |
156 | c = getopt_long(argc, argv, "hVvt:u::U::d::ni:e:c:", longopts, NULL); | 158 | c = getopt_long(argc, argv, "hVvt:u::U::d::ni:e:c:o", longopts, NULL); |
157 | 159 | ||
158 | if(c == -1 || c == EOF || c == 1) break; | 160 | if(c == -1 || c == EOF || c == 1) break; |
159 | 161 | ||
@@ -203,6 +205,9 @@ int process_arguments (int argc, char **argv) { | |||
203 | case 'c': | 205 | case 'c': |
204 | do_critical=add_to_regexp(do_critical, optarg); | 206 | do_critical=add_to_regexp(do_critical, optarg); |
205 | break; | 207 | break; |
208 | case 'o': | ||
209 | only_critical=1; | ||
210 | break; | ||
206 | case INPUT_FILE_OPT: | 211 | case INPUT_FILE_OPT: |
207 | input_filename = optarg; | 212 | input_filename = optarg; |
208 | break; | 213 | break; |
@@ -463,7 +468,11 @@ print_help (void) | |||
463 | printf (" %s\n", _("upgrades for Debian and Ubuntu:")); | 468 | printf (" %s\n", _("upgrades for Debian and Ubuntu:")); |
464 | printf (" \t\%s\n", SECURITY_RE); | 469 | printf (" \t\%s\n", SECURITY_RE); |
465 | printf (" %s\n", _("Note that the package must first match the include list before its")); | 470 | printf (" %s\n", _("Note that the package must first match the include list before its")); |
466 | printf (" %s\n\n", _("information is compared against the critical list.")); | 471 | printf (" %s\n", _("information is compared against the critical list.")); |
472 | printf (" %s\n", "-o, --only-critical"); | ||
473 | printf (" %s\n", _("Only warn about upgrades matching the critical list. The total number")); | ||
474 | printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause")); | ||
475 | printf (" %s\n\n", _("the plugin to return WARNING status.")); | ||
467 | 476 | ||
468 | printf ("%s\n\n", _("The following options require root privileges and should be used with care:")); | 477 | printf ("%s\n\n", _("The following options require root privileges and should be used with care:")); |
469 | printf (" %s\n", "-u, --update=OPTS"); | 478 | printf (" %s\n", "-u, --update=OPTS"); |