diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_apt.c | 664 | ||||
| -rw-r--r-- | plugins/check_curl.c | 2 | ||||
| -rw-r--r-- | plugins/check_disk.c | 22 | ||||
| -rw-r--r-- | plugins/check_fping.c | 23 | ||||
| -rw-r--r-- | plugins/check_ide_smart.c | 6 | ||||
| -rw-r--r-- | plugins/check_ldap.c | 42 | ||||
| -rw-r--r-- | plugins/check_mysql.c | 42 | ||||
| -rw-r--r-- | plugins/check_nt.c | 39 | ||||
| -rw-r--r-- | plugins/check_ntp.c | 8 | ||||
| -rw-r--r-- | plugins/check_nwstat.c | 48 | ||||
| -rw-r--r-- | plugins/check_overcr.c | 31 | ||||
| -rw-r--r-- | plugins/check_procs.c | 58 | ||||
| -rw-r--r-- | plugins/check_radius.c | 28 | ||||
| -rw-r--r-- | plugins/check_smtp.c | 98 | ||||
| -rw-r--r-- | plugins/check_tcp.c | 2 | ||||
| -rw-r--r-- | plugins/check_ups.c | 10 | ||||
| -rw-r--r-- | plugins/runcmd.c | 2 | ||||
| -rw-r--r-- | plugins/utils.c | 2 |
18 files changed, 592 insertions, 535 deletions
diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 5e4021b5..1eda45dd 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c | |||
| @@ -1,33 +1,33 @@ | |||
| 1 | /***************************************************************************** | 1 | /***************************************************************************** |
| 2 | * | 2 | * |
| 3 | * Monitoring check_apt plugin | 3 | * Monitoring check_apt plugin |
| 4 | * | 4 | * |
| 5 | * License: GPL | 5 | * License: GPL |
| 6 | * Copyright (c) 2006-2024 Monitoring Plugins Development Team | 6 | * Copyright (c) 2006-2024 Monitoring Plugins Development Team |
| 7 | * | 7 | * |
| 8 | * Original author: Sean Finney | 8 | * Original author: Sean Finney |
| 9 | * | 9 | * |
| 10 | * Description: | 10 | * Description: |
| 11 | * | 11 | * |
| 12 | * This file contains the check_apt plugin | 12 | * This file contains the check_apt plugin |
| 13 | * | 13 | * |
| 14 | * Check for available updates in apt package management systems | 14 | * Check for available updates in apt package management systems |
| 15 | * | 15 | * |
| 16 | * | 16 | * |
| 17 | * This program is free software: you can redistribute it and/or modify | 17 | * This program is free software: you can redistribute it and/or modify |
| 18 | * it under the terms of the GNU General Public License as published by | 18 | * it under the terms of the GNU General Public License as published by |
| 19 | * the Free Software Foundation, either version 3 of the License, or | 19 | * the Free Software Foundation, either version 3 of the License, or |
| 20 | * (at your option) any later version. | 20 | * (at your option) any later version. |
| 21 | * | 21 | * |
| 22 | * This program is distributed in the hope that it will be useful, | 22 | * This program is distributed in the hope that it will be useful, |
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 | * GNU General Public License for more details. | 25 | * GNU General Public License for more details. |
| 26 | * | 26 | * |
| 27 | * You should have received a copy of the GNU General Public License | 27 | * You should have received a copy of the GNU General Public License |
| 28 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 28 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 29 | * | 29 | * |
| 30 | *****************************************************************************/ | 30 | *****************************************************************************/ |
| 31 | 31 | ||
| 32 | const char *progname = "check_apt"; | 32 | const char *progname = "check_apt"; |
| 33 | const char *copyright = "2006-2024"; | 33 | const char *copyright = "2006-2024"; |
| @@ -39,17 +39,21 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 39 | #include "regex.h" | 39 | #include "regex.h" |
| 40 | 40 | ||
| 41 | /* some constants */ | 41 | /* some constants */ |
| 42 | typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; | 42 | typedef enum { |
| 43 | UPGRADE, | ||
| 44 | DIST_UPGRADE, | ||
| 45 | NO_UPGRADE | ||
| 46 | } upgrade_type; | ||
| 43 | 47 | ||
| 44 | /* Character for hidden input file option (for testing). */ | 48 | /* Character for hidden input file option (for testing). */ |
| 45 | #define INPUT_FILE_OPT CHAR_MAX+1 | 49 | #define INPUT_FILE_OPT CHAR_MAX + 1 |
| 46 | /* the default opts can be overridden via the cmdline */ | 50 | /* the default opts can be overridden via the cmdline */ |
| 47 | #define UPGRADE_DEFAULT_OPTS "-o 'Debug::NoLocking=true' -s -qq" | 51 | #define UPGRADE_DEFAULT_OPTS "-o 'Debug::NoLocking=true' -s -qq" |
| 48 | #define UPDATE_DEFAULT_OPTS "-q" | 52 | #define UPDATE_DEFAULT_OPTS "-q" |
| 49 | /* until i commit the configure.in patch which gets this, i'll define | 53 | /* until i commit the configure.in patch which gets this, i'll define |
| 50 | * it here as well */ | 54 | * it here as well */ |
| 51 | #ifndef PATH_TO_APTGET | 55 | #ifndef PATH_TO_APTGET |
| 52 | # define PATH_TO_APTGET "/usr/bin/apt-get" | 56 | # define PATH_TO_APTGET "/usr/bin/apt-get" |
| 53 | #endif /* PATH_TO_APTGET */ | 57 | #endif /* PATH_TO_APTGET */ |
| 54 | /* String found at the beginning of the apt output lines we're interested in */ | 58 | /* String found at the beginning of the apt output lines we're interested in */ |
| 55 | #define PKGINST_PREFIX "Inst " | 59 | #define PKGINST_PREFIX "Inst " |
| @@ -57,97 +61,108 @@ typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; | |||
| 57 | #define SECURITY_RE "^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)" | 61 | #define SECURITY_RE "^[^\\(]*\\(.* (Debian-Security:|Ubuntu:[^/]*/[^-]*-security)" |
| 58 | 62 | ||
| 59 | /* some standard functions */ | 63 | /* some standard functions */ |
| 60 | int process_arguments(int, char **); | 64 | static int process_arguments(int /*argc*/, char ** /*argv*/); |
| 61 | void print_help(void); | 65 | static void print_help(void); |
| 62 | void print_usage(void); | 66 | void print_usage(void); |
| 63 | 67 | ||
| 64 | /* construct the appropriate apt-get cmdline */ | 68 | /* construct the appropriate apt-get cmdline */ |
| 65 | char* construct_cmdline(upgrade_type u, const char *opts); | 69 | static char *construct_cmdline(upgrade_type u, const char *opts); |
| 66 | /* run an apt-get update */ | 70 | /* run an apt-get update */ |
| 67 | int run_update(void); | 71 | static int run_update(void); |
| 72 | |||
| 73 | typedef struct { | ||
| 74 | int errorcode; | ||
| 75 | int package_count; | ||
| 76 | int security_package_count; | ||
| 77 | char **packages_list; | ||
| 78 | char **secpackages_list; | ||
| 79 | } run_upgrade_result; | ||
| 80 | |||
| 68 | /* run an apt-get upgrade */ | 81 | /* run an apt-get upgrade */ |
| 69 | int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist); | 82 | static run_upgrade_result run_upgrade(void); |
| 83 | |||
| 70 | /* add another clause to a regexp */ | 84 | /* add another clause to a regexp */ |
| 71 | char* add_to_regexp(char *expr, const char *next); | 85 | static char *add_to_regexp(char *expr, const char *next); |
| 72 | /* extract package name from Inst line */ | 86 | /* extract package name from Inst line */ |
| 73 | char* pkg_name(char *line); | 87 | static char *pkg_name(char *line); |
| 74 | /* string comparison function for qsort */ | 88 | /* string comparison function for qsort */ |
| 75 | int cmpstringp(const void *p1, const void *p2); | 89 | static int cmpstringp(const void *p1, const void *p2); |
| 76 | 90 | ||
| 77 | /* configuration variables */ | 91 | /* configuration variables */ |
| 78 | static int verbose = 0; /* -v */ | 92 | static int verbose = 0; /* -v */ |
| 79 | static bool list = false; /* list packages available for upgrade */ | 93 | static bool list = false; /* list packages available for upgrade */ |
| 80 | static bool do_update = false; /* whether to call apt-get update */ | 94 | static bool do_update = false; /* whether to call apt-get update */ |
| 81 | static bool only_critical = false; /* whether to warn about non-critical updates */ | 95 | static bool only_critical = false; /* whether to warn about non-critical updates */ |
| 82 | static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ | 96 | static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ |
| 83 | static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ | 97 | static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ |
| 84 | static char *update_opts = NULL; /* options to override defaults for update */ | 98 | static char *update_opts = NULL; /* options to override defaults for update */ |
| 85 | static char *do_include = NULL; /* regexp to only include certain packages */ | 99 | static char *do_include = NULL; /* regexp to only include certain packages */ |
| 86 | static char *do_exclude = NULL; /* regexp to only exclude certain packages */ | 100 | static char *do_exclude = NULL; /* regexp to only exclude certain packages */ |
| 87 | static char *do_critical = NULL; /* regexp specifying critical packages */ | 101 | static char *do_critical = NULL; /* regexp specifying critical packages */ |
| 88 | static char *input_filename = NULL; /* input filename for testing */ | 102 | static char *input_filename = NULL; /* input filename for testing */ |
| 89 | /* number of packages available for upgrade to return WARNING status */ | 103 | /* number of packages available for upgrade to return WARNING status */ |
| 90 | static int packages_warning = 1; | 104 | static int packages_warning = 1; |
| 91 | 105 | ||
| 92 | /* other global variables */ | 106 | /* other global variables */ |
| 93 | static int stderr_warning = 0; /* if a cmd issued output on stderr */ | 107 | static int stderr_warning = 0; /* if a cmd issued output on stderr */ |
| 94 | static int exec_warning = 0; /* if a cmd exited non-zero */ | 108 | static int exec_warning = 0; /* if a cmd exited non-zero */ |
| 95 | |||
| 96 | int main (int argc, char **argv) { | ||
| 97 | int result=STATE_UNKNOWN, packages_available=0, sec_count=0; | ||
| 98 | char **packages_list=NULL, **secpackages_list=NULL; | ||
| 99 | 109 | ||
| 110 | int main(int argc, char **argv) { | ||
| 100 | /* Parse extra opts if any */ | 111 | /* Parse extra opts if any */ |
| 101 | argv=np_extra_opts(&argc, argv, progname); | 112 | argv = np_extra_opts(&argc, argv, progname); |
| 102 | 113 | ||
| 103 | if (process_arguments(argc, argv) == ERROR) | 114 | if (process_arguments(argc, argv) == ERROR) { |
| 104 | usage_va(_("Could not parse arguments")); | 115 | usage_va(_("Could not parse arguments")); |
| 116 | } | ||
| 105 | 117 | ||
| 106 | /* Set signal handling and alarm timeout */ | 118 | /* Set signal handling and alarm timeout */ |
| 107 | if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { | 119 | if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) { |
| 108 | usage_va(_("Cannot catch SIGALRM")); | 120 | usage_va(_("Cannot catch SIGALRM")); |
| 109 | } | 121 | } |
| 110 | 122 | ||
| 111 | /* handle timeouts gracefully... */ | 123 | /* handle timeouts gracefully... */ |
| 112 | alarm (timeout_interval); | 124 | alarm(timeout_interval); |
| 113 | 125 | ||
| 126 | int result = STATE_UNKNOWN; | ||
| 114 | /* if they want to run apt-get update first... */ | 127 | /* if they want to run apt-get update first... */ |
| 115 | if(do_update) result = run_update(); | 128 | if (do_update) { |
| 129 | result = run_update(); | ||
| 130 | } | ||
| 116 | 131 | ||
| 117 | /* apt-get upgrade */ | 132 | /* apt-get upgrade */ |
| 118 | result = max_state(result, run_upgrade(&packages_available, &sec_count, &packages_list, &secpackages_list)); | 133 | run_upgrade_result upgrad_res = run_upgrade(); |
| 119 | 134 | ||
| 120 | if(sec_count > 0){ | 135 | result = max_state(result, upgrad_res.errorcode); |
| 136 | int packages_available = upgrad_res.package_count; | ||
| 137 | int sec_count = upgrad_res.security_package_count; | ||
| 138 | char **packages_list = upgrad_res.packages_list; | ||
| 139 | char **secpackages_list = upgrad_res.secpackages_list; | ||
| 140 | |||
| 141 | if (sec_count > 0) { | ||
| 121 | result = max_state(result, STATE_CRITICAL); | 142 | result = max_state(result, STATE_CRITICAL); |
| 122 | } else if(packages_available >= packages_warning && only_critical == false){ | 143 | } else if (packages_available >= packages_warning && only_critical == false) { |
| 123 | result = max_state(result, STATE_WARNING); | 144 | result = max_state(result, STATE_WARNING); |
| 124 | } else if(result > STATE_UNKNOWN){ | 145 | } else if (result > STATE_UNKNOWN) { |
| 125 | result = STATE_UNKNOWN; | 146 | result = STATE_UNKNOWN; |
| 126 | } | 147 | } |
| 127 | 148 | ||
| 128 | printf(_("APT %s: %d packages available for %s (%d critical updates). %s%s%s%s|available_upgrades=%d;;;0 critical_updates=%d;;;0\n"), | 149 | printf(_("APT %s: %d packages available for %s (%d critical updates). %s%s%s%s|available_upgrades=%d;;;0 critical_updates=%d;;;0\n"), |
| 129 | state_text(result), | 150 | state_text(result), packages_available, (upgrade == DIST_UPGRADE) ? "dist-upgrade" : "upgrade", sec_count, |
| 130 | packages_available, | 151 | (stderr_warning) ? " warnings detected" : "", (stderr_warning && exec_warning) ? "," : "", |
| 131 | (upgrade==DIST_UPGRADE)?"dist-upgrade":"upgrade", | 152 | (exec_warning) ? " errors detected" : "", (stderr_warning || exec_warning) ? "." : "", packages_available, sec_count); |
| 132 | sec_count, | 153 | |
| 133 | (stderr_warning)?" warnings detected":"", | 154 | if (list) { |
| 134 | (stderr_warning && exec_warning)?",":"", | 155 | qsort(secpackages_list, sec_count, sizeof(char *), cmpstringp); |
| 135 | (exec_warning)?" errors detected":"", | 156 | qsort(packages_list, packages_available - sec_count, sizeof(char *), cmpstringp); |
| 136 | (stderr_warning||exec_warning)?".":"", | 157 | |
| 137 | packages_available, | 158 | for (int i = 0; i < sec_count; i++) { |
| 138 | sec_count | ||
| 139 | ); | ||
| 140 | |||
| 141 | if(list) { | ||
| 142 | qsort(secpackages_list, sec_count, sizeof(char*), cmpstringp); | ||
| 143 | qsort(packages_list, packages_available-sec_count, sizeof(char*), cmpstringp); | ||
| 144 | |||
| 145 | for(int i = 0; i < sec_count; i++) | ||
| 146 | printf("%s (security)\n", secpackages_list[i]); | 159 | printf("%s (security)\n", secpackages_list[i]); |
| 160 | } | ||
| 147 | 161 | ||
| 148 | if (only_critical == false) { | 162 | if (only_critical == false) { |
| 149 | for(int i = 0; i < packages_available - sec_count; i++) | 163 | for (int i = 0; i < packages_available - sec_count; i++) { |
| 150 | printf("%s\n", packages_list[i]); | 164 | printf("%s\n", packages_list[i]); |
| 165 | } | ||
| 151 | } | 166 | } |
| 152 | } | 167 | } |
| 153 | 168 | ||
| @@ -155,34 +170,32 @@ int main (int argc, char **argv) { | |||
| 155 | } | 170 | } |
| 156 | 171 | ||
| 157 | /* process command-line arguments */ | 172 | /* process command-line arguments */ |
| 158 | int process_arguments (int argc, char **argv) { | 173 | int process_arguments(int argc, char **argv) { |
| 159 | int c; | 174 | static struct option longopts[] = {{"version", no_argument, 0, 'V'}, |
| 160 | 175 | {"help", no_argument, 0, 'h'}, | |
| 161 | static struct option longopts[] = { | 176 | {"verbose", no_argument, 0, 'v'}, |
| 162 | {"version", no_argument, 0, 'V'}, | 177 | {"timeout", required_argument, 0, 't'}, |
| 163 | {"help", no_argument, 0, 'h'}, | 178 | {"update", optional_argument, 0, 'u'}, |
| 164 | {"verbose", no_argument, 0, 'v'}, | 179 | {"upgrade", optional_argument, 0, 'U'}, |
| 165 | {"timeout", required_argument, 0, 't'}, | 180 | {"no-upgrade", no_argument, 0, 'n'}, |
| 166 | {"update", optional_argument, 0, 'u'}, | 181 | {"dist-upgrade", optional_argument, 0, 'd'}, |
| 167 | {"upgrade", optional_argument, 0, 'U'}, | 182 | {"list", no_argument, false, 'l'}, |
| 168 | {"no-upgrade", no_argument, 0, 'n'}, | 183 | {"include", required_argument, 0, 'i'}, |
| 169 | {"dist-upgrade", optional_argument, 0, 'd'}, | 184 | {"exclude", required_argument, 0, 'e'}, |
| 170 | {"list", no_argument, false, 'l'}, | 185 | {"critical", required_argument, 0, 'c'}, |
| 171 | {"include", required_argument, 0, 'i'}, | 186 | {"only-critical", no_argument, 0, 'o'}, |
| 172 | {"exclude", required_argument, 0, 'e'}, | 187 | {"input-file", required_argument, 0, INPUT_FILE_OPT}, |
| 173 | {"critical", required_argument, 0, 'c'}, | 188 | {"packages-warning", required_argument, 0, 'w'}, |
| 174 | {"only-critical", no_argument, 0, 'o'}, | 189 | {0, 0, 0, 0}}; |
| 175 | {"input-file", required_argument, 0, INPUT_FILE_OPT}, | 190 | |
| 176 | {"packages-warning", required_argument, 0, 'w'}, | 191 | while (true) { |
| 177 | {0, 0, 0, 0} | 192 | int option_char = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL); |
| 178 | }; | 193 | |
| 179 | 194 | if (option_char == -1 || option_char == EOF || option_char == 1) { | |
| 180 | while(1) { | 195 | break; |
| 181 | c = getopt_long(argc, argv, "hVvt:u::U::d::nli:e:c:ow:", longopts, NULL); | 196 | } |
| 182 | |||
| 183 | if(c == -1 || c == EOF || c == 1) break; | ||
| 184 | 197 | ||
| 185 | switch(c) { | 198 | switch (option_char) { |
| 186 | case 'h': | 199 | case 'h': |
| 187 | print_help(); | 200 | print_help(); |
| 188 | exit(STATE_UNKNOWN); | 201 | exit(STATE_UNKNOWN); |
| @@ -193,46 +206,52 @@ int process_arguments (int argc, char **argv) { | |||
| 193 | verbose++; | 206 | verbose++; |
| 194 | break; | 207 | break; |
| 195 | case 't': | 208 | case 't': |
| 196 | timeout_interval=atoi(optarg); | 209 | timeout_interval = atoi(optarg); |
| 197 | break; | 210 | break; |
| 198 | case 'd': | 211 | case 'd': |
| 199 | upgrade=DIST_UPGRADE; | 212 | upgrade = DIST_UPGRADE; |
| 200 | if(optarg!=NULL){ | 213 | if (optarg != NULL) { |
| 201 | upgrade_opts=strdup(optarg); | 214 | upgrade_opts = strdup(optarg); |
| 202 | if(upgrade_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); | 215 | if (upgrade_opts == NULL) { |
| 216 | die(STATE_UNKNOWN, "strdup failed"); | ||
| 217 | } | ||
| 203 | } | 218 | } |
| 204 | break; | 219 | break; |
| 205 | case 'U': | 220 | case 'U': |
| 206 | upgrade=UPGRADE; | 221 | upgrade = UPGRADE; |
| 207 | if(optarg!=NULL){ | 222 | if (optarg != NULL) { |
| 208 | upgrade_opts=strdup(optarg); | 223 | upgrade_opts = strdup(optarg); |
| 209 | if(upgrade_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); | 224 | if (upgrade_opts == NULL) { |
| 225 | die(STATE_UNKNOWN, "strdup failed"); | ||
| 226 | } | ||
| 210 | } | 227 | } |
| 211 | break; | 228 | break; |
| 212 | case 'n': | 229 | case 'n': |
| 213 | upgrade=NO_UPGRADE; | 230 | upgrade = NO_UPGRADE; |
| 214 | break; | 231 | break; |
| 215 | case 'u': | 232 | case 'u': |
| 216 | do_update=true; | 233 | do_update = true; |
| 217 | if(optarg!=NULL){ | 234 | if (optarg != NULL) { |
| 218 | update_opts=strdup(optarg); | 235 | update_opts = strdup(optarg); |
| 219 | if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); | 236 | if (update_opts == NULL) { |
| 237 | die(STATE_UNKNOWN, "strdup failed"); | ||
| 238 | } | ||
| 220 | } | 239 | } |
| 221 | break; | 240 | break; |
| 222 | case 'l': | 241 | case 'l': |
| 223 | list=true; | 242 | list = true; |
| 224 | break; | 243 | break; |
| 225 | case 'i': | 244 | case 'i': |
| 226 | do_include=add_to_regexp(do_include, optarg); | 245 | do_include = add_to_regexp(do_include, optarg); |
| 227 | break; | 246 | break; |
| 228 | case 'e': | 247 | case 'e': |
| 229 | do_exclude=add_to_regexp(do_exclude, optarg); | 248 | do_exclude = add_to_regexp(do_exclude, optarg); |
| 230 | break; | 249 | break; |
| 231 | case 'c': | 250 | case 'c': |
| 232 | do_critical=add_to_regexp(do_critical, optarg); | 251 | do_critical = add_to_regexp(do_critical, optarg); |
| 233 | break; | 252 | break; |
| 234 | case 'o': | 253 | case 'o': |
| 235 | only_critical=true; | 254 | only_critical = true; |
| 236 | break; | 255 | break; |
| 237 | case INPUT_FILE_OPT: | 256 | case INPUT_FILE_OPT: |
| 238 | input_filename = optarg; | 257 | input_filename = optarg; |
| @@ -249,68 +268,78 @@ int process_arguments (int argc, char **argv) { | |||
| 249 | return OK; | 268 | return OK; |
| 250 | } | 269 | } |
| 251 | 270 | ||
| 252 | |||
| 253 | /* run an apt-get upgrade */ | 271 | /* run an apt-get upgrade */ |
| 254 | int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){ | 272 | run_upgrade_result run_upgrade(void) { |
| 255 | int result=STATE_UNKNOWN, regres=0, pc=0, spc=0; | 273 | regex_t ereg; |
| 256 | struct output chld_out, chld_err; | ||
| 257 | regex_t ireg, ereg, sreg; | ||
| 258 | char *cmdline=NULL, rerrbuf[64]; | ||
| 259 | |||
| 260 | /* initialize ereg as it is possible it is printed while uninitialized */ | 274 | /* initialize ereg as it is possible it is printed while uninitialized */ |
| 261 | memset(&ereg, '\0', sizeof(ereg.buffer)); | 275 | memset(&ereg, '\0', sizeof(ereg.buffer)); |
| 262 | 276 | ||
| 263 | if(upgrade==NO_UPGRADE) return STATE_OK; | 277 | run_upgrade_result result = { |
| 278 | .errorcode = STATE_UNKNOWN, | ||
| 279 | }; | ||
| 264 | 280 | ||
| 281 | if (upgrade == NO_UPGRADE) { | ||
| 282 | result.errorcode = STATE_OK; | ||
| 283 | return result; | ||
| 284 | } | ||
| 285 | |||
| 286 | int regres = 0; | ||
| 287 | regex_t ireg; | ||
| 288 | char rerrbuf[64]; | ||
| 265 | /* compile the regexps */ | 289 | /* compile the regexps */ |
| 266 | if (do_include != NULL) { | 290 | if (do_include != NULL) { |
| 267 | regres=regcomp(&ireg, do_include, REG_EXTENDED); | 291 | regres = regcomp(&ireg, do_include, REG_EXTENDED); |
| 268 | if (regres!=0) { | 292 | if (regres != 0) { |
| 269 | regerror(regres, &ireg, rerrbuf, 64); | 293 | regerror(regres, &ireg, rerrbuf, 64); |
| 270 | die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); | 294 | die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); |
| 271 | } | 295 | } |
| 272 | } | 296 | } |
| 273 | 297 | ||
| 274 | if(do_exclude!=NULL){ | 298 | if (do_exclude != NULL) { |
| 275 | regres=regcomp(&ereg, do_exclude, REG_EXTENDED); | 299 | regres = regcomp(&ereg, do_exclude, REG_EXTENDED); |
| 276 | if(regres!=0) { | 300 | if (regres != 0) { |
| 277 | regerror(regres, &ereg, rerrbuf, 64); | 301 | regerror(regres, &ereg, rerrbuf, 64); |
| 278 | die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), | 302 | die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); |
| 279 | progname, rerrbuf); | ||
| 280 | } | 303 | } |
| 281 | } | 304 | } |
| 282 | 305 | ||
| 306 | regex_t sreg; | ||
| 283 | const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE; | 307 | const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE; |
| 284 | regres=regcomp(&sreg, crit_ptr, REG_EXTENDED); | 308 | regres = regcomp(&sreg, crit_ptr, REG_EXTENDED); |
| 285 | if(regres!=0) { | 309 | if (regres != 0) { |
| 286 | regerror(regres, &ereg, rerrbuf, 64); | 310 | regerror(regres, &ereg, rerrbuf, 64); |
| 287 | die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), | 311 | die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); |
| 288 | progname, rerrbuf); | ||
| 289 | } | 312 | } |
| 290 | 313 | ||
| 291 | cmdline=construct_cmdline(upgrade, upgrade_opts); | 314 | struct output chld_out; |
| 315 | struct output chld_err; | ||
| 316 | char *cmdline = NULL; | ||
| 317 | cmdline = construct_cmdline(upgrade, upgrade_opts); | ||
| 292 | if (input_filename != NULL) { | 318 | if (input_filename != NULL) { |
| 293 | /* read input from a file for testing */ | 319 | /* read input from a file for testing */ |
| 294 | result = cmd_file_read(input_filename, &chld_out, 0); | 320 | result.errorcode = cmd_file_read(input_filename, &chld_out, 0); |
| 295 | } else { | 321 | } else { |
| 296 | /* run the upgrade */ | 322 | /* run the upgrade */ |
| 297 | result = np_runcmd(cmdline, &chld_out, &chld_err, 0); | 323 | result.errorcode = np_runcmd(cmdline, &chld_out, &chld_err, 0); |
| 298 | } | 324 | } |
| 299 | 325 | ||
| 300 | /* apt-get upgrade only changes exit status if there is an | 326 | /* apt-get upgrade only changes exit status if there is an |
| 301 | * internal error when run in dry-run mode. therefore we will | 327 | * internal error when run in dry-run mode. therefore we will |
| 302 | * treat such an error as UNKNOWN */ | 328 | * treat such an error as UNKNOWN */ |
| 303 | if(result != 0){ | 329 | if (result.errorcode != STATE_OK) { |
| 304 | exec_warning=1; | 330 | exec_warning = 1; |
| 305 | result = STATE_UNKNOWN; | 331 | result.errorcode = STATE_UNKNOWN; |
| 306 | fprintf(stderr, _("'%s' exited with non-zero status.\n"), | 332 | fprintf(stderr, _("'%s' exited with non-zero status.\n"), cmdline); |
| 307 | cmdline); | ||
| 308 | } | 333 | } |
| 309 | 334 | ||
| 310 | *pkglist=malloc(sizeof(char *) * chld_out.lines); | 335 | char **pkglist = malloc(sizeof(char *) * chld_out.lines); |
| 311 | if(!pkglist) die(STATE_UNKNOWN, "malloc failed!\n"); | 336 | if (!pkglist) { |
| 312 | *secpkglist=malloc(sizeof(char *) * chld_out.lines); | 337 | die(STATE_UNKNOWN, "malloc failed!\n"); |
| 313 | if(!secpkglist) die(STATE_UNKNOWN, "malloc failed!\n"); | 338 | } |
| 339 | char **secpkglist = malloc(sizeof(char *) * chld_out.lines); | ||
| 340 | if (!secpkglist) { | ||
| 341 | die(STATE_UNKNOWN, "malloc failed!\n"); | ||
| 342 | } | ||
| 314 | 343 | ||
| 315 | /* parse the output, which should only consist of lines like | 344 | /* parse the output, which should only consist of lines like |
| 316 | * | 345 | * |
| @@ -321,82 +350,91 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg | |||
| 321 | * we may need to switch to the --print-uris output format, | 350 | * we may need to switch to the --print-uris output format, |
| 322 | * in which case the logic here will slightly change. | 351 | * in which case the logic here will slightly change. |
| 323 | */ | 352 | */ |
| 324 | for(size_t i = 0; i < chld_out.lines; i++) { | 353 | int package_counter = 0; |
| 325 | if(verbose){ | 354 | int security_package_counter = 0; |
| 355 | for (size_t i = 0; i < chld_out.lines; i++) { | ||
| 356 | if (verbose) { | ||
| 326 | printf("%s\n", chld_out.line[i]); | 357 | printf("%s\n", chld_out.line[i]); |
| 327 | } | 358 | } |
| 328 | /* if it is a package we care about */ | 359 | /* if it is a package we care about */ |
| 329 | if (strncmp(PKGINST_PREFIX, chld_out.line[i], strlen(PKGINST_PREFIX)) == 0 && | 360 | if (strncmp(PKGINST_PREFIX, chld_out.line[i], strlen(PKGINST_PREFIX)) == 0 && |
| 330 | (do_include == NULL || regexec(&ireg, chld_out.line[i], 0, NULL, 0) == 0)) { | 361 | (do_include == NULL || regexec(&ireg, chld_out.line[i], 0, NULL, 0) == 0)) { |
| 331 | /* if we're not excluding, or it's not in the | 362 | /* if we're not excluding, or it's not in the |
| 332 | * list of stuff to exclude */ | 363 | * list of stuff to exclude */ |
| 333 | if(do_exclude==NULL || | 364 | if (do_exclude == NULL || regexec(&ereg, chld_out.line[i], 0, NULL, 0) != 0) { |
| 334 | regexec(&ereg, chld_out.line[i], 0, NULL, 0)!=0){ | 365 | package_counter++; |
| 335 | pc++; | 366 | if (regexec(&sreg, chld_out.line[i], 0, NULL, 0) == 0) { |
| 336 | if(regexec(&sreg, chld_out.line[i], 0, NULL, 0)==0){ | 367 | security_package_counter++; |
| 337 | spc++; | 368 | if (verbose) { |
| 338 | if(verbose) printf("*"); | 369 | printf("*"); |
| 339 | (*secpkglist)[spc-1] = pkg_name(chld_out.line[i]); | 370 | } |
| 371 | (secpkglist)[security_package_counter - 1] = pkg_name(chld_out.line[i]); | ||
| 340 | } else { | 372 | } else { |
| 341 | (*pkglist)[pc-spc-1] = pkg_name(chld_out.line[i]); | 373 | (pkglist)[package_counter - security_package_counter - 1] = pkg_name(chld_out.line[i]); |
| 342 | } | 374 | } |
| 343 | if(verbose){ | 375 | if (verbose) { |
| 344 | printf("*%s\n", chld_out.line[i]); | 376 | printf("*%s\n", chld_out.line[i]); |
| 345 | } | 377 | } |
| 346 | } | 378 | } |
| 347 | } | 379 | } |
| 348 | } | 380 | } |
| 349 | *pkgcount=pc; | 381 | result.package_count = package_counter; |
| 350 | *secpkgcount=spc; | 382 | result.security_package_count = security_package_counter; |
| 383 | result.packages_list = pkglist; | ||
| 384 | result.secpackages_list = secpkglist; | ||
| 351 | 385 | ||
| 352 | /* If we get anything on stderr, at least set warning */ | 386 | /* If we get anything on stderr, at least set warning */ |
| 353 | if (input_filename == NULL && chld_err.buflen) { | 387 | if (input_filename == NULL && chld_err.buflen) { |
| 354 | stderr_warning=1; | 388 | stderr_warning = 1; |
| 355 | result = max_state(result, STATE_WARNING); | 389 | result.errorcode = max_state(result.errorcode, STATE_WARNING); |
| 356 | if(verbose){ | 390 | if (verbose) { |
| 357 | for(size_t i = 0; i < chld_err.lines; i++) { | 391 | for (size_t i = 0; i < chld_err.lines; i++) { |
| 358 | fprintf(stderr, "%s\n", chld_err.line[i]); | 392 | fprintf(stderr, "%s\n", chld_err.line[i]); |
| 359 | } | 393 | } |
| 360 | } | 394 | } |
| 361 | } | 395 | } |
| 362 | if (do_include != NULL) regfree(&ireg); | 396 | if (do_include != NULL) { |
| 397 | regfree(&ireg); | ||
| 398 | } | ||
| 363 | regfree(&sreg); | 399 | regfree(&sreg); |
| 364 | if(do_exclude!=NULL) regfree(&ereg); | 400 | if (do_exclude != NULL) { |
| 401 | regfree(&ereg); | ||
| 402 | } | ||
| 365 | free(cmdline); | 403 | free(cmdline); |
| 366 | return result; | 404 | return result; |
| 367 | } | 405 | } |
| 368 | 406 | ||
| 369 | /* run an apt-get update (needs root) */ | 407 | /* run an apt-get update (needs root) */ |
| 370 | int run_update(void){ | 408 | int run_update(void) { |
| 371 | int result=STATE_UNKNOWN; | 409 | int result = STATE_UNKNOWN; |
| 372 | struct output chld_out, chld_err; | ||
| 373 | char *cmdline; | 410 | char *cmdline; |
| 374 | |||
| 375 | /* run the update */ | 411 | /* run the update */ |
| 376 | cmdline = construct_cmdline(NO_UPGRADE, update_opts); | 412 | cmdline = construct_cmdline(NO_UPGRADE, update_opts); |
| 413 | |||
| 414 | struct output chld_out; | ||
| 415 | struct output chld_err; | ||
| 377 | result = np_runcmd(cmdline, &chld_out, &chld_err, 0); | 416 | result = np_runcmd(cmdline, &chld_out, &chld_err, 0); |
| 378 | /* apt-get update changes exit status if it can't fetch packages. | 417 | /* apt-get update changes exit status if it can't fetch packages. |
| 379 | * since we were explicitly asked to do so, this is treated as | 418 | * since we were explicitly asked to do so, this is treated as |
| 380 | * a critical error. */ | 419 | * a critical error. */ |
| 381 | if(result != 0){ | 420 | if (result != 0) { |
| 382 | exec_warning=1; | 421 | exec_warning = 1; |
| 383 | result = STATE_CRITICAL; | 422 | result = STATE_CRITICAL; |
| 384 | fprintf(stderr, _("'%s' exited with non-zero status.\n"), | 423 | fprintf(stderr, _("'%s' exited with non-zero status.\n"), cmdline); |
| 385 | cmdline); | ||
| 386 | } | 424 | } |
| 387 | 425 | ||
| 388 | if(verbose){ | 426 | if (verbose) { |
| 389 | for(size_t i = 0; i < chld_out.lines; i++) { | 427 | for (size_t i = 0; i < chld_out.lines; i++) { |
| 390 | printf("%s\n", chld_out.line[i]); | 428 | printf("%s\n", chld_out.line[i]); |
| 391 | } | 429 | } |
| 392 | } | 430 | } |
| 393 | 431 | ||
| 394 | /* If we get anything on stderr, at least set warning */ | 432 | /* If we get anything on stderr, at least set warning */ |
| 395 | if(chld_err.buflen){ | 433 | if (chld_err.buflen) { |
| 396 | stderr_warning=1; | 434 | stderr_warning = 1; |
| 397 | result = max_state(result, STATE_WARNING); | 435 | result = max_state(result, STATE_WARNING); |
| 398 | if(verbose){ | 436 | if (verbose) { |
| 399 | for(size_t i = 0; i < chld_err.lines; i++) { | 437 | for (size_t i = 0; i < chld_err.lines; i++) { |
| 400 | fprintf(stderr, "%s\n", chld_err.line[i]); | 438 | fprintf(stderr, "%s\n", chld_err.line[i]); |
| 401 | } | 439 | } |
| 402 | } | 440 | } |
| @@ -405,158 +443,166 @@ int run_update(void){ | |||
| 405 | return result; | 443 | return result; |
| 406 | } | 444 | } |
| 407 | 445 | ||
| 408 | char* pkg_name(char *line){ | 446 | char *pkg_name(char *line) { |
| 409 | char *start=NULL, *space=NULL, *pkg=NULL; | 447 | char *start = line + strlen(PKGINST_PREFIX); |
| 410 | int len=0; | ||
| 411 | 448 | ||
| 412 | start = line + strlen(PKGINST_PREFIX); | 449 | int len = strlen(start); |
| 413 | len = strlen(start); | ||
| 414 | 450 | ||
| 415 | space = index(start, ' '); | 451 | char *space = index(start, ' '); |
| 416 | if(space!=NULL){ | 452 | if (space != NULL) { |
| 417 | len = space - start; | 453 | len = space - start; |
| 418 | } | 454 | } |
| 419 | 455 | ||
| 420 | pkg=malloc(sizeof(char)*(len+1)); | 456 | char *pkg = malloc(sizeof(char) * (len + 1)); |
| 421 | if(!pkg) die(STATE_UNKNOWN, "malloc failed!\n"); | 457 | if (!pkg) { |
| 458 | die(STATE_UNKNOWN, "malloc failed!\n"); | ||
| 459 | } | ||
| 422 | 460 | ||
| 423 | strncpy(pkg, start, len); | 461 | strncpy(pkg, start, len); |
| 424 | pkg[len]='\0'; | 462 | pkg[len] = '\0'; |
| 425 | 463 | ||
| 426 | return pkg; | 464 | return pkg; |
| 427 | } | 465 | } |
| 428 | 466 | ||
| 429 | int cmpstringp(const void *p1, const void *p2){ | 467 | int cmpstringp(const void *p1, const void *p2) { return strcmp(*(char *const *)p1, *(char *const *)p2); } |
| 430 | return strcmp(* (char * const *) p1, * (char * const *) p2); | ||
| 431 | } | ||
| 432 | 468 | ||
| 433 | char* add_to_regexp(char *expr, const char *next){ | 469 | char *add_to_regexp(char *expr, const char *next) { |
| 434 | char *re=NULL; | 470 | char *re = NULL; |
| 435 | 471 | ||
| 436 | if(expr==NULL){ | 472 | if (expr == NULL) { |
| 437 | re=malloc(sizeof(char)*(strlen("()")+strlen(next)+1)); | 473 | re = malloc(sizeof(char) * (strlen("()") + strlen(next) + 1)); |
| 438 | if(!re) die(STATE_UNKNOWN, "malloc failed!\n"); | 474 | if (!re) { |
| 475 | die(STATE_UNKNOWN, "malloc failed!\n"); | ||
| 476 | } | ||
| 439 | sprintf(re, "(%s)", next); | 477 | sprintf(re, "(%s)", next); |
| 440 | } else { | 478 | } else { |
| 441 | /* resize it, adding an extra char for the new '|' separator */ | 479 | /* resize it, adding an extra char for the new '|' separator */ |
| 442 | re=realloc(expr, sizeof(char)*(strlen(expr)+1+strlen(next)+1)); | 480 | re = realloc(expr, sizeof(char) * (strlen(expr) + 1 + strlen(next) + 1)); |
| 443 | if(!re) die(STATE_UNKNOWN, "realloc failed!\n"); | 481 | if (!re) { |
| 482 | die(STATE_UNKNOWN, "realloc failed!\n"); | ||
| 483 | } | ||
| 444 | /* append it starting at ')' in the old re */ | 484 | /* append it starting at ')' in the old re */ |
| 445 | sprintf((char*)(re+strlen(re)-1), "|%s)", next); | 485 | sprintf((char *)(re + strlen(re) - 1), "|%s)", next); |
| 446 | } | 486 | } |
| 447 | 487 | ||
| 448 | return re; | 488 | return re; |
| 449 | } | 489 | } |
| 450 | 490 | ||
| 451 | char* construct_cmdline(upgrade_type u, const char *opts){ | 491 | char *construct_cmdline(upgrade_type u, const char *opts) { |
| 452 | int len=0; | 492 | const char *opts_ptr = NULL; |
| 453 | const char *opts_ptr=NULL, *aptcmd=NULL; | 493 | const char *aptcmd = NULL; |
| 454 | char *cmd=NULL; | ||
| 455 | 494 | ||
| 456 | switch(u){ | 495 | switch (u) { |
| 457 | case UPGRADE: | 496 | case UPGRADE: |
| 458 | if(opts==NULL) opts_ptr=UPGRADE_DEFAULT_OPTS; | 497 | if (opts == NULL) { |
| 459 | else opts_ptr=opts; | 498 | opts_ptr = UPGRADE_DEFAULT_OPTS; |
| 460 | aptcmd="upgrade"; | 499 | } else { |
| 500 | opts_ptr = opts; | ||
| 501 | } | ||
| 502 | aptcmd = "upgrade"; | ||
| 461 | break; | 503 | break; |
| 462 | case DIST_UPGRADE: | 504 | case DIST_UPGRADE: |
| 463 | if(opts==NULL) opts_ptr=UPGRADE_DEFAULT_OPTS; | 505 | if (opts == NULL) { |
| 464 | else opts_ptr=opts; | 506 | opts_ptr = UPGRADE_DEFAULT_OPTS; |
| 465 | aptcmd="dist-upgrade"; | 507 | } else { |
| 508 | opts_ptr = opts; | ||
| 509 | } | ||
| 510 | aptcmd = "dist-upgrade"; | ||
| 466 | break; | 511 | break; |
| 467 | case NO_UPGRADE: | 512 | case NO_UPGRADE: |
| 468 | if(opts==NULL) opts_ptr=UPDATE_DEFAULT_OPTS; | 513 | if (opts == NULL) { |
| 469 | else opts_ptr=opts; | 514 | opts_ptr = UPDATE_DEFAULT_OPTS; |
| 470 | aptcmd="update"; | 515 | } else { |
| 516 | opts_ptr = opts; | ||
| 517 | } | ||
| 518 | aptcmd = "update"; | ||
| 471 | break; | 519 | break; |
| 472 | } | 520 | } |
| 473 | 521 | ||
| 474 | len+=strlen(PATH_TO_APTGET)+1; /* "/usr/bin/apt-get " */ | 522 | int len = 0; |
| 475 | len+=strlen(opts_ptr)+1; /* "opts " */ | 523 | len += strlen(PATH_TO_APTGET) + 1; /* "/usr/bin/apt-get " */ |
| 476 | len+=strlen(aptcmd)+1; /* "upgrade\0" */ | 524 | len += strlen(opts_ptr) + 1; /* "opts " */ |
| 525 | len += strlen(aptcmd) + 1; /* "upgrade\0" */ | ||
| 477 | 526 | ||
| 478 | cmd=(char*)malloc(sizeof(char)*len); | 527 | char *cmd = (char *)malloc(sizeof(char) * len); |
| 479 | if(cmd==NULL) die(STATE_UNKNOWN, "malloc failed"); | 528 | if (cmd == NULL) { |
| 529 | die(STATE_UNKNOWN, "malloc failed"); | ||
| 530 | } | ||
| 480 | sprintf(cmd, "%s %s %s", PATH_TO_APTGET, opts_ptr, aptcmd); | 531 | sprintf(cmd, "%s %s %s", PATH_TO_APTGET, opts_ptr, aptcmd); |
| 481 | return cmd; | 532 | return cmd; |
| 482 | } | 533 | } |
| 483 | 534 | ||
| 484 | /* informative help message */ | 535 | /* informative help message */ |
| 485 | void | 536 | void print_help(void) { |
| 486 | print_help (void) | 537 | print_revision(progname, NP_VERSION); |
| 487 | { | 538 | |
| 488 | print_revision(progname, NP_VERSION); | 539 | printf(_(COPYRIGHT), copyright, email); |
| 489 | 540 | ||
| 490 | printf(_(COPYRIGHT), copyright, email); | 541 | printf("%s\n", _("This plugin checks for software updates on systems that use")); |
| 491 | 542 | printf("%s\n", _("package management systems based on the apt-get(8) command")); | |
| 492 | printf("%s\n", _("This plugin checks for software updates on systems that use")); | 543 | printf("%s\n", _("found in Debian GNU/Linux")); |
| 493 | printf("%s\n", _("package management systems based on the apt-get(8) command")); | 544 | |
| 494 | printf("%s\n", _("found in Debian GNU/Linux")); | 545 | printf("\n\n"); |
| 495 | 546 | ||
| 496 | printf ("\n\n"); | 547 | print_usage(); |
| 497 | 548 | ||
| 498 | print_usage(); | 549 | printf(UT_HELP_VRSN); |
| 499 | 550 | printf(UT_EXTRA_OPTS); | |
| 500 | printf(UT_HELP_VRSN); | 551 | |
| 501 | printf(UT_EXTRA_OPTS); | 552 | printf(UT_PLUG_TIMEOUT, timeout_interval); |
| 502 | 553 | ||
| 503 | printf(UT_PLUG_TIMEOUT, timeout_interval); | 554 | printf(" %s\n", "-n, --no-upgrade"); |
| 504 | 555 | printf(" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); | |
| 505 | printf (" %s\n", "-n, --no-upgrade"); | 556 | printf(" %s\n", "-l, --list"); |
| 506 | printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); | 557 | printf(" %s\n", _("List packages available for upgrade. Packages are printed sorted by")); |
| 507 | printf (" %s\n", "-l, --list"); | 558 | printf(" %s\n", _("name with security packages listed first.")); |
| 508 | printf (" %s\n", _("List packages available for upgrade. Packages are printed sorted by")); | 559 | printf(" %s\n", "-i, --include=REGEXP"); |
| 509 | printf (" %s\n", _("name with security packages listed first.")); | 560 | printf(" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times")); |
| 510 | printf (" %s\n", "-i, --include=REGEXP"); | 561 | printf(" %s\n", _("the values will be combined together. Any packages matching this list")); |
| 511 | printf (" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times")); | 562 | printf(" %s\n", _("cause the plugin to return WARNING status. Others will be ignored.")); |
| 512 | printf (" %s\n", _("the values will be combined together. Any packages matching this list")); | 563 | printf(" %s\n", _("Default is to include all packages.")); |
| 513 | printf (" %s\n", _("cause the plugin to return WARNING status. Others will be ignored.")); | 564 | printf(" %s\n", "-e, --exclude=REGEXP"); |
| 514 | printf (" %s\n", _("Default is to include all packages.")); | 565 | printf(" %s\n", _("Exclude packages matching REGEXP from the list of packages that would")); |
| 515 | printf (" %s\n", "-e, --exclude=REGEXP"); | 566 | printf(" %s\n", _("otherwise be included. Can be specified multiple times; the values")); |
| 516 | printf (" %s\n", _("Exclude packages matching REGEXP from the list of packages that would")); | 567 | printf(" %s\n", _("will be combined together. Default is to exclude no packages.")); |
| 517 | printf (" %s\n", _("otherwise be included. Can be specified multiple times; the values")); | 568 | printf(" %s\n", "-c, --critical=REGEXP"); |
| 518 | printf (" %s\n", _("will be combined together. Default is to exclude no packages.")); | 569 | printf(" %s\n", _("If the full package information of any of the upgradable packages match")); |
| 519 | printf (" %s\n", "-c, --critical=REGEXP"); | 570 | printf(" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified")); |
| 520 | printf (" %s\n", _("If the full package information of any of the upgradable packages match")); | 571 | printf(" %s\n", _("multiple times like above. Default is a regexp matching security")); |
| 521 | printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified")); | 572 | printf(" %s\n", _("upgrades for Debian and Ubuntu:")); |
| 522 | printf (" %s\n", _("multiple times like above. Default is a regexp matching security")); | 573 | printf(" \t%s\n", SECURITY_RE); |
| 523 | printf (" %s\n", _("upgrades for Debian and Ubuntu:")); | 574 | printf(" %s\n", _("Note that the package must first match the include list before its")); |
| 524 | printf (" \t%s\n", SECURITY_RE); | 575 | printf(" %s\n", _("information is compared against the critical list.")); |
| 525 | printf (" %s\n", _("Note that the package must first match the include list before its")); | 576 | printf(" %s\n", "-o, --only-critical"); |
| 526 | printf (" %s\n", _("information is compared against the critical list.")); | 577 | printf(" %s\n", _("Only warn about upgrades matching the critical list. The total number")); |
| 527 | printf (" %s\n", "-o, --only-critical"); | 578 | printf(" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause")); |
| 528 | printf (" %s\n", _("Only warn about upgrades matching the critical list. The total number")); | 579 | printf(" %s\n", _("the plugin to return WARNING status.")); |
| 529 | printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause")); | 580 | printf(" %s\n", "-w, --packages-warning"); |
| 530 | printf (" %s\n", _("the plugin to return WARNING status.")); | 581 | printf(" %s\n", _("Minimum number of packages available for upgrade to return WARNING status.")); |
| 531 | printf (" %s\n", "-w, --packages-warning"); | 582 | printf(" %s\n\n", _("Default is 1 package.")); |
| 532 | printf (" %s\n", _("Minimum number of packages available for upgrade to return WARNING status.")); | 583 | |
| 533 | printf (" %s\n\n", _("Default is 1 package.")); | 584 | printf("%s\n\n", _("The following options require root privileges and should be used with care:")); |
| 534 | 585 | printf(" %s\n", "-u, --update=OPTS"); | |
| 535 | printf ("%s\n\n", _("The following options require root privileges and should be used with care:")); | 586 | printf(" %s\n", _("First perform an 'apt-get update'. An optional OPTS parameter overrides")); |
| 536 | printf (" %s\n", "-u, --update=OPTS"); | 587 | printf(" %s\n", _("the default options. Note: you may also need to adjust the global")); |
| 537 | printf (" %s\n", _("First perform an 'apt-get update'. An optional OPTS parameter overrides")); | 588 | printf(" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get")); |
| 538 | printf (" %s\n", _("the default options. Note: you may also need to adjust the global")); | 589 | printf(" %s\n", _("upgrade is expected to take longer than the default timeout.")); |
| 539 | printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get")); | 590 | printf(" %s\n", "-U, --upgrade=OPTS"); |
| 540 | printf (" %s\n", _("upgrade is expected to take longer than the default timeout.")); | 591 | printf(" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,")); |
| 541 | printf (" %s\n", "-U, --upgrade=OPTS"); | 592 | printf(" %s\n", _("apt-get will be run with these command line options instead of the")); |
| 542 | printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,")); | 593 | printf(" %s", _("default ")); |
| 543 | printf (" %s\n", _("apt-get will be run with these command line options instead of the")); | 594 | printf("(%s).\n", UPGRADE_DEFAULT_OPTS); |
| 544 | printf (" %s", _("default ")); | 595 | printf(" %s\n", _("Note that you may be required to have root privileges if you do not use")); |
| 545 | printf ("(%s).\n", UPGRADE_DEFAULT_OPTS); | 596 | printf(" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade")); |
| 546 | printf (" %s\n", _("Note that you may be required to have root privileges if you do not use")); | 597 | printf(" %s\n", "-d, --dist-upgrade=OPTS"); |
| 547 | printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade")); | 598 | printf(" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS")); |
| 548 | printf (" %s\n", "-d, --dist-upgrade=OPTS"); | 599 | printf(" %s\n", _("can be provided to override the default options.")); |
| 549 | printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS")); | 600 | |
| 550 | printf (" %s\n", _("can be provided to override the default options.")); | 601 | printf(UT_SUPPORT); |
| 551 | |||
| 552 | printf(UT_SUPPORT); | ||
| 553 | } | 602 | } |
| 554 | 603 | ||
| 555 | |||
| 556 | /* simple usage heading */ | 604 | /* simple usage heading */ |
| 557 | void | 605 | void print_usage(void) { |
| 558 | print_usage(void) | 606 | printf("%s\n", _("Usage:")); |
| 559 | { | 607 | printf("%s [[-d|-u|-U]opts] [-n] [-l] [-t timeout] [-w packages-warning]\n", progname); |
| 560 | printf ("%s\n", _("Usage:")); | ||
| 561 | printf ("%s [[-d|-u|-U]opts] [-n] [-l] [-t timeout] [-w packages-warning]\n", progname); | ||
| 562 | } | 608 | } |
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 1d27da28..8ea73ce1 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
| @@ -525,7 +525,7 @@ int check_http(void) { | |||
| 525 | // use the host_name later on to make SNI happy | 525 | // use the host_name later on to make SNI happy |
| 526 | if (use_ssl && host_name != NULL) { | 526 | if (use_ssl && host_name != NULL) { |
| 527 | if ((res = lookup_host(server_address, addrstr, DEFAULT_BUFFER_SIZE / 2)) != 0) { | 527 | if ((res = lookup_host(server_address, addrstr, DEFAULT_BUFFER_SIZE / 2)) != 0) { |
| 528 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %d"), server_address, res, | 528 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), server_address, res, |
| 529 | gai_strerror(res)); | 529 | gai_strerror(res)); |
| 530 | die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); | 530 | die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); |
| 531 | } | 531 | } |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index d1d1b92a..037a6f7a 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
| @@ -156,20 +156,20 @@ static struct name_list *seen = NULL; | |||
| 156 | int main(int argc, char **argv) { | 156 | int main(int argc, char **argv) { |
| 157 | int result = STATE_UNKNOWN; | 157 | int result = STATE_UNKNOWN; |
| 158 | int disk_result = STATE_UNKNOWN; | 158 | int disk_result = STATE_UNKNOWN; |
| 159 | char *output; | 159 | char *output = NULL; |
| 160 | char *ignored; | 160 | char *ignored = NULL; |
| 161 | char *details; | 161 | char *details = NULL; |
| 162 | char *perf; | 162 | char *perf = NULL; |
| 163 | char *perf_ilabel; | 163 | char *perf_ilabel = NULL; |
| 164 | char *preamble = " - free space:"; | 164 | char *preamble = " - free space:"; |
| 165 | char *ignored_preamble = " - ignored paths:"; | 165 | char *ignored_preamble = " - ignored paths:"; |
| 166 | char *flag_header; | 166 | char *flag_header = NULL; |
| 167 | int temp_result; | 167 | int temp_result = STATE_UNKNOWN; |
| 168 | 168 | ||
| 169 | struct mount_entry *me; | 169 | struct mount_entry *me = NULL; |
| 170 | struct fs_usage fsp; | 170 | struct fs_usage fsp = {0}; |
| 171 | struct parameter_list *temp_list; | 171 | struct parameter_list *temp_list = NULL; |
| 172 | struct parameter_list *path; | 172 | struct parameter_list *path = NULL; |
| 173 | 173 | ||
| 174 | #ifdef __CYGWIN__ | 174 | #ifdef __CYGWIN__ |
| 175 | char mountdir[32]; | 175 | char mountdir[32]; |
diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 49235e28..c1d03ece 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | * | 7 | * |
| 8 | * Description: | 8 | * Description: |
| 9 | * | 9 | * |
| 10 | * This file contains the check_disk plugin | 10 | * This file contains the check_fping plugin |
| 11 | * | 11 | * |
| 12 | * This plugin will use the fping command to ping the specified host for a | 12 | * This plugin will use the fping command to ping the specified host for a |
| 13 | * fast check | 13 | * fast check |
| @@ -60,6 +60,8 @@ static int packet_count = PACKET_COUNT; | |||
| 60 | static int target_timeout = 0; | 60 | static int target_timeout = 0; |
| 61 | static int packet_interval = 0; | 61 | static int packet_interval = 0; |
| 62 | static bool verbose = false; | 62 | static bool verbose = false; |
| 63 | static bool dontfrag = false; | ||
| 64 | static bool randomize_packet_data = false; | ||
| 63 | static int cpl; | 65 | static int cpl; |
| 64 | static int wpl; | 66 | static int wpl; |
| 65 | static double crta; | 67 | static double crta; |
| @@ -103,6 +105,11 @@ int main(int argc, char **argv) { | |||
| 103 | xasprintf(&option_string, "%s-S %s ", option_string, sourceip); | 105 | xasprintf(&option_string, "%s-S %s ", option_string, sourceip); |
| 104 | if (sourceif) | 106 | if (sourceif) |
| 105 | xasprintf(&option_string, "%s-I %s ", option_string, sourceif); | 107 | xasprintf(&option_string, "%s-I %s ", option_string, sourceif); |
| 108 | if (dontfrag) | ||
| 109 | xasprintf(&option_string, "%s-M ", option_string); | ||
| 110 | if (randomize_packet_data) | ||
| 111 | xasprintf(&option_string, "%s-R ", option_string); | ||
| 112 | |||
| 106 | 113 | ||
| 107 | #ifdef PATH_TO_FPING6 | 114 | #ifdef PATH_TO_FPING6 |
| 108 | if (address_family != AF_INET && is_inet6_addr(server)) | 115 | if (address_family != AF_INET && is_inet6_addr(server)) |
| @@ -279,6 +286,8 @@ int process_arguments(int argc, char **argv) { | |||
| 279 | {"help", no_argument, 0, 'h'}, | 286 | {"help", no_argument, 0, 'h'}, |
| 280 | {"use-ipv4", no_argument, 0, '4'}, | 287 | {"use-ipv4", no_argument, 0, '4'}, |
| 281 | {"use-ipv6", no_argument, 0, '6'}, | 288 | {"use-ipv6", no_argument, 0, '6'}, |
| 289 | {"dontfrag", no_argument, 0, 'M'}, | ||
| 290 | {"random", no_argument, 0, 'R'}, | ||
| 282 | {0, 0, 0, 0}}; | 291 | {0, 0, 0, 0}}; |
| 283 | 292 | ||
| 284 | rv[PL] = NULL; | 293 | rv[PL] = NULL; |
| @@ -295,7 +304,7 @@ int process_arguments(int argc, char **argv) { | |||
| 295 | } | 304 | } |
| 296 | 305 | ||
| 297 | while (1) { | 306 | while (1) { |
| 298 | c = getopt_long(argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:46", longopts, &option); | 307 | c = getopt_long(argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:M:R:46", longopts, &option); |
| 299 | 308 | ||
| 300 | if (c == -1 || c == EOF || c == 1) | 309 | if (c == -1 || c == EOF || c == 1) |
| 301 | break; | 310 | break; |
| @@ -390,6 +399,12 @@ int process_arguments(int argc, char **argv) { | |||
| 390 | else | 399 | else |
| 391 | usage(_("Interval must be a positive integer")); | 400 | usage(_("Interval must be a positive integer")); |
| 392 | break; | 401 | break; |
| 402 | case 'R': | ||
| 403 | randomize_packet_data = true; | ||
| 404 | break; | ||
| 405 | case 'M': | ||
| 406 | dontfrag = true; | ||
| 407 | break; | ||
| 393 | } | 408 | } |
| 394 | } | 409 | } |
| 395 | 410 | ||
| @@ -470,6 +485,10 @@ void print_help(void) { | |||
| 470 | printf(" %s\n", _("name or IP Address of sourceip")); | 485 | printf(" %s\n", _("name or IP Address of sourceip")); |
| 471 | printf(" %s\n", "-I, --sourceif=IF"); | 486 | printf(" %s\n", "-I, --sourceif=IF"); |
| 472 | printf(" %s\n", _("source interface name")); | 487 | printf(" %s\n", _("source interface name")); |
| 488 | printf(" %s\n", "-M, --dontfrag"); | ||
| 489 | printf(" %s\n", _("set the Don't Fragment flag")); | ||
| 490 | printf(" %s\n", "-R, --random"); | ||
| 491 | printf(" %s\n", _("random packet data (to foil link data compression)")); | ||
| 473 | printf(UT_VERBOSE); | 492 | printf(UT_VERBOSE); |
| 474 | printf("\n"); | 493 | printf("\n"); |
| 475 | printf(" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)")); | 494 | printf(" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)")); |
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 381dbd80..9640ef70 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c | |||
| @@ -113,12 +113,10 @@ typedef struct values_s { | |||
| 113 | __u8 checksum; | 113 | __u8 checksum; |
| 114 | } __attribute__((packed)) values_t; | 114 | } __attribute__((packed)) values_t; |
| 115 | 115 | ||
| 116 | struct { | 116 | static struct { |
| 117 | __u8 value; | 117 | __u8 value; |
| 118 | char *text; | 118 | char *text; |
| 119 | } | 119 | } offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"}, |
| 120 | |||
| 121 | static offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"}, | ||
| 122 | {0x05, "Aborted"}, {0x06, "Failed"}, {0, 0}}; | 120 | {0x05, "Aborted"}, {0x06, "Failed"}, {0, 0}}; |
| 123 | 121 | ||
| 124 | static struct { | 122 | static struct { |
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index 1c728292..87818da6 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c | |||
| @@ -47,37 +47,37 @@ enum { | |||
| 47 | DEFAULT_PORT = 389 | 47 | DEFAULT_PORT = 389 |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | int process_arguments (int, char **); | 50 | static int process_arguments (int, char **); |
| 51 | int validate_arguments (void); | 51 | static int validate_arguments (void); |
| 52 | void print_help (void); | 52 | static void print_help (void); |
| 53 | void print_usage (void); | 53 | void print_usage (void); |
| 54 | 54 | ||
| 55 | char ld_defattr[] = "(objectclass=*)"; | 55 | static char ld_defattr[] = "(objectclass=*)"; |
| 56 | char *ld_attr = ld_defattr; | 56 | static char *ld_attr = ld_defattr; |
| 57 | char *ld_host = NULL; | 57 | static char *ld_host = NULL; |
| 58 | char *ld_base = NULL; | 58 | static char *ld_base = NULL; |
| 59 | char *ld_passwd = NULL; | 59 | static char *ld_passwd = NULL; |
| 60 | char *ld_binddn = NULL; | 60 | static char *ld_binddn = NULL; |
| 61 | int ld_port = -1; | 61 | static int ld_port = -1; |
| 62 | #ifdef HAVE_LDAP_SET_OPTION | 62 | #ifdef HAVE_LDAP_SET_OPTION |
| 63 | int ld_protocol = DEFAULT_PROTOCOL; | 63 | static int ld_protocol = DEFAULT_PROTOCOL; |
| 64 | #endif | 64 | #endif |
| 65 | #ifndef LDAP_OPT_SUCCESS | 65 | #ifndef LDAP_OPT_SUCCESS |
| 66 | # define LDAP_OPT_SUCCESS LDAP_SUCCESS | 66 | # define LDAP_OPT_SUCCESS LDAP_SUCCESS |
| 67 | #endif | 67 | #endif |
| 68 | double warn_time = UNDEFINED; | 68 | static double warn_time = UNDEFINED; |
| 69 | double crit_time = UNDEFINED; | 69 | static double crit_time = UNDEFINED; |
| 70 | thresholds *entries_thresholds = NULL; | 70 | static thresholds *entries_thresholds = NULL; |
| 71 | struct timeval tv; | 71 | static struct timeval tv; |
| 72 | char* warn_entries = NULL; | 72 | static char* warn_entries = NULL; |
| 73 | char* crit_entries = NULL; | 73 | static char* crit_entries = NULL; |
| 74 | bool starttls = false; | 74 | static bool starttls = false; |
| 75 | bool ssl_on_connect = false; | 75 | static bool ssl_on_connect = false; |
| 76 | bool verbose = false; | 76 | static bool verbose = false; |
| 77 | 77 | ||
| 78 | /* for ldap tls */ | 78 | /* for ldap tls */ |
| 79 | 79 | ||
| 80 | char *SERVICE = "LDAP"; | 80 | static char *SERVICE = "LDAP"; |
| 81 | 81 | ||
| 82 | int | 82 | int |
| 83 | main (int argc, char *argv[]) | 83 | main (int argc, char *argv[]) |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 1f0b7099..8a73772d 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
| @@ -45,23 +45,23 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 45 | #include <mysqld_error.h> | 45 | #include <mysqld_error.h> |
| 46 | #include <errmsg.h> | 46 | #include <errmsg.h> |
| 47 | 47 | ||
| 48 | char *db_user = NULL; | 48 | static char *db_user = NULL; |
| 49 | char *db_host = NULL; | 49 | static char *db_host = NULL; |
| 50 | char *db_socket = NULL; | 50 | static char *db_socket = NULL; |
| 51 | char *db_pass = NULL; | 51 | static char *db_pass = NULL; |
| 52 | char *db = NULL; | 52 | static char *db = NULL; |
| 53 | char *ca_cert = NULL; | 53 | static char *ca_cert = NULL; |
| 54 | char *ca_dir = NULL; | 54 | static char *ca_dir = NULL; |
| 55 | char *cert = NULL; | 55 | static char *cert = NULL; |
| 56 | char *key = NULL; | 56 | static char *key = NULL; |
| 57 | char *ciphers = NULL; | 57 | static char *ciphers = NULL; |
| 58 | bool ssl = false; | 58 | static bool ssl = false; |
| 59 | char *opt_file = NULL; | 59 | static char *opt_file = NULL; |
| 60 | char *opt_group = NULL; | 60 | static char *opt_group = NULL; |
| 61 | unsigned int db_port = MYSQL_PORT; | 61 | static unsigned int db_port = MYSQL_PORT; |
| 62 | bool check_slave = false; | 62 | static bool check_slave = false; |
| 63 | bool ignore_auth = false; | 63 | static bool ignore_auth = false; |
| 64 | int verbose = 0; | 64 | static int verbose = 0; |
| 65 | 65 | ||
| 66 | static double warning_time = 0; | 66 | static double warning_time = 0; |
| 67 | static double critical_time = 0; | 67 | static double critical_time = 0; |
| @@ -91,11 +91,11 @@ static const char *metric_counter[LENGTH_METRIC_COUNTER] = { | |||
| 91 | 91 | ||
| 92 | #define MYSQLDUMP_THREADS_QUERY "SELECT COUNT(1) mysqldumpThreads FROM information_schema.processlist WHERE info LIKE 'SELECT /*!40001 SQL_NO_CACHE */%'" | 92 | #define MYSQLDUMP_THREADS_QUERY "SELECT COUNT(1) mysqldumpThreads FROM information_schema.processlist WHERE info LIKE 'SELECT /*!40001 SQL_NO_CACHE */%'" |
| 93 | 93 | ||
| 94 | thresholds *my_threshold = NULL; | 94 | static thresholds *my_threshold = NULL; |
| 95 | 95 | ||
| 96 | int process_arguments (int, char **); | 96 | static int process_arguments (int, char **); |
| 97 | int validate_arguments (void); | 97 | static int validate_arguments (void); |
| 98 | void print_help (void); | 98 | static void print_help (void); |
| 99 | void print_usage (void); | 99 | void print_usage (void); |
| 100 | 100 | ||
| 101 | int | 101 | int |
diff --git a/plugins/check_nt.c b/plugins/check_nt.c index 413aad6b..dec0b668 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c | |||
| @@ -59,26 +59,25 @@ enum { | |||
| 59 | PORT = 1248 | 59 | PORT = 1248 |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | char *server_address = NULL; | 62 | static char *server_address = NULL; |
| 63 | char *volume_name = NULL; | 63 | static int server_port = PORT; |
| 64 | int server_port = PORT; | 64 | static char *value_list = NULL; |
| 65 | char *value_list = NULL; | 65 | static char *req_password = NULL; |
| 66 | char *req_password = NULL; | 66 | static unsigned long lvalue_list[MAX_VALUE_LIST]; |
| 67 | unsigned long lvalue_list[MAX_VALUE_LIST]; | 67 | static unsigned long warning_value = 0L; |
| 68 | unsigned long warning_value = 0L; | 68 | static unsigned long critical_value = 0L; |
| 69 | unsigned long critical_value = 0L; | 69 | static bool check_warning_value = false; |
| 70 | bool check_warning_value = false; | 70 | static bool check_critical_value = false; |
| 71 | bool check_critical_value = false; | 71 | static enum checkvars vars_to_check = CHECK_NONE; |
| 72 | enum checkvars vars_to_check = CHECK_NONE; | 72 | static bool show_all = false; |
| 73 | bool show_all = false; | 73 | |
| 74 | 74 | static char recv_buffer[MAX_INPUT_BUFFER]; | |
| 75 | char recv_buffer[MAX_INPUT_BUFFER]; | 75 | |
| 76 | 76 | static void fetch_data(const char *address, int port, const char *sendb); | |
| 77 | void fetch_data(const char *address, int port, const char *sendb); | 77 | static int process_arguments(int /*argc*/, char ** /*argv*/); |
| 78 | int process_arguments(int, char **); | 78 | static void preparelist(char *string); |
| 79 | void preparelist(char *string); | 79 | static bool strtoularray(unsigned long *array, char *string, const char *delim); |
| 80 | bool strtoularray(unsigned long *array, char *string, const char *delim); | 80 | static void print_help(void); |
| 81 | void print_help(void); | ||
| 82 | void print_usage(void); | 81 | void print_usage(void); |
| 83 | 82 | ||
| 84 | int main(int argc, char **argv) { | 83 | int main(int argc, char **argv) { |
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c index 55a49460..d33f8786 100644 --- a/plugins/check_ntp.c +++ b/plugins/check_ntp.c | |||
| @@ -47,10 +47,10 @@ static bool do_jitter = false; | |||
| 47 | static char *jwarn="5000"; | 47 | static char *jwarn="5000"; |
| 48 | static char *jcrit="10000"; | 48 | static char *jcrit="10000"; |
| 49 | 49 | ||
| 50 | int process_arguments (int, char **); | 50 | static int process_arguments (int /*argc*/, char ** /*argv*/); |
| 51 | thresholds *offset_thresholds = NULL; | 51 | static thresholds *offset_thresholds = NULL; |
| 52 | thresholds *jitter_thresholds = NULL; | 52 | static thresholds *jitter_thresholds = NULL; |
| 53 | void print_help (void); | 53 | static void print_help (void); |
| 54 | void print_usage (void); | 54 | void print_usage (void); |
| 55 | 55 | ||
| 56 | /* number of times to perform each request to get a good average. */ | 56 | /* number of times to perform each request to get a good average. */ |
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 3af63603..176dfbc8 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c | |||
| @@ -89,30 +89,30 @@ enum { | |||
| 89 | PORT = 9999 | 89 | PORT = 9999 |
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| 92 | char *server_address = NULL; | 92 | static char *server_address = NULL; |
| 93 | char *volume_name = NULL; | 93 | static char *volume_name = NULL; |
| 94 | char *nlm_name = NULL; | 94 | static char *nlm_name = NULL; |
| 95 | char *nrmp_name = NULL; | 95 | static char *nrmp_name = NULL; |
| 96 | char *nrmm_name = NULL; | 96 | static char *nrmm_name = NULL; |
| 97 | char *nrms_name = NULL; | 97 | static char *nrms_name = NULL; |
| 98 | char *nss1_name = NULL; | 98 | static char *nss1_name = NULL; |
| 99 | char *nss2_name = NULL; | 99 | static char *nss2_name = NULL; |
| 100 | char *nss3_name = NULL; | 100 | static char *nss3_name = NULL; |
| 101 | char *nss4_name = NULL; | 101 | static char *nss4_name = NULL; |
| 102 | char *nss5_name = NULL; | 102 | static char *nss5_name = NULL; |
| 103 | char *nss6_name = NULL; | 103 | static char *nss6_name = NULL; |
| 104 | char *nss7_name = NULL; | 104 | static char *nss7_name = NULL; |
| 105 | int server_port = PORT; | 105 | static int server_port = PORT; |
| 106 | unsigned long warning_value = 0L; | 106 | static unsigned long warning_value = 0L; |
| 107 | unsigned long critical_value = 0L; | 107 | static unsigned long critical_value = 0L; |
| 108 | bool check_warning_value = false; | 108 | static bool check_warning_value = false; |
| 109 | bool check_critical_value = false; | 109 | static bool check_critical_value = false; |
| 110 | bool check_netware_version = false; | 110 | static bool check_netware_version = false; |
| 111 | enum checkvar vars_to_check = NONE; | 111 | static enum checkvar vars_to_check = NONE; |
| 112 | int sap_number = -1; | 112 | static int sap_number = -1; |
| 113 | 113 | ||
| 114 | int process_arguments(int, char **); | 114 | static int process_arguments(int /*argc*/, char ** /*argv*/); |
| 115 | void print_help(void); | 115 | static void print_help(void); |
| 116 | void print_usage(void); | 116 | void print_usage(void); |
| 117 | 117 | ||
| 118 | int main(int argc, char **argv) { | 118 | int main(int argc, char **argv) { |
diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c index e80d4775..599540b7 100644 --- a/plugins/check_overcr.c +++ b/plugins/check_overcr.c | |||
| @@ -52,23 +52,22 @@ enum { | |||
| 52 | PORT = 2000 | 52 | PORT = 2000 |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | char *server_address = NULL; | 55 | static char *server_address = NULL; |
| 56 | int server_port = PORT; | 56 | static int server_port = PORT; |
| 57 | double warning_value = 0L; | 57 | static double warning_value = 0L; |
| 58 | double critical_value = 0L; | 58 | static double critical_value = 0L; |
| 59 | bool check_warning_value = false; | 59 | static bool check_warning_value = false; |
| 60 | bool check_critical_value = false; | 60 | static bool check_critical_value = false; |
| 61 | enum checkvar vars_to_check = NONE; | 61 | static enum checkvar vars_to_check = NONE; |
| 62 | int cmd_timeout = 1; | 62 | |
| 63 | 63 | static int netstat_port = 0; | |
| 64 | int netstat_port = 0; | 64 | static char *disk_name = NULL; |
| 65 | char *disk_name = NULL; | 65 | static char *process_name = NULL; |
| 66 | char *process_name = NULL; | 66 | static char send_buffer[MAX_INPUT_BUFFER]; |
| 67 | char send_buffer[MAX_INPUT_BUFFER]; | 67 | |
| 68 | 68 | static int process_arguments(int, char **); | |
| 69 | int process_arguments(int, char **); | ||
| 70 | void print_usage(void); | 69 | void print_usage(void); |
| 71 | void print_help(void); | 70 | static void print_help(void); |
| 72 | 71 | ||
| 73 | int main(int argc, char **argv) { | 72 | int main(int argc, char **argv) { |
| 74 | int result = STATE_UNKNOWN; | 73 | int result = STATE_UNKNOWN; |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 5777ba07..1d78ccee 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c | |||
| @@ -51,17 +51,17 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | int process_arguments (int, char **); | 54 | static int process_arguments (int /*argc*/, char ** /*argv*/); |
| 55 | int validate_arguments (void); | 55 | static int validate_arguments (void); |
| 56 | int convert_to_seconds (char *); | 56 | static int convert_to_seconds (char * /*etime*/); |
| 57 | void print_help (void); | 57 | static void print_help (void); |
| 58 | void print_usage (void); | 58 | void print_usage (void); |
| 59 | 59 | ||
| 60 | char *warning_range = NULL; | 60 | static char *warning_range = NULL; |
| 61 | char *critical_range = NULL; | 61 | static char *critical_range = NULL; |
| 62 | thresholds *procs_thresholds = NULL; | 62 | static thresholds *procs_thresholds = NULL; |
| 63 | 63 | ||
| 64 | int options = 0; /* bitmask of filter criteria to test against */ | 64 | static int options = 0; /* bitmask of filter criteria to test against */ |
| 65 | #define ALL 1 | 65 | #define ALL 1 |
| 66 | #define STAT 2 | 66 | #define STAT 2 |
| 67 | #define PPID 4 | 67 | #define PPID 4 |
| @@ -89,27 +89,25 @@ enum metric { | |||
| 89 | }; | 89 | }; |
| 90 | enum metric metric = METRIC_PROCS; | 90 | enum metric metric = METRIC_PROCS; |
| 91 | 91 | ||
| 92 | int verbose = 0; | 92 | static int verbose = 0; |
| 93 | int uid; | 93 | static int uid; |
| 94 | pid_t ppid; | 94 | static pid_t ppid; |
| 95 | int vsz; | 95 | static int vsz; |
| 96 | int rss; | 96 | static int rss; |
| 97 | float pcpu; | 97 | static float pcpu; |
| 98 | char *statopts; | 98 | static char *statopts; |
| 99 | char *prog; | 99 | static char *prog; |
| 100 | char *exclude_progs; | 100 | static char *exclude_progs; |
| 101 | char **exclude_progs_arr = NULL; | 101 | static char **exclude_progs_arr = NULL; |
| 102 | char exclude_progs_counter = 0; | 102 | static char exclude_progs_counter = 0; |
| 103 | char *args; | 103 | static char *args; |
| 104 | char *input_filename = NULL; | 104 | static char *input_filename = NULL; |
| 105 | regex_t re_args; | 105 | static regex_t re_args; |
| 106 | char *fmt; | 106 | static char *fmt; |
| 107 | char *fails; | 107 | static char *fails; |
| 108 | char tmp[MAX_INPUT_BUFFER]; | 108 | static char tmp[MAX_INPUT_BUFFER]; |
| 109 | int kthread_filter = 0; | 109 | static int kthread_filter = 0; |
| 110 | int usepid = 0; /* whether to test for pid or /proc/pid/exe */ | 110 | static int usepid = 0; /* whether to test for pid or /proc/pid/exe */ |
| 111 | |||
| 112 | FILE *ps_input = NULL; | ||
| 113 | 111 | ||
| 114 | static int | 112 | static int |
| 115 | stat_exe (const pid_t pid, struct stat *buf) { | 113 | stat_exe (const pid_t pid, struct stat *buf) { |
| @@ -834,7 +832,7 @@ be the total number of running processes\n\n")); | |||
| 834 | printf (" %s\n", "check_procs -w 50000 -c 100000 --metric=VSZ"); | 832 | printf (" %s\n", "check_procs -w 50000 -c 100000 --metric=VSZ"); |
| 835 | printf (" %s\n\n", _("Alert if VSZ of any processes over 50K or 100K")); | 833 | printf (" %s\n\n", _("Alert if VSZ of any processes over 50K or 100K")); |
| 836 | printf (" %s\n", "check_procs -w 10 -c 20 --metric=CPU"); | 834 | printf (" %s\n", "check_procs -w 10 -c 20 --metric=CPU"); |
| 837 | printf (" %s\n", _("Alert if CPU of any processes over 10\% or 20\%")); | 835 | printf (" %s\n", _("Alert if CPU of any processes over 10%% or 20%%")); |
| 838 | 836 | ||
| 839 | printf (UT_SUPPORT); | 837 | printf (UT_SUPPORT); |
| 840 | } | 838 | } |
diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 8ed19e55..d9ff8fa7 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c | |||
| @@ -46,8 +46,8 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 46 | #include <radiusclient.h> | 46 | #include <radiusclient.h> |
| 47 | #endif | 47 | #endif |
| 48 | 48 | ||
| 49 | int process_arguments (int, char **); | 49 | static int process_arguments (int /*argc*/, char ** /*argv*/); |
| 50 | void print_help (void); | 50 | static void print_help (void); |
| 51 | void print_usage (void); | 51 | void print_usage (void); |
| 52 | 52 | ||
| 53 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) | 53 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) |
| @@ -78,22 +78,22 @@ void print_usage (void); | |||
| 78 | #define REJECT_RC BADRESP_RC | 78 | #define REJECT_RC BADRESP_RC |
| 79 | #endif | 79 | #endif |
| 80 | 80 | ||
| 81 | int my_rc_read_config(char *); | 81 | static int my_rc_read_config(char * /*a*/); |
| 82 | 82 | ||
| 83 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) | 83 | #if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI) |
| 84 | rc_handle *rch = NULL; | 84 | static rc_handle *rch = NULL; |
| 85 | #endif | 85 | #endif |
| 86 | 86 | ||
| 87 | char *server = NULL; | 87 | static char *server = NULL; |
| 88 | char *username = NULL; | 88 | static char *username = NULL; |
| 89 | char *password = NULL; | 89 | static char *password = NULL; |
| 90 | char *nasid = NULL; | 90 | static char *nasid = NULL; |
| 91 | char *nasipaddress = NULL; | 91 | static char *nasipaddress = NULL; |
| 92 | char *expect = NULL; | 92 | static char *expect = NULL; |
| 93 | char *config_file = NULL; | 93 | static char *config_file = NULL; |
| 94 | unsigned short port = PW_AUTH_UDP_PORT; | 94 | static unsigned short port = PW_AUTH_UDP_PORT; |
| 95 | int retries = 1; | 95 | static int retries = 1; |
| 96 | bool verbose = false; | 96 | static bool verbose = false; |
| 97 | 97 | ||
| 98 | /****************************************************************************** | 98 | /****************************************************************************** |
| 99 | 99 | ||
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index bc175287..e6369e63 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
| @@ -40,8 +40,8 @@ const char *email = "devel@monitoring-plugins.org"; | |||
| 40 | #include <ctype.h> | 40 | #include <ctype.h> |
| 41 | 41 | ||
| 42 | #ifdef HAVE_SSL | 42 | #ifdef HAVE_SSL |
| 43 | bool check_cert = false; | 43 | static bool check_cert = false; |
| 44 | int days_till_exp_warn, days_till_exp_crit; | 44 | static int days_till_exp_warn, days_till_exp_crit; |
| 45 | # define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) | 45 | # define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) |
| 46 | # define my_send(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0)) | 46 | # define my_send(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0)) |
| 47 | #else /* ifndef HAVE_SSL */ | 47 | #else /* ifndef HAVE_SSL */ |
| @@ -64,61 +64,59 @@ enum { | |||
| 64 | 64 | ||
| 65 | #define EHLO_SUPPORTS_STARTTLS 1 | 65 | #define EHLO_SUPPORTS_STARTTLS 1 |
| 66 | 66 | ||
| 67 | int process_arguments (int, char **); | 67 | static int process_arguments (int, char **); |
| 68 | int validate_arguments (void); | 68 | static int validate_arguments (void); |
| 69 | void print_help (void); | 69 | static void print_help (void); |
| 70 | void print_usage (void); | 70 | void print_usage (void); |
| 71 | void smtp_quit(void); | 71 | static void smtp_quit(void); |
| 72 | int recvline(char *, size_t); | 72 | static int recvline(char *, size_t); |
| 73 | int recvlines(char *, size_t); | 73 | static int recvlines(char *, size_t); |
| 74 | int my_close(void); | 74 | static int my_close(void); |
| 75 | 75 | ||
| 76 | #include "regex.h" | 76 | #include "regex.h" |
| 77 | char regex_expect[MAX_INPUT_BUFFER] = ""; | 77 | static regex_t preg; |
| 78 | regex_t preg; | 78 | static regmatch_t pmatch[10]; |
| 79 | regmatch_t pmatch[10]; | 79 | static char errbuf[MAX_INPUT_BUFFER]; |
| 80 | char timestamp[20] = ""; | 80 | static int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
| 81 | char errbuf[MAX_INPUT_BUFFER]; | 81 | static int eflags = 0; |
| 82 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 82 | static int errcode, excode; |
| 83 | int eflags = 0; | 83 | |
| 84 | int errcode, excode; | 84 | static int server_port = SMTP_PORT; |
| 85 | 85 | static int server_port_option = 0; | |
| 86 | int server_port = SMTP_PORT; | 86 | static char *server_address = NULL; |
| 87 | int server_port_option = 0; | 87 | static char *server_expect = NULL; |
| 88 | char *server_address = NULL; | 88 | static char *mail_command = NULL; |
| 89 | char *server_expect = NULL; | 89 | static char *from_arg = NULL; |
| 90 | char *mail_command = NULL; | 90 | static int send_mail_from=0; |
| 91 | char *from_arg = NULL; | 91 | static int ncommands=0; |
| 92 | int send_mail_from=0; | 92 | static int command_size=0; |
| 93 | int ncommands=0; | 93 | static int nresponses=0; |
| 94 | int command_size=0; | 94 | static int response_size=0; |
| 95 | int nresponses=0; | 95 | static char **commands = NULL; |
| 96 | int response_size=0; | 96 | static char **responses = NULL; |
| 97 | char **commands = NULL; | 97 | static char *authtype = NULL; |
| 98 | char **responses = NULL; | 98 | static char *authuser = NULL; |
| 99 | char *authtype = NULL; | 99 | static char *authpass = NULL; |
| 100 | char *authuser = NULL; | 100 | static double warning_time = 0; |
| 101 | char *authpass = NULL; | 101 | static bool check_warning_time = false; |
| 102 | double warning_time = 0; | 102 | static double critical_time = 0; |
| 103 | bool check_warning_time = false; | 103 | static bool check_critical_time = false; |
| 104 | double critical_time = 0; | 104 | static int verbose = 0; |
| 105 | bool check_critical_time = false; | 105 | static bool use_ssl = false; |
| 106 | int verbose = 0; | 106 | static bool use_starttls = false; |
| 107 | bool use_ssl = false; | 107 | static bool use_sni = false; |
| 108 | bool use_starttls = false; | 108 | static bool use_proxy_prefix = false; |
| 109 | bool use_sni = false; | 109 | static bool use_ehlo = false; |
| 110 | bool use_proxy_prefix = false; | 110 | static bool use_lhlo = false; |
| 111 | bool use_ehlo = false; | 111 | static bool ssl_established = false; |
| 112 | bool use_lhlo = false; | 112 | static char *localhostname = NULL; |
| 113 | bool ssl_established = false; | 113 | static int sd; |
| 114 | char *localhostname = NULL; | 114 | static char buffer[MAX_INPUT_BUFFER]; |
| 115 | int sd; | ||
| 116 | char buffer[MAX_INPUT_BUFFER]; | ||
| 117 | enum { | 115 | enum { |
| 118 | TCP_PROTOCOL = 1, | 116 | TCP_PROTOCOL = 1, |
| 119 | UDP_PROTOCOL = 2, | 117 | UDP_PROTOCOL = 2, |
| 120 | }; | 118 | }; |
| 121 | bool ignore_send_quit_failure = false; | 119 | static bool ignore_send_quit_failure = false; |
| 122 | 120 | ||
| 123 | 121 | ||
| 124 | int | 122 | int |
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index c13ac767..49ad096c 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
| @@ -119,7 +119,7 @@ int main(int argc, char **argv) { | |||
| 119 | 119 | ||
| 120 | /* set up a reasonable buffer at first (will be realloc()'ed if | 120 | /* set up a reasonable buffer at first (will be realloc()'ed if |
| 121 | * user specifies other options) */ | 121 | * user specifies other options) */ |
| 122 | server_expect = calloc(sizeof(char *), 2); | 122 | server_expect = calloc(2, sizeof(char *)); |
| 123 | 123 | ||
| 124 | /* determine defaults for this service's protocol */ | 124 | /* determine defaults for this service's protocol */ |
| 125 | if (!strncmp(SERVICE, "UDP", 3)) { | 125 | if (!strncmp(SERVICE, "UDP", 3)) { |
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index adb7ab81..526a29df 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c | |||
| @@ -97,12 +97,12 @@ ups_config ups_config_init(void) { | |||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | // Forward declarations | 99 | // Forward declarations |
| 100 | int determine_status(ups_config *, int *supported_options); | 100 | static int determine_status(ups_config * /*config*/, int *supported_options); |
| 101 | int get_ups_variable(const char *, char *, const ups_config config); | 101 | static int get_ups_variable(const char * /*varname*/, char * /*buf*/, ups_config config); |
| 102 | 102 | ||
| 103 | int process_arguments(int, char **, ups_config *); | 103 | static int process_arguments(int /*argc*/, char ** /*argv*/, ups_config * /*config*/); |
| 104 | int validate_arguments(ups_config); | 104 | static int validate_arguments(ups_config /*config*/); |
| 105 | void print_help(void); | 105 | static void print_help(void); |
| 106 | void print_usage(void); | 106 | void print_usage(void); |
| 107 | 107 | ||
| 108 | int main(int argc, char **argv) { | 108 | int main(int argc, char **argv) { |
diff --git a/plugins/runcmd.c b/plugins/runcmd.c index 2e53dc0b..74843149 100644 --- a/plugins/runcmd.c +++ b/plugins/runcmd.c | |||
| @@ -130,7 +130,7 @@ static int np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr) { | |||
| 130 | /* each arg must be whitespace-separated, so args can be a maximum | 130 | /* each arg must be whitespace-separated, so args can be a maximum |
| 131 | * of (len / 2) + 1. We add 1 extra to the mix for NULL termination */ | 131 | * of (len / 2) + 1. We add 1 extra to the mix for NULL termination */ |
| 132 | argc = (cmdlen >> 1) + 2; | 132 | argc = (cmdlen >> 1) + 2; |
| 133 | argv = calloc(sizeof(char *), argc); | 133 | argv = calloc(argc, sizeof(char *)); |
| 134 | 134 | ||
| 135 | if (argv == NULL) { | 135 | if (argv == NULL) { |
| 136 | printf("%s\n", _("Could not malloc argv array in popen()")); | 136 | printf("%s\n", _("Could not malloc argv array in popen()")); |
diff --git a/plugins/utils.c b/plugins/utils.c index f11db731..6d366e3d 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
| @@ -185,7 +185,7 @@ bool is_percentage_expression(const char str[]) { | |||
| 185 | return false; | 185 | return false; |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | char *foo = calloc(sizeof(char), len + 1); | 188 | char *foo = calloc(len + 1, sizeof(char)); |
| 189 | 189 | ||
| 190 | if (!foo) { | 190 | if (!foo) { |
| 191 | die(STATE_UNKNOWN, _("calloc failed \n")); | 191 | die(STATE_UNKNOWN, _("calloc failed \n")); |
