diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2026-06-10 14:49:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-10 14:49:33 +0200 |
| commit | f8aad020f7c0be604da8981663b6d815f94ffaa4 (patch) | |
| tree | e1c7bdeff275778b4dd324d26e826c861d143b48 | |
| parent | 47b1b2d754d4809006f6dc1aa13ba9c80405975c (diff) | |
| download | monitoring-plugins-f8aad020f7c0be604da8981663b6d815f94ffaa4.tar.gz | |
Run clang-format on everything once again (#2275)
Co-authored-by: Lorenz Kästle <lorenz.kaestle@netways.de>
| -rw-r--r-- | config_test/child_test.c | 116 | ||||
| -rw-r--r-- | lib/output.h | 2 | ||||
| -rw-r--r-- | lib/parse_ini.c | 3 | ||||
| -rw-r--r-- | lib/perfdata.c | 6 | ||||
| -rw-r--r-- | lib/utils_cmd.h | 10 | ||||
| -rw-r--r-- | plugins/check_by_ssh.c | 3 | ||||
| -rw-r--r-- | plugins/check_curl.d/check_curl_helpers.c | 2 | ||||
| -rw-r--r-- | plugins/check_curl.d/config.h | 1 | ||||
| -rw-r--r-- | plugins/check_ide_smart.c | 78 | ||||
| -rw-r--r-- | plugins/check_nagios.c | 33 | ||||
| -rw-r--r-- | plugins/common.h | 4 | ||||
| -rw-r--r-- | plugins/netutils.h | 7 | ||||
| -rw-r--r-- | plugins/sslutils.c | 3 | ||||
| -rw-r--r-- | plugins/utils.c | 1 |
14 files changed, 149 insertions, 120 deletions
diff --git a/config_test/child_test.c b/config_test/child_test.c index 2add3bcf..21439330 100644 --- a/config_test/child_test.c +++ b/config_test/child_test.c | |||
| @@ -5,73 +5,75 @@ | |||
| 5 | #include <stdio.h> | 5 | #include <stdio.h> |
| 6 | #include <sys/types.h> | 6 | #include <sys/types.h> |
| 7 | #include <signal.h> | 7 | #include <signal.h> |
| 8 | void popen_sigchld_handler (int); | 8 | void popen_sigchld_handler(int); |
| 9 | int childtermd; | 9 | int childtermd; |
| 10 | 10 | ||
| 11 | int main(){ | 11 | int main() { |
| 12 | char str[1024]; | 12 | char str[1024]; |
| 13 | int pipefd[2]; | 13 | int pipefd[2]; |
| 14 | pid_t pid; | 14 | pid_t pid; |
| 15 | int status, died; | 15 | int status, died; |
| 16 | 16 | ||
| 17 | if (signal (SIGCHLD, popen_sigchld_handler) == SIG_ERR) { | 17 | if (signal(SIGCHLD, popen_sigchld_handler) == SIG_ERR) { |
| 18 | printf ("Cannot catch SIGCHLD\n"); | 18 | printf("Cannot catch SIGCHLD\n"); |
| 19 | _exit(-1); | 19 | _exit(-1); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | pipe (pipefd); | 22 | pipe(pipefd); |
| 23 | switch(pid=fork()){ | 23 | switch (pid = fork()) { |
| 24 | case -1: | 24 | case -1: |
| 25 | printf("can't fork\n"); | 25 | printf("can't fork\n"); |
| 26 | _exit(-1); | 26 | _exit(-1); |
| 27 | 27 | ||
| 28 | case 0 : /* this is the code the child runs */ | 28 | case 0: /* this is the code the child runs */ |
| 29 | close(1); /* close stdout */ | 29 | close(1); /* close stdout */ |
| 30 | /* pipefd[1] is for writing to the pipe. We want the output | 30 | /* pipefd[1] is for writing to the pipe. We want the output |
| 31 | * that used to go to the standard output (file descriptor 1) | 31 | * that used to go to the standard output (file descriptor 1) |
| 32 | * to be written to the pipe. The following command does this, | 32 | * to be written to the pipe. The following command does this, |
| 33 | * creating a new file descriptor 1 (the lowest available) | 33 | * creating a new file descriptor 1 (the lowest available) |
| 34 | * that writes where pipefd[1] goes. */ | 34 | * that writes where pipefd[1] goes. */ |
| 35 | dup (pipefd[1]); /* points pipefd at file descriptor */ | 35 | dup(pipefd[1]); /* points pipefd at file descriptor */ |
| 36 | /* the child isn't going to read from the pipe, so | 36 | /* the child isn't going to read from the pipe, so |
| 37 | * pipefd[0] can be closed */ | 37 | * pipefd[0] can be closed */ |
| 38 | close (pipefd[0]); | 38 | close(pipefd[0]); |
| 39 | 39 | ||
| 40 | /* These are the commands to run, with success commented. dig and nslookup only problems */ | 40 | /* These are the commands to run, with success commented. dig and nslookup only problems */ |
| 41 | /*execl ("/bin/date","date",0);*/ /* 100% */ | 41 | /*execl ("/bin/date","date",0);*/ /* 100% */ |
| 42 | /*execl ("/bin/cat", "cat", "/etc/hosts", 0);*/ /* 100% */ | 42 | /*execl ("/bin/cat", "cat", "/etc/hosts", 0);*/ /* 100% */ |
| 43 | /*execl ("/usr/bin/dig", "dig", "redhat.com", 0);*/ /* 69% */ | 43 | /*execl ("/usr/bin/dig", "dig", "redhat.com", 0);*/ /* 69% */ |
| 44 | /*execl("/bin/sleep", "sleep", "1", 0);*/ /* 100% */ | 44 | /*execl("/bin/sleep", "sleep", "1", 0);*/ /* 100% */ |
| 45 | execl ("/usr/bin/nslookup","nslookup","redhat.com",0); /* 90% (after 100 tests), 40% (after 10 tests) */ | 45 | execl("/usr/bin/nslookup", "nslookup", "redhat.com", |
| 46 | /*execl ("/bin/ping","ping","-c","1","localhost",0);*/ /* 100% */ | 46 | 0); /* 90% (after 100 tests), 40% (after 10 tests) */ |
| 47 | /*execl ("/bin/ping","ping","-c","1","192.168.10.32",0);*/ /* 100% */ | 47 | /*execl ("/bin/ping","ping","-c","1","localhost",0);*/ /* 100% */ |
| 48 | _exit(0); | 48 | /*execl ("/bin/ping","ping","-c","1","192.168.10.32",0);*/ /* 100% */ |
| 49 | _exit(0); | ||
| 49 | 50 | ||
| 50 | default: /* this is the code the parent runs */ | 51 | default: /* this is the code the parent runs */ |
| 51 | 52 | ||
| 52 | close(0); /* close stdin */ | 53 | close(0); /* close stdin */ |
| 53 | /* Set file descriptor 0 (stdin) to read from the pipe */ | 54 | /* Set file descriptor 0 (stdin) to read from the pipe */ |
| 54 | dup (pipefd[0]); | 55 | dup(pipefd[0]); |
| 55 | /* the parent isn't going to write to the pipe */ | 56 | /* the parent isn't going to write to the pipe */ |
| 56 | close (pipefd[1]); | 57 | close(pipefd[1]); |
| 57 | /* Now read from the pipe */ | 58 | /* Now read from the pipe */ |
| 58 | fgets(str, 1023, stdin); | 59 | fgets(str, 1023, stdin); |
| 59 | /*printf("1st line output is %s\n", str);*/ | 60 | /*printf("1st line output is %s\n", str);*/ |
| 60 | 61 | ||
| 61 | /*while (!childtermd);*/ /* Uncomment this line to fix */ | 62 | /*while (!childtermd);*/ /* Uncomment this line to fix */ |
| 62 | 63 | ||
| 63 | died= wait(&status); | 64 | died = wait(&status); |
| 64 | /*printf("died=%d status=%d\n", died, status);*/ | 65 | /*printf("died=%d status=%d\n", died, status);*/ |
| 65 | if (died > 0) _exit(0); | 66 | if (died > 0) { |
| 66 | else _exit(1); | 67 | _exit(0); |
| 67 | } | 68 | } else { |
| 69 | _exit(1); | ||
| 70 | } | ||
| 71 | } | ||
| 68 | } | 72 | } |
| 69 | 73 | ||
| 70 | void | 74 | void popen_sigchld_handler(int signo) { |
| 71 | popen_sigchld_handler (int signo) | 75 | if (signo == SIGCHLD) { |
| 72 | { | 76 | /*printf("Caught sigchld\n");*/ |
| 73 | if (signo == SIGCHLD) { | 77 | childtermd = 1; |
| 74 | /*printf("Caught sigchld\n");*/ | 78 | } |
| 75 | childtermd = 1; | ||
| 76 | } | ||
| 77 | } | 79 | } |
diff --git a/lib/output.h b/lib/output.h index b9cdb07d..37486925 100644 --- a/lib/output.h +++ b/lib/output.h | |||
| @@ -65,7 +65,7 @@ mp_output_detail_level mp_get_level_of_detail(void); | |||
| 65 | */ | 65 | */ |
| 66 | typedef struct mp_check mp_check; | 66 | typedef struct mp_check mp_check; |
| 67 | struct mp_check { | 67 | struct mp_check { |
| 68 | char *summary; // Overall summary, if not set a summary will be automatically generated | 68 | char *summary; // Overall summary, if not set a summary will be automatically generated |
| 69 | char *ok_summary; // (optional) Summary if the overall state is OK | 69 | char *ok_summary; // (optional) Summary if the overall state is OK |
| 70 | mp_subcheck_list *subchecks; | 70 | mp_subcheck_list *subchecks; |
| 71 | 71 | ||
diff --git a/lib/parse_ini.c b/lib/parse_ini.c index 8a54af58..98207051 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c | |||
| @@ -130,7 +130,8 @@ np_arg_list *np_get_defaults(const char *locator, const char *default_section) { | |||
| 130 | 130 | ||
| 131 | np_arg_list *defaults = NULL; | 131 | np_arg_list *defaults = NULL; |
| 132 | if (!read_defaults(inifile, ini_info.stanza, &defaults)) { | 132 | if (!read_defaults(inifile, ini_info.stanza, &defaults)) { |
| 133 | die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), ini_info.stanza, ini_info.file); | 133 | die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), ini_info.stanza, |
| 134 | ini_info.file); | ||
| 134 | } | 135 | } |
| 135 | 136 | ||
| 136 | if (ini_info.file_string_on_heap) { | 137 | if (ini_info.file_string_on_heap) { |
diff --git a/lib/perfdata.c b/lib/perfdata.c index e3710ec7..f57f7c06 100644 --- a/lib/perfdata.c +++ b/lib/perfdata.c | |||
| @@ -253,9 +253,9 @@ char *mp_range_to_string(const mp_range input) { | |||
| 253 | } else { | 253 | } else { |
| 254 | // check for zeroes, so we can use the short form | 254 | // check for zeroes, so we can use the short form |
| 255 | if ((input.start.type == PD_TYPE_NONE) || | 255 | if ((input.start.type == PD_TYPE_NONE) || |
| 256 | ((input.start.type == PD_TYPE_INT) && (input.start.pd_int == 0)) || | 256 | ((input.start.type == PD_TYPE_INT) && (input.start.pd_int == 0)) || |
| 257 | ((input.start.type == PD_TYPE_UINT) && (input.start.pd_uint == 0)) || | 257 | ((input.start.type == PD_TYPE_UINT) && (input.start.pd_uint == 0)) || |
| 258 | ((input.start.type == PD_TYPE_DOUBLE) && (input.start.pd_double == 0))){ | 258 | ((input.start.type == PD_TYPE_DOUBLE) && (input.start.pd_double == 0))) { |
| 259 | // nothing to do here | 259 | // nothing to do here |
| 260 | } else { | 260 | } else { |
| 261 | // Start value is an actual value | 261 | // Start value is an actual value |
diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h index 04a624b8..e4869ce8 100644 --- a/lib/utils_cmd.h +++ b/lib/utils_cmd.h | |||
| @@ -22,13 +22,13 @@ int cmd_run_array(char *const *, output *, output *, int); | |||
| 22 | int cmd_file_read(const char *, output *, int); | 22 | int cmd_file_read(const char *, output *, int); |
| 23 | 23 | ||
| 24 | typedef struct { | 24 | typedef struct { |
| 25 | int error_code; | 25 | int error_code; |
| 26 | int cmd_error_code; | 26 | int cmd_error_code; |
| 27 | output out; | 27 | output out; |
| 28 | output err; | 28 | output err; |
| 29 | } cmd_run_result; | 29 | } cmd_run_result; |
| 30 | cmd_run_result cmd_run2(const char *cmd, int flags); | 30 | cmd_run_result cmd_run2(const char *cmd, int flags); |
| 31 | cmd_run_result cmd_run_array2(char * const *cmd, int flags); | 31 | cmd_run_result cmd_run_array2(char *const *cmd, int flags); |
| 32 | 32 | ||
| 33 | /* only multi-threaded plugins need to bother with this */ | 33 | /* only multi-threaded plugins need to bother with this */ |
| 34 | void cmd_init(void); | 34 | void cmd_init(void); |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 4d0c8e7d..178908cf 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
| @@ -100,8 +100,7 @@ int main(int argc, char **argv) { | |||
| 100 | if (child_result.cmd_error_code == 255 && config.unknown_timeout) { | 100 | if (child_result.cmd_error_code == 255 && config.unknown_timeout) { |
| 101 | mp_subcheck sc_ssh_execution = mp_subcheck_init(); | 101 | mp_subcheck sc_ssh_execution = mp_subcheck_init(); |
| 102 | xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s", | 102 | xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s", |
| 103 | child_result.err.lines > 0 ? child_result.err.line[0] | 103 | child_result.err.lines > 0 ? child_result.err.line[0] : "(no error output)"); |
| 104 | : "(no error output)"); | ||
| 105 | 104 | ||
| 106 | sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); | 105 | sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN); |
| 107 | mp_add_subcheck_to_check(&overall, sc_ssh_execution); | 106 | mp_add_subcheck_to_check(&overall, sc_ssh_execution); |
diff --git a/plugins/check_curl.d/check_curl_helpers.c b/plugins/check_curl.d/check_curl_helpers.c index 5b13a138..4edd0bbf 100644 --- a/plugins/check_curl.d/check_curl_helpers.c +++ b/plugins/check_curl.d/check_curl_helpers.c | |||
| @@ -222,7 +222,7 @@ check_curl_configure_curl(const check_curl_static_curl_config config, | |||
| 222 | 222 | ||
| 223 | bool have_local_resolution = hostname_gets_resolved_locally(working_state); | 223 | bool have_local_resolution = hostname_gets_resolved_locally(working_state); |
| 224 | if (verbose >= 1) { | 224 | if (verbose >= 1) { |
| 225 | printf("* have local name resolution: %s\n", (have_local_resolution ? "true": "false")); | 225 | printf("* have local name resolution: %s\n", (have_local_resolution ? "true" : "false")); |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | /* enable haproxy protocol */ | 228 | /* enable haproxy protocol */ |
diff --git a/plugins/check_curl.d/config.h b/plugins/check_curl.d/config.h index 0a7fa01d..2ff486c9 100644 --- a/plugins/check_curl.d/config.h +++ b/plugins/check_curl.d/config.h | |||
| @@ -118,7 +118,6 @@ typedef struct { | |||
| 118 | bool show_extended_perfdata; | 118 | bool show_extended_perfdata; |
| 119 | bool show_body; | 119 | bool show_body; |
| 120 | 120 | ||
| 121 | |||
| 122 | bool output_format_is_set; | 121 | bool output_format_is_set; |
| 123 | mp_output_format output_format; | 122 | mp_output_format output_format; |
| 124 | } check_curl_config; | 123 | } check_curl_config; |
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 43731039..e6b29f1c 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c | |||
| @@ -118,7 +118,8 @@ typedef struct { | |||
| 118 | static struct { | 118 | static struct { |
| 119 | uint8_t value; | 119 | uint8_t value; |
| 120 | char *text; | 120 | char *text; |
| 121 | } offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"}, {0x05, "Aborted"}, {0x06, "Failed"}, {0, 0}}; | 121 | } offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"}, |
| 122 | {0x05, "Aborted"}, {0x06, "Failed"}, {0, 0}}; | ||
| 122 | 123 | ||
| 123 | static struct { | 124 | static struct { |
| 124 | uint8_t value; | 125 | uint8_t value; |
| @@ -141,7 +142,8 @@ static int smart_read_values(int /*fd*/, smart_values * /*values*/); | |||
| 141 | static mp_state_enum compare_values_and_thresholds(smart_values * /*p*/, smart_thresholds * /*t*/); | 142 | static mp_state_enum compare_values_and_thresholds(smart_values * /*p*/, smart_thresholds * /*t*/); |
| 142 | static void print_value(smart_value * /*p*/, smart_threshold * /*t*/); | 143 | static void print_value(smart_value * /*p*/, smart_threshold * /*t*/); |
| 143 | static void print_values(smart_values * /*p*/, smart_thresholds * /*t*/); | 144 | static void print_values(smart_values * /*p*/, smart_thresholds * /*t*/); |
| 144 | static mp_state_enum smart_cmd_simple(int /*fd*/, enum SmartCommand /*command*/, uint8_t /*val0*/, bool /*show_error*/); | 145 | static mp_state_enum smart_cmd_simple(int /*fd*/, enum SmartCommand /*command*/, uint8_t /*val0*/, |
| 146 | bool /*show_error*/); | ||
| 145 | static int smart_read_thresholds(int /*fd*/, smart_thresholds * /*thresholds*/); | 147 | static int smart_read_thresholds(int /*fd*/, smart_thresholds * /*thresholds*/); |
| 146 | static int verbose = 0; | 148 | static int verbose = 0; |
| 147 | 149 | ||
| @@ -150,15 +152,16 @@ typedef struct { | |||
| 150 | check_ide_smart_config config; | 152 | check_ide_smart_config config; |
| 151 | } check_ide_smart_config_wrapper; | 153 | } check_ide_smart_config_wrapper; |
| 152 | static check_ide_smart_config_wrapper process_arguments(int argc, char **argv) { | 154 | static check_ide_smart_config_wrapper process_arguments(int argc, char **argv) { |
| 153 | static struct option longopts[] = {{"device", required_argument, 0, 'd'}, | 155 | static struct option longopts[] = { |
| 154 | {"immediate", no_argument, 0, 'i'}, | 156 | {"device", required_argument, 0, 'd'}, |
| 155 | {"quiet-check", no_argument, 0, 'q'}, | 157 | {"immediate", no_argument, 0, 'i'}, |
| 156 | {"auto-on", no_argument, 0, '1'}, | 158 | {"quiet-check", no_argument, 0, 'q'}, |
| 157 | {"auto-off", no_argument, 0, '0'}, | 159 | {"auto-on", no_argument, 0, '1'}, |
| 158 | {"nagios", no_argument, 0, 'n'}, /* DEPRECATED, but we still accept it */ | 160 | {"auto-off", no_argument, 0, '0'}, |
| 159 | {"help", no_argument, 0, 'h'}, | 161 | {"nagios", no_argument, 0, 'n'}, /* DEPRECATED, but we still accept it */ |
| 160 | {"version", no_argument, 0, 'V'}, | 162 | {"help", no_argument, 0, 'h'}, |
| 161 | {0, 0, 0, 0}}; | 163 | {"version", no_argument, 0, 'V'}, |
| 164 | {0, 0, 0, 0}}; | ||
| 162 | 165 | ||
| 163 | check_ide_smart_config_wrapper result = { | 166 | check_ide_smart_config_wrapper result = { |
| 164 | .errorcode = OK, | 167 | .errorcode = OK, |
| @@ -178,18 +181,21 @@ static check_ide_smart_config_wrapper process_arguments(int argc, char **argv) { | |||
| 178 | result.config.device = optarg; | 181 | result.config.device = optarg; |
| 179 | break; | 182 | break; |
| 180 | case 'q': | 183 | case 'q': |
| 181 | fprintf(stderr, "%s\n", _("DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\".")); | 184 | fprintf(stderr, "%s\n", |
| 185 | _("DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\".")); | ||
| 182 | fprintf(stderr, "%s\n", _("Nagios-compatible output is now always returned.")); | 186 | fprintf(stderr, "%s\n", _("Nagios-compatible output is now always returned.")); |
| 183 | break; | 187 | break; |
| 184 | case 'i': | 188 | case 'i': |
| 185 | case '1': | 189 | case '1': |
| 186 | case '0': | 190 | case '0': |
| 187 | printf("%s\n", _("SMART commands are broken and have been disabled (See Notes in --help).")); | 191 | printf("%s\n", |
| 192 | _("SMART commands are broken and have been disabled (See Notes in --help).")); | ||
| 188 | result.errorcode = ERROR; | 193 | result.errorcode = ERROR; |
| 189 | return result; | 194 | return result; |
| 190 | break; | 195 | break; |
| 191 | case 'n': | 196 | case 'n': |
| 192 | fprintf(stderr, "%s\n", _("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the")); | 197 | fprintf(stderr, "%s\n", |
| 198 | _("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the")); | ||
| 193 | fprintf(stderr, "%s\n", _("default and will be removed from future releases.")); | 199 | fprintf(stderr, "%s\n", _("default and will be removed from future releases.")); |
| 194 | break; | 200 | break; |
| 195 | case 'v': /* verbose */ | 201 | case 'v': /* verbose */ |
| @@ -348,12 +354,13 @@ mp_state_enum compare_values_and_thresholds(smart_values *values, smart_threshol | |||
| 348 | 354 | ||
| 349 | switch (status) { | 355 | switch (status) { |
| 350 | case PREFAILURE: | 356 | case PREFAILURE: |
| 351 | printf(_("CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"), prefailure, prefailure > 1 ? 's' : ' ', failed, | 357 | printf(_("CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"), prefailure, |
| 352 | total); | 358 | prefailure > 1 ? 's' : ' ', failed, total); |
| 353 | status = STATE_CRITICAL; | 359 | status = STATE_CRITICAL; |
| 354 | break; | 360 | break; |
| 355 | case ADVISORY: | 361 | case ADVISORY: |
| 356 | printf(_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"), advisory, advisory > 1 ? "ies" : "y", failed, total); | 362 | printf(_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"), advisory, |
| 363 | advisory > 1 ? "ies" : "y", failed, total); | ||
| 357 | status = STATE_WARNING; | 364 | status = STATE_WARNING; |
| 358 | break; | 365 | break; |
| 359 | case OPERATIONAL: | 366 | case OPERATIONAL: |
| @@ -369,9 +376,11 @@ mp_state_enum compare_values_and_thresholds(smart_values *values, smart_threshol | |||
| 369 | } | 376 | } |
| 370 | 377 | ||
| 371 | void print_value(smart_value *value_pointer, smart_threshold *threshold_pointer) { | 378 | void print_value(smart_value *value_pointer, smart_threshold *threshold_pointer) { |
| 372 | printf("Id=%3d, Status=%2d {%s , %s}, Value=%3d, Threshold=%3d, %s\n", value_pointer->id, value_pointer->status, | 379 | printf("Id=%3d, Status=%2d {%s , %s}, Value=%3d, Threshold=%3d, %s\n", value_pointer->id, |
| 373 | value_pointer->status & 1 ? "PreFailure" : "Advisory ", value_pointer->status & 2 ? "OnLine " : "OffLine", | 380 | value_pointer->status, value_pointer->status & 1 ? "PreFailure" : "Advisory ", |
| 374 | value_pointer->value, threshold_pointer->threshold, value_pointer->value >= threshold_pointer->threshold ? "Passed" : "Failed"); | 381 | value_pointer->status & 2 ? "OnLine " : "OffLine", value_pointer->value, |
| 382 | threshold_pointer->threshold, | ||
| 383 | value_pointer->value >= threshold_pointer->threshold ? "Passed" : "Failed"); | ||
| 375 | } | 384 | } |
| 376 | 385 | ||
| 377 | void print_values(smart_values *values, smart_thresholds *thresholds) { | 386 | void print_values(smart_values *values, smart_thresholds *thresholds) { |
| @@ -382,15 +391,21 @@ void print_values(smart_values *values, smart_thresholds *thresholds) { | |||
| 382 | print_value(value++, threshold++); | 391 | print_value(value++, threshold++); |
| 383 | } | 392 | } |
| 384 | } | 393 | } |
| 385 | printf(_("OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"), values->offline_status, | 394 | printf(_("OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"), |
| 386 | get_offline_text(values->offline_status & 0x7f), (values->offline_status & 0x80 ? "Yes" : "No"), values->offline_timeout / 60); | 395 | values->offline_status, get_offline_text(values->offline_status & 0x7f), |
| 387 | printf(_("OffLineCapability=%d {%s %s %s}\n"), values->offline_capability, values->offline_capability & 1 ? "Immediate" : "", | 396 | (values->offline_status & 0x80 ? "Yes" : "No"), values->offline_timeout / 60); |
| 388 | values->offline_capability & 2 ? "Auto" : "", values->offline_capability & 4 ? "AbortOnCmd" : "SuspendOnCmd"); | 397 | printf(_("OffLineCapability=%d {%s %s %s}\n"), values->offline_capability, |
| 389 | printf(_("SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"), values->revision, values->checksum, values->smart_capability, | 398 | values->offline_capability & 1 ? "Immediate" : "", |
| 390 | values->smart_capability & 1 ? "SaveOnStandBy" : "", values->smart_capability & 2 ? "AutoSave" : ""); | 399 | values->offline_capability & 2 ? "Auto" : "", |
| 400 | values->offline_capability & 4 ? "AbortOnCmd" : "SuspendOnCmd"); | ||
| 401 | printf(_("SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"), values->revision, | ||
| 402 | values->checksum, values->smart_capability, | ||
| 403 | values->smart_capability & 1 ? "SaveOnStandBy" : "", | ||
| 404 | values->smart_capability & 2 ? "AutoSave" : ""); | ||
| 391 | } | 405 | } |
| 392 | 406 | ||
| 393 | mp_state_enum smart_cmd_simple(int file_descriptor, enum SmartCommand command, uint8_t val0, bool show_error) { | 407 | mp_state_enum smart_cmd_simple(int file_descriptor, enum SmartCommand command, uint8_t val0, |
| 408 | bool show_error) { | ||
| 394 | mp_state_enum result = STATE_UNKNOWN; | 409 | mp_state_enum result = STATE_UNKNOWN; |
| 395 | #ifdef __linux__ | 410 | #ifdef __linux__ |
| 396 | uint8_t args[4] = { | 411 | uint8_t args[4] = { |
| @@ -517,15 +532,18 @@ void print_help(void) { | |||
| 517 | 532 | ||
| 518 | printf(" %s\n", "-d, --device=DEVICE"); | 533 | printf(" %s\n", "-d, --device=DEVICE"); |
| 519 | printf(" %s\n", _("Select device DEVICE")); | 534 | printf(" %s\n", _("Select device DEVICE")); |
| 520 | printf(" %s\n", _("Note: if the device is specified without this option, any further option will")); | 535 | printf(" %s\n", |
| 536 | _("Note: if the device is specified without this option, any further option will")); | ||
| 521 | printf(" %s\n", _("be ignored.")); | 537 | printf(" %s\n", _("be ignored.")); |
| 522 | 538 | ||
| 523 | printf(UT_VERBOSE); | 539 | printf(UT_VERBOSE); |
| 524 | 540 | ||
| 525 | printf("\n"); | 541 | printf("\n"); |
| 526 | printf("%s\n", _("Notes:")); | 542 | printf("%s\n", _("Notes:")); |
| 527 | printf(" %s\n", _("The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were")); | 543 | printf(" %s\n", |
| 528 | printf(" %s\n", _("broken in an underhand manner and have been disabled. You can use smartctl")); | 544 | _("The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were")); |
| 545 | printf(" %s\n", | ||
| 546 | _("broken in an underhand manner and have been disabled. You can use smartctl")); | ||
| 529 | printf(" %s\n", _("instead:")); | 547 | printf(" %s\n", _("instead:")); |
| 530 | printf(" %s\n", _("-0/--auto-off: use \"smartctl --offlineauto=off\"")); | 548 | printf(" %s\n", _("-0/--auto-off: use \"smartctl --offlineauto=off\"")); |
| 531 | printf(" %s\n", _("-1/--auto-on: use \"smartctl --offlineauto=on\"")); | 549 | printf(" %s\n", _("-1/--auto-on: use \"smartctl --offlineauto=on\"")); |
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index e2f230c9..84506bb4 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c | |||
| @@ -79,7 +79,8 @@ int main(int argc, char **argv) { | |||
| 79 | /* open the status log */ | 79 | /* open the status log */ |
| 80 | FILE *log_file = fopen(config.status_log, "r"); | 80 | FILE *log_file = fopen(config.status_log, "r"); |
| 81 | if (log_file == NULL) { | 81 | if (log_file == NULL) { |
| 82 | die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), _("Cannot open status log for reading!")); | 82 | die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), |
| 83 | _("Cannot open status log for reading!")); | ||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | unsigned long latest_entry_time = 0L; | 86 | unsigned long latest_entry_time = 0L; |
| @@ -153,7 +154,8 @@ int main(int argc, char **argv) { | |||
| 153 | } | 154 | } |
| 154 | 155 | ||
| 155 | /* May get empty procargs */ | 156 | /* May get empty procargs */ |
| 156 | if (!strstr(procargs, argv[0]) && strstr(procargs, config.process_string) && strcmp(procargs, "")) { | 157 | if (!strstr(procargs, argv[0]) && strstr(procargs, config.process_string) && |
| 158 | strcmp(procargs, "")) { | ||
| 157 | proc_entries++; | 159 | proc_entries++; |
| 158 | if (verbose >= 2) { | 160 | if (verbose >= 2) { |
| 159 | printf(_("Found process: %s %s\n"), procprog, procargs); | 161 | printf(_("Found process: %s %s\n"), procprog, procargs); |
| @@ -171,11 +173,13 @@ int main(int argc, char **argv) { | |||
| 171 | alarm(0); | 173 | alarm(0); |
| 172 | 174 | ||
| 173 | if (proc_entries == 0) { | 175 | if (proc_entries == 0) { |
| 174 | die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), _("Could not locate a running Nagios process!")); | 176 | die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), |
| 177 | _("Could not locate a running Nagios process!")); | ||
| 175 | } | 178 | } |
| 176 | 179 | ||
| 177 | if (latest_entry_time == 0L) { | 180 | if (latest_entry_time == 0L) { |
| 178 | die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), _("Cannot parse Nagios log file for valid time")); | 181 | die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), |
| 182 | _("Cannot parse Nagios log file for valid time")); | ||
| 179 | } | 183 | } |
| 180 | 184 | ||
| 181 | time_t current_time; | 185 | time_t current_time; |
| @@ -189,7 +193,8 @@ int main(int argc, char **argv) { | |||
| 189 | printf("NAGIOS %s: ", (result == STATE_OK) ? _("OK") : _("WARNING")); | 193 | printf("NAGIOS %s: ", (result == STATE_OK) ? _("OK") : _("WARNING")); |
| 190 | printf(ngettext("%d process", "%d processes", proc_entries), proc_entries); | 194 | printf(ngettext("%d process", "%d processes", proc_entries), proc_entries); |
| 191 | printf(", "); | 195 | printf(", "); |
| 192 | printf(ngettext("status log updated %d second ago", "status log updated %d seconds ago", (int)(current_time - latest_entry_time)), | 196 | printf(ngettext("status log updated %d second ago", "status log updated %d seconds ago", |
| 197 | (int)(current_time - latest_entry_time)), | ||
| 193 | (int)(current_time - latest_entry_time)); | 198 | (int)(current_time - latest_entry_time)); |
| 194 | printf("\n"); | 199 | printf("\n"); |
| 195 | 200 | ||
| @@ -198,10 +203,11 @@ int main(int argc, char **argv) { | |||
| 198 | 203 | ||
| 199 | /* process command-line arguments */ | 204 | /* process command-line arguments */ |
| 200 | check_nagios_config_wrapper process_arguments(int argc, char **argv) { | 205 | check_nagios_config_wrapper process_arguments(int argc, char **argv) { |
| 201 | static struct option longopts[] = {{"filename", required_argument, 0, 'F'}, {"expires", required_argument, 0, 'e'}, | 206 | static struct option longopts[] = { |
| 202 | {"command", required_argument, 0, 'C'}, {"timeout", optional_argument, 0, 't'}, | 207 | {"filename", required_argument, 0, 'F'}, {"expires", required_argument, 0, 'e'}, |
| 203 | {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, | 208 | {"command", required_argument, 0, 'C'}, {"timeout", optional_argument, 0, 't'}, |
| 204 | {"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0}}; | 209 | {"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'}, |
| 210 | {"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0}}; | ||
| 205 | 211 | ||
| 206 | check_nagios_config_wrapper result = { | 212 | check_nagios_config_wrapper result = { |
| 207 | .errorcode = OK, | 213 | .errorcode = OK, |
| @@ -285,7 +291,8 @@ void print_help(void) { | |||
| 285 | printf("%s\n", _("This plugin checks the status of the Nagios process on the local machine")); | 291 | printf("%s\n", _("This plugin checks the status of the Nagios process on the local machine")); |
| 286 | printf("%s\n", _("The plugin will check to make sure the Nagios status log is no older than")); | 292 | printf("%s\n", _("The plugin will check to make sure the Nagios status log is no older than")); |
| 287 | printf("%s\n", _("the number of minutes specified by the expires option.")); | 293 | printf("%s\n", _("the number of minutes specified by the expires option.")); |
| 288 | printf("%s\n", _("It also checks the process table for a process matching the command argument.")); | 294 | printf("%s\n", |
| 295 | _("It also checks the process table for a process matching the command argument.")); | ||
| 289 | 296 | ||
| 290 | printf("\n\n"); | 297 | printf("\n\n"); |
| 291 | 298 | ||
| @@ -306,12 +313,14 @@ void print_help(void) { | |||
| 306 | 313 | ||
| 307 | printf("\n"); | 314 | printf("\n"); |
| 308 | printf("%s\n", _("Examples:")); | 315 | printf("%s\n", _("Examples:")); |
| 309 | printf(" %s\n", "check_nagios -t 20 -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios"); | 316 | printf(" %s\n", "check_nagios -t 20 -e 5 -F /usr/local/nagios/var/status.log -C " |
| 317 | "/usr/local/nagios/bin/nagios"); | ||
| 310 | 318 | ||
| 311 | printf(UT_SUPPORT); | 319 | printf(UT_SUPPORT); |
| 312 | } | 320 | } |
| 313 | 321 | ||
| 314 | void print_usage(void) { | 322 | void print_usage(void) { |
| 315 | printf("%s\n", _("Usage:")); | 323 | printf("%s\n", _("Usage:")); |
| 316 | printf("%s -F <status log file> -t <timeout_seconds> -e <expire_minutes> -C <process_string>\n", progname); | 324 | printf("%s -F <status log file> -t <timeout_seconds> -e <expire_minutes> -C <process_string>\n", |
| 325 | progname); | ||
| 317 | } | 326 | } |
diff --git a/plugins/common.h b/plugins/common.h index 9d1434a3..577f70fe 100644 --- a/plugins/common.h +++ b/plugins/common.h | |||
| @@ -207,9 +207,9 @@ enum { | |||
| 207 | 207 | ||
| 208 | /* for checking the result of getopt_long */ | 208 | /* for checking the result of getopt_long */ |
| 209 | #if EOF == -1 | 209 | #if EOF == -1 |
| 210 | #define CHECK_EOF(c) ((c) == EOF) | 210 | # define CHECK_EOF(c) ((c) == EOF) |
| 211 | #else | 211 | #else |
| 212 | #define CHECK_EOF(c) ((c) == -1 || (c) == EOF) | 212 | # define CHECK_EOF(c) ((c) == -1 || (c) == EOF) |
| 213 | #endif | 213 | #endif |
| 214 | 214 | ||
| 215 | #endif /* _COMMON_H_ */ | 215 | #endif /* _COMMON_H_ */ |
diff --git a/plugins/netutils.h b/plugins/netutils.h index 16c2d31f..a74930b8 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h | |||
| @@ -78,8 +78,8 @@ bool dns_lookup(const char *, struct sockaddr_storage *, int); | |||
| 78 | void host_or_die(const char *str); | 78 | void host_or_die(const char *str); |
| 79 | #define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family) | 79 | #define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family) |
| 80 | #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) | 80 | #define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET) |
| 81 | # define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) | 81 | #define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6) |
| 82 | # define is_hostname(addr) resolve_host_or_addr(addr, address_family) | 82 | #define is_hostname(addr) resolve_host_or_addr(addr, address_family) |
| 83 | 83 | ||
| 84 | extern unsigned int socket_timeout; | 84 | extern unsigned int socket_timeout; |
| 85 | extern mp_state_enum socket_timeout_state; | 85 | extern mp_state_enum socket_timeout_state; |
| @@ -128,7 +128,8 @@ typedef struct { | |||
| 128 | double remaining_seconds; | 128 | double remaining_seconds; |
| 129 | retrieve_expiration_date_errors errors; | 129 | retrieve_expiration_date_errors errors; |
| 130 | } net_ssl_check_cert_result; | 130 | } net_ssl_check_cert_result; |
| 131 | net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn, unsigned int days_till_exp_crit); | 131 | net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn, |
| 132 | unsigned int days_till_exp_crit); | ||
| 132 | 133 | ||
| 133 | mp_state_enum np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit); | 134 | mp_state_enum np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit); |
| 134 | mp_subcheck mp_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit); | 135 | mp_subcheck mp_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit); |
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index bcfb08d6..9151f722 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
| @@ -410,7 +410,8 @@ retrieve_expiration_time_result np_net_ssl_get_cert_expiration(X509 *certificate | |||
| 410 | # endif /* MOPL_USE_OPENSSL */ | 410 | # endif /* MOPL_USE_OPENSSL */ |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn, unsigned int days_till_exp_crit) { | 413 | net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn, |
| 414 | unsigned int days_till_exp_crit) { | ||
| 414 | # ifdef MOPL_USE_OPENSSL | 415 | # ifdef MOPL_USE_OPENSSL |
| 415 | X509 *certificate = NULL; | 416 | X509 *certificate = NULL; |
| 416 | certificate = SSL_get_peer_certificate(s); | 417 | certificate = SSL_get_peer_certificate(s); |
diff --git a/plugins/utils.c b/plugins/utils.c index dc6f5a85..941efa39 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
| @@ -40,7 +40,6 @@ extern const char *progname; | |||
| 40 | #define STRLEN 64 | 40 | #define STRLEN 64 |
| 41 | #define TXTBLK 128 | 41 | #define TXTBLK 128 |
| 42 | 42 | ||
| 43 | |||
| 44 | void usage(const char *msg) { | 43 | void usage(const char *msg) { |
| 45 | printf("%s\n", msg); | 44 | printf("%s\n", msg); |
| 46 | print_usage(); | 45 | print_usage(); |
