summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2005-09-18 01:08:45 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2005-09-18 01:08:45 +0000
commit5785f053e1b95a619096fa2bc6bcb0c8911d8acf (patch)
tree8ddb1f8c4566a35a44e3072895dcfaa31b45449e
parent9ab4a8038615a80c380411e5b92e9d9bc7beef73 (diff)
Support --warnifupdates
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@16 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-xnagios-check-apt-updates15
1 files changed, 9 insertions, 6 deletions
diff --git a/nagios-check-apt-updates b/nagios-check-apt-updates
index 7bdc718..c1a58cd 100755
--- a/nagios-check-apt-updates
+++ b/nagios-check-apt-updates
@@ -42,12 +42,13 @@ my $UNKNOWN = 3;
$params->{'chroots'} = [];
Getopt::Long::config('bundling');
if (!GetOptions (
- '--help' => \$params->{'help'},
- '--version' => \$params->{'version'},
- '--sudo' => \$params->{'sudo'},
- '--nosudo' => \$params->{'nosudo'},
- '--verbose' => \$params->{'verbose'},
- '--chroot=s' => $params->{'chroots'},
+ '--help' => \$params->{'help'},
+ '--version' => \$params->{'version'},
+ '--sudo' => \$params->{'sudo'},
+ '--nosudo' => \$params->{'nosudo'},
+ '--verbose' => \$params->{'verbose'},
+ '--warnifupdates' => \$params->{'warnifupdates'},
+ '--chroot=s' => $params->{'chroots'},
)) {
die ("$PROGRAM_NAME: Usage: $PROGRAM_NAME [--help|--version] [--sudo|--nosudo] [--verbose]\n");
};
@@ -59,6 +60,7 @@ if ($params->{'help'}) {
print " --version Report version number.\n";
print " --sudo Use sudo to call apt-get (default).\n";
print " --nosudo Do not use sudo to call apt-get.\n";
+ print " --warnifupdates Exit with a WARNING status if any updates are available.\n";
print " --verbose Be a little verbose.\n";
exit (0);
};
@@ -142,6 +144,7 @@ if (@updates_security) {
};
if (@updates_other) {
$updateinfo .= 'Other Updates ('.(scalar @updates_other).'): '.join(', ', @updates_other)."; ";
+ $exit = $WARNING if $params->{'warnifupdates'};
};
$updateinfo = 'No updates available' unless defined $updateinfo;