diff options
| author | Christian Schmidt <c960657@users.noreply.github.com> | 2016-12-29 16:09:24 +0100 |
|---|---|---|
| committer | Jan Wagner <waja@cyconet.org> | 2016-12-31 12:00:46 +0100 |
| commit | bf18dc42dd16811a3e0f42d4591604a4213afb3e (patch) | |
| tree | f9197f26502f588c01e1d4333814c72f78a7f003 /plugins/check_apt.c | |
| parent | f524b15e572c4316feb70917d05f6349bef996ef (diff) | |
| download | monitoring-plugins-bf18dc42dd16811a3e0f42d4591604a4213afb3e.tar.gz | |
Add --only-critical switch to check_apt
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"); |
