aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_apt.c
diff options
context:
space:
mode:
authorGravatar Christian Schmidt <c960657@users.noreply.github.com> 2016-12-29 16:09:24 +0100
committerGravatar Jan Wagner <waja@cyconet.org> 2016-12-31 12:00:46 +0100
commitbf18dc42dd16811a3e0f42d4591604a4213afb3e (patch)
treef9197f26502f588c01e1d4333814c72f78a7f003 /plugins/check_apt.c
parentf524b15e572c4316feb70917d05f6349bef996ef (diff)
downloadmonitoring-plugins-bf18dc42dd16811a3e0f42d4591604a4213afb3e.tar.gz
Add --only-critical switch to check_apt
Diffstat (limited to 'plugins/check_apt.c')
-rw-r--r--plugins/check_apt.c15
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);
/* configuration variables */
static int verbose = 0; /* -v */
static int do_update = 0; /* whether to call apt-get update */
+static int only_critical = 0; /* whether to warn about non-critical updates */
static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
static char *update_opts = NULL; /* options to override defaults for update */
@@ -110,7 +111,7 @@ int main (int argc, char **argv) {
if(sec_count > 0){
result = max_state(result, STATE_CRITICAL);
- } else if(packages_available > 0){
+ } else if(packages_available > 0 && only_critical == 0){
result = max_state(result, STATE_WARNING);
} else if(result > STATE_UNKNOWN){
result = STATE_UNKNOWN;
@@ -148,12 +149,13 @@ int process_arguments (int argc, char **argv) {
{"include", required_argument, 0, 'i'},
{"exclude", required_argument, 0, 'e'},
{"critical", required_argument, 0, 'c'},
+ {"only-critical", no_argument, 0, 'o'},
{"input-file", required_argument, 0, INPUT_FILE_OPT},
{0, 0, 0, 0}
};
while(1) {
- c = getopt_long(argc, argv, "hVvt:u::U::d::ni:e:c:", longopts, NULL);
+ c = getopt_long(argc, argv, "hVvt:u::U::d::ni:e:c:o", longopts, NULL);
if(c == -1 || c == EOF || c == 1) break;
@@ -203,6 +205,9 @@ int process_arguments (int argc, char **argv) {
case 'c':
do_critical=add_to_regexp(do_critical, optarg);
break;
+ case 'o':
+ only_critical=1;
+ break;
case INPUT_FILE_OPT:
input_filename = optarg;
break;
@@ -463,7 +468,11 @@ print_help (void)
printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
printf (" \t\%s\n", SECURITY_RE);
printf (" %s\n", _("Note that the package must first match the include list before its"));
- printf (" %s\n\n", _("information is compared against the critical list."));
+ printf (" %s\n", _("information is compared against the critical list."));
+ printf (" %s\n", "-o, --only-critical");
+ printf (" %s\n", _("Only warn about upgrades matching the critical list. The total number"));
+ printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
+ printf (" %s\n\n", _("the plugin to return WARNING status."));
printf ("%s\n\n", _("The following options require root privileges and should be used with care:"));
printf (" %s\n", "-u, --update=OPTS");