mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-06-11 01:30:00 -04:00
Run clang-format on everything once again (#2275)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
Co-authored-by: Lorenz Kästle <lorenz.kaestle@netways.de>
This commit is contained in:
parent
47b1b2d754
commit
f8aad020f7
14 changed files with 149 additions and 120 deletions
|
|
@ -5,73 +5,75 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
void popen_sigchld_handler (int);
|
||||
void popen_sigchld_handler(int);
|
||||
int childtermd;
|
||||
|
||||
int main(){
|
||||
char str[1024];
|
||||
int pipefd[2];
|
||||
pid_t pid;
|
||||
int status, died;
|
||||
int main() {
|
||||
char str[1024];
|
||||
int pipefd[2];
|
||||
pid_t pid;
|
||||
int status, died;
|
||||
|
||||
if (signal (SIGCHLD, popen_sigchld_handler) == SIG_ERR) {
|
||||
printf ("Cannot catch SIGCHLD\n");
|
||||
if (signal(SIGCHLD, popen_sigchld_handler) == SIG_ERR) {
|
||||
printf("Cannot catch SIGCHLD\n");
|
||||
_exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
pipe (pipefd);
|
||||
switch(pid=fork()){
|
||||
case -1:
|
||||
printf("can't fork\n");
|
||||
_exit(-1);
|
||||
|
||||
case 0 : /* this is the code the child runs */
|
||||
close(1); /* close stdout */
|
||||
/* pipefd[1] is for writing to the pipe. We want the output
|
||||
* that used to go to the standard output (file descriptor 1)
|
||||
* to be written to the pipe. The following command does this,
|
||||
* creating a new file descriptor 1 (the lowest available)
|
||||
* that writes where pipefd[1] goes. */
|
||||
dup (pipefd[1]); /* points pipefd at file descriptor */
|
||||
/* the child isn't going to read from the pipe, so
|
||||
* pipefd[0] can be closed */
|
||||
close (pipefd[0]);
|
||||
pipe(pipefd);
|
||||
switch (pid = fork()) {
|
||||
case -1:
|
||||
printf("can't fork\n");
|
||||
_exit(-1);
|
||||
|
||||
/* These are the commands to run, with success commented. dig and nslookup only problems */
|
||||
/*execl ("/bin/date","date",0);*/ /* 100% */
|
||||
/*execl ("/bin/cat", "cat", "/etc/hosts", 0);*/ /* 100% */
|
||||
/*execl ("/usr/bin/dig", "dig", "redhat.com", 0);*/ /* 69% */
|
||||
/*execl("/bin/sleep", "sleep", "1", 0);*/ /* 100% */
|
||||
execl ("/usr/bin/nslookup","nslookup","redhat.com",0); /* 90% (after 100 tests), 40% (after 10 tests) */
|
||||
/*execl ("/bin/ping","ping","-c","1","localhost",0);*/ /* 100% */
|
||||
/*execl ("/bin/ping","ping","-c","1","192.168.10.32",0);*/ /* 100% */
|
||||
_exit(0);
|
||||
case 0: /* this is the code the child runs */
|
||||
close(1); /* close stdout */
|
||||
/* pipefd[1] is for writing to the pipe. We want the output
|
||||
* that used to go to the standard output (file descriptor 1)
|
||||
* to be written to the pipe. The following command does this,
|
||||
* creating a new file descriptor 1 (the lowest available)
|
||||
* that writes where pipefd[1] goes. */
|
||||
dup(pipefd[1]); /* points pipefd at file descriptor */
|
||||
/* the child isn't going to read from the pipe, so
|
||||
* pipefd[0] can be closed */
|
||||
close(pipefd[0]);
|
||||
|
||||
default: /* this is the code the parent runs */
|
||||
/* These are the commands to run, with success commented. dig and nslookup only problems */
|
||||
/*execl ("/bin/date","date",0);*/ /* 100% */
|
||||
/*execl ("/bin/cat", "cat", "/etc/hosts", 0);*/ /* 100% */
|
||||
/*execl ("/usr/bin/dig", "dig", "redhat.com", 0);*/ /* 69% */
|
||||
/*execl("/bin/sleep", "sleep", "1", 0);*/ /* 100% */
|
||||
execl("/usr/bin/nslookup", "nslookup", "redhat.com",
|
||||
0); /* 90% (after 100 tests), 40% (after 10 tests) */
|
||||
/*execl ("/bin/ping","ping","-c","1","localhost",0);*/ /* 100% */
|
||||
/*execl ("/bin/ping","ping","-c","1","192.168.10.32",0);*/ /* 100% */
|
||||
_exit(0);
|
||||
|
||||
close(0); /* close stdin */
|
||||
/* Set file descriptor 0 (stdin) to read from the pipe */
|
||||
dup (pipefd[0]);
|
||||
/* the parent isn't going to write to the pipe */
|
||||
close (pipefd[1]);
|
||||
/* Now read from the pipe */
|
||||
fgets(str, 1023, stdin);
|
||||
/*printf("1st line output is %s\n", str);*/
|
||||
default: /* this is the code the parent runs */
|
||||
|
||||
/*while (!childtermd);*/ /* Uncomment this line to fix */
|
||||
close(0); /* close stdin */
|
||||
/* Set file descriptor 0 (stdin) to read from the pipe */
|
||||
dup(pipefd[0]);
|
||||
/* the parent isn't going to write to the pipe */
|
||||
close(pipefd[1]);
|
||||
/* Now read from the pipe */
|
||||
fgets(str, 1023, stdin);
|
||||
/*printf("1st line output is %s\n", str);*/
|
||||
|
||||
died= wait(&status);
|
||||
/*printf("died=%d status=%d\n", died, status);*/
|
||||
if (died > 0) _exit(0);
|
||||
else _exit(1);
|
||||
}
|
||||
/*while (!childtermd);*/ /* Uncomment this line to fix */
|
||||
|
||||
died = wait(&status);
|
||||
/*printf("died=%d status=%d\n", died, status);*/
|
||||
if (died > 0) {
|
||||
_exit(0);
|
||||
} else {
|
||||
_exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
popen_sigchld_handler (int signo)
|
||||
{
|
||||
if (signo == SIGCHLD) {
|
||||
/*printf("Caught sigchld\n");*/
|
||||
childtermd = 1;
|
||||
}
|
||||
void popen_sigchld_handler(int signo) {
|
||||
if (signo == SIGCHLD) {
|
||||
/*printf("Caught sigchld\n");*/
|
||||
childtermd = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ mp_output_detail_level mp_get_level_of_detail(void);
|
|||
*/
|
||||
typedef struct mp_check mp_check;
|
||||
struct mp_check {
|
||||
char *summary; // Overall summary, if not set a summary will be automatically generated
|
||||
char *summary; // Overall summary, if not set a summary will be automatically generated
|
||||
char *ok_summary; // (optional) Summary if the overall state is OK
|
||||
mp_subcheck_list *subchecks;
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ np_arg_list *np_get_defaults(const char *locator, const char *default_section) {
|
|||
|
||||
np_arg_list *defaults = NULL;
|
||||
if (!read_defaults(inifile, ini_info.stanza, &defaults)) {
|
||||
die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), ini_info.stanza, ini_info.file);
|
||||
die(STATE_UNKNOWN, _("Invalid section '%s' in config file '%s'\n"), ini_info.stanza,
|
||||
ini_info.file);
|
||||
}
|
||||
|
||||
if (ini_info.file_string_on_heap) {
|
||||
|
|
|
|||
|
|
@ -253,9 +253,9 @@ char *mp_range_to_string(const mp_range input) {
|
|||
} else {
|
||||
// check for zeroes, so we can use the short form
|
||||
if ((input.start.type == PD_TYPE_NONE) ||
|
||||
((input.start.type == PD_TYPE_INT) && (input.start.pd_int == 0)) ||
|
||||
((input.start.type == PD_TYPE_UINT) && (input.start.pd_uint == 0)) ||
|
||||
((input.start.type == PD_TYPE_DOUBLE) && (input.start.pd_double == 0))){
|
||||
((input.start.type == PD_TYPE_INT) && (input.start.pd_int == 0)) ||
|
||||
((input.start.type == PD_TYPE_UINT) && (input.start.pd_uint == 0)) ||
|
||||
((input.start.type == PD_TYPE_DOUBLE) && (input.start.pd_double == 0))) {
|
||||
// nothing to do here
|
||||
} else {
|
||||
// Start value is an actual value
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ int cmd_run_array(char *const *, output *, output *, int);
|
|||
int cmd_file_read(const char *, output *, int);
|
||||
|
||||
typedef struct {
|
||||
int error_code;
|
||||
int cmd_error_code;
|
||||
output out;
|
||||
output err;
|
||||
int error_code;
|
||||
int cmd_error_code;
|
||||
output out;
|
||||
output err;
|
||||
} cmd_run_result;
|
||||
cmd_run_result cmd_run2(const char *cmd, int flags);
|
||||
cmd_run_result cmd_run_array2(char * const *cmd, int flags);
|
||||
cmd_run_result cmd_run_array2(char *const *cmd, int flags);
|
||||
|
||||
/* only multi-threaded plugins need to bother with this */
|
||||
void cmd_init(void);
|
||||
|
|
|
|||
|
|
@ -100,8 +100,7 @@ int main(int argc, char **argv) {
|
|||
if (child_result.cmd_error_code == 255 && config.unknown_timeout) {
|
||||
mp_subcheck sc_ssh_execution = mp_subcheck_init();
|
||||
xasprintf(&sc_ssh_execution.output, "SSH connection failed: %s",
|
||||
child_result.err.lines > 0 ? child_result.err.line[0]
|
||||
: "(no error output)");
|
||||
child_result.err.lines > 0 ? child_result.err.line[0] : "(no error output)");
|
||||
|
||||
sc_ssh_execution = mp_set_subcheck_state(sc_ssh_execution, STATE_UNKNOWN);
|
||||
mp_add_subcheck_to_check(&overall, sc_ssh_execution);
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ check_curl_configure_curl(const check_curl_static_curl_config config,
|
|||
|
||||
bool have_local_resolution = hostname_gets_resolved_locally(working_state);
|
||||
if (verbose >= 1) {
|
||||
printf("* have local name resolution: %s\n", (have_local_resolution ? "true": "false"));
|
||||
printf("* have local name resolution: %s\n", (have_local_resolution ? "true" : "false"));
|
||||
}
|
||||
|
||||
/* enable haproxy protocol */
|
||||
|
|
|
|||
|
|
@ -118,7 +118,6 @@ typedef struct {
|
|||
bool show_extended_perfdata;
|
||||
bool show_body;
|
||||
|
||||
|
||||
bool output_format_is_set;
|
||||
mp_output_format output_format;
|
||||
} check_curl_config;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@ typedef struct {
|
|||
static struct {
|
||||
uint8_t value;
|
||||
char *text;
|
||||
} offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"}, {0x05, "Aborted"}, {0x06, "Failed"}, {0, 0}};
|
||||
} offline_status_text[] = {{0x00, "NeverStarted"}, {0x02, "Completed"}, {0x04, "Suspended"},
|
||||
{0x05, "Aborted"}, {0x06, "Failed"}, {0, 0}};
|
||||
|
||||
static struct {
|
||||
uint8_t value;
|
||||
|
|
@ -141,7 +142,8 @@ static int smart_read_values(int /*fd*/, smart_values * /*values*/);
|
|||
static mp_state_enum compare_values_and_thresholds(smart_values * /*p*/, smart_thresholds * /*t*/);
|
||||
static void print_value(smart_value * /*p*/, smart_threshold * /*t*/);
|
||||
static void print_values(smart_values * /*p*/, smart_thresholds * /*t*/);
|
||||
static mp_state_enum smart_cmd_simple(int /*fd*/, enum SmartCommand /*command*/, uint8_t /*val0*/, bool /*show_error*/);
|
||||
static mp_state_enum smart_cmd_simple(int /*fd*/, enum SmartCommand /*command*/, uint8_t /*val0*/,
|
||||
bool /*show_error*/);
|
||||
static int smart_read_thresholds(int /*fd*/, smart_thresholds * /*thresholds*/);
|
||||
static int verbose = 0;
|
||||
|
||||
|
|
@ -150,15 +152,16 @@ typedef struct {
|
|||
check_ide_smart_config config;
|
||||
} check_ide_smart_config_wrapper;
|
||||
static check_ide_smart_config_wrapper process_arguments(int argc, char **argv) {
|
||||
static struct option longopts[] = {{"device", required_argument, 0, 'd'},
|
||||
{"immediate", no_argument, 0, 'i'},
|
||||
{"quiet-check", no_argument, 0, 'q'},
|
||||
{"auto-on", no_argument, 0, '1'},
|
||||
{"auto-off", no_argument, 0, '0'},
|
||||
{"nagios", no_argument, 0, 'n'}, /* DEPRECATED, but we still accept it */
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{0, 0, 0, 0}};
|
||||
static struct option longopts[] = {
|
||||
{"device", required_argument, 0, 'd'},
|
||||
{"immediate", no_argument, 0, 'i'},
|
||||
{"quiet-check", no_argument, 0, 'q'},
|
||||
{"auto-on", no_argument, 0, '1'},
|
||||
{"auto-off", no_argument, 0, '0'},
|
||||
{"nagios", no_argument, 0, 'n'}, /* DEPRECATED, but we still accept it */
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{0, 0, 0, 0}};
|
||||
|
||||
check_ide_smart_config_wrapper result = {
|
||||
.errorcode = OK,
|
||||
|
|
@ -178,18 +181,21 @@ static check_ide_smart_config_wrapper process_arguments(int argc, char **argv) {
|
|||
result.config.device = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
fprintf(stderr, "%s\n", _("DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."));
|
||||
fprintf(stderr, "%s\n",
|
||||
_("DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."));
|
||||
fprintf(stderr, "%s\n", _("Nagios-compatible output is now always returned."));
|
||||
break;
|
||||
case 'i':
|
||||
case '1':
|
||||
case '0':
|
||||
printf("%s\n", _("SMART commands are broken and have been disabled (See Notes in --help)."));
|
||||
printf("%s\n",
|
||||
_("SMART commands are broken and have been disabled (See Notes in --help)."));
|
||||
result.errorcode = ERROR;
|
||||
return result;
|
||||
break;
|
||||
case 'n':
|
||||
fprintf(stderr, "%s\n", _("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"));
|
||||
fprintf(stderr, "%s\n",
|
||||
_("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"));
|
||||
fprintf(stderr, "%s\n", _("default and will be removed from future releases."));
|
||||
break;
|
||||
case 'v': /* verbose */
|
||||
|
|
@ -348,12 +354,13 @@ mp_state_enum compare_values_and_thresholds(smart_values *values, smart_threshol
|
|||
|
||||
switch (status) {
|
||||
case PREFAILURE:
|
||||
printf(_("CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"), prefailure, prefailure > 1 ? 's' : ' ', failed,
|
||||
total);
|
||||
printf(_("CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"), prefailure,
|
||||
prefailure > 1 ? 's' : ' ', failed, total);
|
||||
status = STATE_CRITICAL;
|
||||
break;
|
||||
case ADVISORY:
|
||||
printf(_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"), advisory, advisory > 1 ? "ies" : "y", failed, total);
|
||||
printf(_("WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"), advisory,
|
||||
advisory > 1 ? "ies" : "y", failed, total);
|
||||
status = STATE_WARNING;
|
||||
break;
|
||||
case OPERATIONAL:
|
||||
|
|
@ -369,9 +376,11 @@ mp_state_enum compare_values_and_thresholds(smart_values *values, smart_threshol
|
|||
}
|
||||
|
||||
void print_value(smart_value *value_pointer, smart_threshold *threshold_pointer) {
|
||||
printf("Id=%3d, Status=%2d {%s , %s}, Value=%3d, Threshold=%3d, %s\n", value_pointer->id, value_pointer->status,
|
||||
value_pointer->status & 1 ? "PreFailure" : "Advisory ", value_pointer->status & 2 ? "OnLine " : "OffLine",
|
||||
value_pointer->value, threshold_pointer->threshold, value_pointer->value >= threshold_pointer->threshold ? "Passed" : "Failed");
|
||||
printf("Id=%3d, Status=%2d {%s , %s}, Value=%3d, Threshold=%3d, %s\n", value_pointer->id,
|
||||
value_pointer->status, value_pointer->status & 1 ? "PreFailure" : "Advisory ",
|
||||
value_pointer->status & 2 ? "OnLine " : "OffLine", value_pointer->value,
|
||||
threshold_pointer->threshold,
|
||||
value_pointer->value >= threshold_pointer->threshold ? "Passed" : "Failed");
|
||||
}
|
||||
|
||||
void print_values(smart_values *values, smart_thresholds *thresholds) {
|
||||
|
|
@ -382,15 +391,21 @@ void print_values(smart_values *values, smart_thresholds *thresholds) {
|
|||
print_value(value++, threshold++);
|
||||
}
|
||||
}
|
||||
printf(_("OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"), values->offline_status,
|
||||
get_offline_text(values->offline_status & 0x7f), (values->offline_status & 0x80 ? "Yes" : "No"), values->offline_timeout / 60);
|
||||
printf(_("OffLineCapability=%d {%s %s %s}\n"), values->offline_capability, values->offline_capability & 1 ? "Immediate" : "",
|
||||
values->offline_capability & 2 ? "Auto" : "", values->offline_capability & 4 ? "AbortOnCmd" : "SuspendOnCmd");
|
||||
printf(_("SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"), values->revision, values->checksum, values->smart_capability,
|
||||
values->smart_capability & 1 ? "SaveOnStandBy" : "", values->smart_capability & 2 ? "AutoSave" : "");
|
||||
printf(_("OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"),
|
||||
values->offline_status, get_offline_text(values->offline_status & 0x7f),
|
||||
(values->offline_status & 0x80 ? "Yes" : "No"), values->offline_timeout / 60);
|
||||
printf(_("OffLineCapability=%d {%s %s %s}\n"), values->offline_capability,
|
||||
values->offline_capability & 1 ? "Immediate" : "",
|
||||
values->offline_capability & 2 ? "Auto" : "",
|
||||
values->offline_capability & 4 ? "AbortOnCmd" : "SuspendOnCmd");
|
||||
printf(_("SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"), values->revision,
|
||||
values->checksum, values->smart_capability,
|
||||
values->smart_capability & 1 ? "SaveOnStandBy" : "",
|
||||
values->smart_capability & 2 ? "AutoSave" : "");
|
||||
}
|
||||
|
||||
mp_state_enum smart_cmd_simple(int file_descriptor, enum SmartCommand command, uint8_t val0, bool show_error) {
|
||||
mp_state_enum smart_cmd_simple(int file_descriptor, enum SmartCommand command, uint8_t val0,
|
||||
bool show_error) {
|
||||
mp_state_enum result = STATE_UNKNOWN;
|
||||
#ifdef __linux__
|
||||
uint8_t args[4] = {
|
||||
|
|
@ -517,15 +532,18 @@ void print_help(void) {
|
|||
|
||||
printf(" %s\n", "-d, --device=DEVICE");
|
||||
printf(" %s\n", _("Select device DEVICE"));
|
||||
printf(" %s\n", _("Note: if the device is specified without this option, any further option will"));
|
||||
printf(" %s\n",
|
||||
_("Note: if the device is specified without this option, any further option will"));
|
||||
printf(" %s\n", _("be ignored."));
|
||||
|
||||
printf(UT_VERBOSE);
|
||||
|
||||
printf("\n");
|
||||
printf("%s\n", _("Notes:"));
|
||||
printf(" %s\n", _("The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"));
|
||||
printf(" %s\n", _("broken in an underhand manner and have been disabled. You can use smartctl"));
|
||||
printf(" %s\n",
|
||||
_("The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"));
|
||||
printf(" %s\n",
|
||||
_("broken in an underhand manner and have been disabled. You can use smartctl"));
|
||||
printf(" %s\n", _("instead:"));
|
||||
printf(" %s\n", _("-0/--auto-off: use \"smartctl --offlineauto=off\""));
|
||||
printf(" %s\n", _("-1/--auto-on: use \"smartctl --offlineauto=on\""));
|
||||
|
|
|
|||
|
|
@ -79,7 +79,8 @@ int main(int argc, char **argv) {
|
|||
/* open the status log */
|
||||
FILE *log_file = fopen(config.status_log, "r");
|
||||
if (log_file == NULL) {
|
||||
die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), _("Cannot open status log for reading!"));
|
||||
die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"),
|
||||
_("Cannot open status log for reading!"));
|
||||
}
|
||||
|
||||
unsigned long latest_entry_time = 0L;
|
||||
|
|
@ -153,7 +154,8 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
/* May get empty procargs */
|
||||
if (!strstr(procargs, argv[0]) && strstr(procargs, config.process_string) && strcmp(procargs, "")) {
|
||||
if (!strstr(procargs, argv[0]) && strstr(procargs, config.process_string) &&
|
||||
strcmp(procargs, "")) {
|
||||
proc_entries++;
|
||||
if (verbose >= 2) {
|
||||
printf(_("Found process: %s %s\n"), procprog, procargs);
|
||||
|
|
@ -171,11 +173,13 @@ int main(int argc, char **argv) {
|
|||
alarm(0);
|
||||
|
||||
if (proc_entries == 0) {
|
||||
die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), _("Could not locate a running Nagios process!"));
|
||||
die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"),
|
||||
_("Could not locate a running Nagios process!"));
|
||||
}
|
||||
|
||||
if (latest_entry_time == 0L) {
|
||||
die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"), _("Cannot parse Nagios log file for valid time"));
|
||||
die(STATE_CRITICAL, "NAGIOS %s: %s\n", _("CRITICAL"),
|
||||
_("Cannot parse Nagios log file for valid time"));
|
||||
}
|
||||
|
||||
time_t current_time;
|
||||
|
|
@ -189,7 +193,8 @@ int main(int argc, char **argv) {
|
|||
printf("NAGIOS %s: ", (result == STATE_OK) ? _("OK") : _("WARNING"));
|
||||
printf(ngettext("%d process", "%d processes", proc_entries), proc_entries);
|
||||
printf(", ");
|
||||
printf(ngettext("status log updated %d second ago", "status log updated %d seconds ago", (int)(current_time - latest_entry_time)),
|
||||
printf(ngettext("status log updated %d second ago", "status log updated %d seconds ago",
|
||||
(int)(current_time - latest_entry_time)),
|
||||
(int)(current_time - latest_entry_time));
|
||||
printf("\n");
|
||||
|
||||
|
|
@ -198,10 +203,11 @@ int main(int argc, char **argv) {
|
|||
|
||||
/* process command-line arguments */
|
||||
check_nagios_config_wrapper process_arguments(int argc, char **argv) {
|
||||
static struct option longopts[] = {{"filename", required_argument, 0, 'F'}, {"expires", required_argument, 0, 'e'},
|
||||
{"command", required_argument, 0, 'C'}, {"timeout", optional_argument, 0, 't'},
|
||||
{"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'},
|
||||
{"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0}};
|
||||
static struct option longopts[] = {
|
||||
{"filename", required_argument, 0, 'F'}, {"expires", required_argument, 0, 'e'},
|
||||
{"command", required_argument, 0, 'C'}, {"timeout", optional_argument, 0, 't'},
|
||||
{"version", no_argument, 0, 'V'}, {"help", no_argument, 0, 'h'},
|
||||
{"verbose", no_argument, 0, 'v'}, {0, 0, 0, 0}};
|
||||
|
||||
check_nagios_config_wrapper result = {
|
||||
.errorcode = OK,
|
||||
|
|
@ -285,7 +291,8 @@ void print_help(void) {
|
|||
printf("%s\n", _("This plugin checks the status of the Nagios process on the local machine"));
|
||||
printf("%s\n", _("The plugin will check to make sure the Nagios status log is no older than"));
|
||||
printf("%s\n", _("the number of minutes specified by the expires option."));
|
||||
printf("%s\n", _("It also checks the process table for a process matching the command argument."));
|
||||
printf("%s\n",
|
||||
_("It also checks the process table for a process matching the command argument."));
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
|
|
@ -306,12 +313,14 @@ void print_help(void) {
|
|||
|
||||
printf("\n");
|
||||
printf("%s\n", _("Examples:"));
|
||||
printf(" %s\n", "check_nagios -t 20 -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios");
|
||||
printf(" %s\n", "check_nagios -t 20 -e 5 -F /usr/local/nagios/var/status.log -C "
|
||||
"/usr/local/nagios/bin/nagios");
|
||||
|
||||
printf(UT_SUPPORT);
|
||||
}
|
||||
|
||||
void print_usage(void) {
|
||||
printf("%s\n", _("Usage:"));
|
||||
printf("%s -F <status log file> -t <timeout_seconds> -e <expire_minutes> -C <process_string>\n", progname);
|
||||
printf("%s -F <status log file> -t <timeout_seconds> -e <expire_minutes> -C <process_string>\n",
|
||||
progname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,9 +207,9 @@ enum {
|
|||
|
||||
/* for checking the result of getopt_long */
|
||||
#if EOF == -1
|
||||
#define CHECK_EOF(c) ((c) == EOF)
|
||||
# define CHECK_EOF(c) ((c) == EOF)
|
||||
#else
|
||||
#define CHECK_EOF(c) ((c) == -1 || (c) == EOF)
|
||||
# define CHECK_EOF(c) ((c) == -1 || (c) == EOF)
|
||||
#endif
|
||||
|
||||
#endif /* _COMMON_H_ */
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ bool dns_lookup(const char *, struct sockaddr_storage *, int);
|
|||
void host_or_die(const char *str);
|
||||
#define resolve_host_or_addr(addr, family) dns_lookup(addr, NULL, family)
|
||||
#define is_inet_addr(addr) resolve_host_or_addr(addr, AF_INET)
|
||||
# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)
|
||||
# define is_hostname(addr) resolve_host_or_addr(addr, address_family)
|
||||
#define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)
|
||||
#define is_hostname(addr) resolve_host_or_addr(addr, address_family)
|
||||
|
||||
extern unsigned int socket_timeout;
|
||||
extern mp_state_enum socket_timeout_state;
|
||||
|
|
@ -128,7 +128,8 @@ typedef struct {
|
|||
double remaining_seconds;
|
||||
retrieve_expiration_date_errors errors;
|
||||
} net_ssl_check_cert_result;
|
||||
net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn, unsigned int days_till_exp_crit);
|
||||
net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn,
|
||||
unsigned int days_till_exp_crit);
|
||||
|
||||
mp_state_enum np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit);
|
||||
mp_subcheck mp_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit);
|
||||
|
|
|
|||
|
|
@ -410,7 +410,8 @@ retrieve_expiration_time_result np_net_ssl_get_cert_expiration(X509 *certificate
|
|||
# endif /* MOPL_USE_OPENSSL */
|
||||
}
|
||||
|
||||
net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn, unsigned int days_till_exp_crit) {
|
||||
net_ssl_check_cert_result np_net_ssl_check_cert2(unsigned int days_till_exp_warn,
|
||||
unsigned int days_till_exp_crit) {
|
||||
# ifdef MOPL_USE_OPENSSL
|
||||
X509 *certificate = NULL;
|
||||
certificate = SSL_get_peer_certificate(s);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ extern const char *progname;
|
|||
#define STRLEN 64
|
||||
#define TXTBLK 128
|
||||
|
||||
|
||||
void usage(const char *msg) {
|
||||
printf("%s\n", msg);
|
||||
print_usage();
|
||||
|
|
|
|||
Loading…
Reference in a new issue