New upstream version 2.3.3
This commit is contained in:
parent
21323d25dd
commit
e7bdd1c6c6
49 changed files with 13068 additions and 34075 deletions
|
@ -1,32 +1,32 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
*
|
||||
* Monitoring check_apt plugin
|
||||
*
|
||||
*
|
||||
* License: GPL
|
||||
* Copyright (c) 2006-2008 Monitoring Plugins Development Team
|
||||
*
|
||||
*
|
||||
* Original author: Sean Finney
|
||||
*
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
*
|
||||
* This file contains the check_apt plugin
|
||||
*
|
||||
*
|
||||
* Check for available updates in apt package management systems
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
const char *progname = "check_apt";
|
||||
|
@ -76,9 +76,9 @@ int cmpstringp(const void *p1, const void *p2);
|
|||
|
||||
/* configuration variables */
|
||||
static int verbose = 0; /* -v */
|
||||
static int list = 0; /* list packages available for upgrade */
|
||||
static int do_update = 0; /* whether to call apt-get update */
|
||||
static int only_critical = 0; /* whether to warn about non-critical updates */
|
||||
static bool list = false; /* list packages available for upgrade */
|
||||
static bool do_update = false; /* whether to call apt-get update */
|
||||
static bool only_critical = false; /* 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 */
|
||||
|
@ -119,7 +119,7 @@ int main (int argc, char **argv) {
|
|||
|
||||
if(sec_count > 0){
|
||||
result = max_state(result, STATE_CRITICAL);
|
||||
} else if(packages_available >= packages_warning && only_critical == 0){
|
||||
} else if(packages_available >= packages_warning && only_critical == false){
|
||||
result = max_state(result, STATE_WARNING);
|
||||
} else if(result > STATE_UNKNOWN){
|
||||
result = STATE_UNKNOWN;
|
||||
|
@ -144,7 +144,7 @@ int main (int argc, char **argv) {
|
|||
|
||||
for(i = 0; i < sec_count; i++)
|
||||
printf("%s (security)\n", secpackages_list[i]);
|
||||
if (only_critical == 0) {
|
||||
if (only_critical == false) {
|
||||
for(i = 0; i < packages_available - sec_count; i++)
|
||||
printf("%s\n", packages_list[i]);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ int process_arguments (int argc, char **argv) {
|
|||
{"upgrade", optional_argument, 0, 'U'},
|
||||
{"no-upgrade", no_argument, 0, 'n'},
|
||||
{"dist-upgrade", optional_argument, 0, 'd'},
|
||||
{"list", no_argument, 0, 'l'},
|
||||
{"list", no_argument, false, 'l'},
|
||||
{"include", required_argument, 0, 'i'},
|
||||
{"exclude", required_argument, 0, 'e'},
|
||||
{"critical", required_argument, 0, 'c'},
|
||||
|
@ -212,14 +212,14 @@ int process_arguments (int argc, char **argv) {
|
|||
upgrade=NO_UPGRADE;
|
||||
break;
|
||||
case 'u':
|
||||
do_update=1;
|
||||
do_update=true;
|
||||
if(optarg!=NULL){
|
||||
update_opts=strdup(optarg);
|
||||
if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
list=1;
|
||||
list=true;
|
||||
break;
|
||||
case 'i':
|
||||
do_include=add_to_regexp(do_include, optarg);
|
||||
|
@ -231,7 +231,7 @@ int process_arguments (int argc, char **argv) {
|
|||
do_critical=add_to_regexp(do_critical, optarg);
|
||||
break;
|
||||
case 'o':
|
||||
only_critical=1;
|
||||
only_critical=true;
|
||||
break;
|
||||
case INPUT_FILE_OPT:
|
||||
input_filename = optarg;
|
||||
|
@ -269,7 +269,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
|
|||
die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(do_exclude!=NULL){
|
||||
regres=regcomp(&ereg, do_exclude, REG_EXTENDED);
|
||||
if(regres!=0) {
|
||||
|
@ -278,7 +278,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
|
|||
progname, rerrbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE;
|
||||
regres=regcomp(&sreg, crit_ptr, REG_EXTENDED);
|
||||
if(regres!=0) {
|
||||
|
@ -295,7 +295,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
|
|||
/* run the upgrade */
|
||||
result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
|
||||
}
|
||||
|
||||
|
||||
/* apt-get upgrade only changes exit status if there is an
|
||||
* internal error when run in dry-run mode. therefore we will
|
||||
* treat such an error as UNKNOWN */
|
||||
|
@ -371,7 +371,7 @@ int run_update(void){
|
|||
struct output chld_out, chld_err;
|
||||
char *cmdline;
|
||||
|
||||
/* run the upgrade */
|
||||
/* run the update */
|
||||
cmdline = construct_cmdline(NO_UPGRADE, update_opts);
|
||||
result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
|
||||
/* apt-get update changes exit status if it can't fetch packages.
|
||||
|
@ -501,16 +501,6 @@ print_help (void)
|
|||
|
||||
printf(UT_PLUG_TIMEOUT, timeout_interval);
|
||||
|
||||
printf (" %s\n", "-U, --upgrade=OPTS");
|
||||
printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
|
||||
printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
|
||||
printf (" %s", _("default "));
|
||||
printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
|
||||
printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
|
||||
printf (" %s\n", _("the default options."));
|
||||
printf (" %s\n", "-d, --dist-upgrade=OPTS");
|
||||
printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
|
||||
printf (" %s\n", _("can be provided to override the default options."));
|
||||
printf (" %s\n", "-n, --no-upgrade");
|
||||
printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
|
||||
printf (" %s\n", "-l, --list");
|
||||
|
@ -530,7 +520,7 @@ print_help (void)
|
|||
printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified"));
|
||||
printf (" %s\n", _("multiple times like above. Default is a regexp matching security"));
|
||||
printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
|
||||
printf (" \t\%s\n", SECURITY_RE);
|
||||
printf (" \t%s\n", SECURITY_RE);
|
||||
printf (" %s\n", _("Note that the package must first match the include list before its"));
|
||||
printf (" %s\n", _("information is compared against the critical list."));
|
||||
printf (" %s\n", "-o, --only-critical");
|
||||
|
@ -538,7 +528,7 @@ print_help (void)
|
|||
printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
|
||||
printf (" %s\n", _("the plugin to return WARNING status."));
|
||||
printf (" %s\n", "-w, --packages-warning");
|
||||
printf (" %s\n", _("Minumum number of packages available for upgrade to return WARNING status."));
|
||||
printf (" %s\n", _("Minimum number of packages available for upgrade to return WARNING status."));
|
||||
printf (" %s\n\n", _("Default is 1 package."));
|
||||
|
||||
printf ("%s\n\n", _("The following options require root privileges and should be used with care:"));
|
||||
|
@ -547,6 +537,16 @@ print_help (void)
|
|||
printf (" %s\n", _("the default options. Note: you may also need to adjust the global"));
|
||||
printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get"));
|
||||
printf (" %s\n", _("upgrade is expected to take longer than the default timeout."));
|
||||
printf (" %s\n", "-U, --upgrade=OPTS");
|
||||
printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,"));
|
||||
printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
|
||||
printf (" %s", _("default "));
|
||||
printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
|
||||
printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
|
||||
printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade"));
|
||||
printf (" %s\n", "-d, --dist-upgrade=OPTS");
|
||||
printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
|
||||
printf (" %s\n", _("can be provided to override the default options."));
|
||||
|
||||
printf(UT_SUPPORT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue