Imported Upstream version 2.1
This commit is contained in:
parent
0841b5c7c7
commit
060ec72678
47 changed files with 1718 additions and 1420 deletions
|
@ -169,7 +169,8 @@ process_arguments (int argc, char **argv)
|
|||
{"verbose", no_argument, 0, 'v'},
|
||||
{"fork", no_argument, 0, 'f'},
|
||||
{"timeout", required_argument, 0, 't'},
|
||||
{"host", required_argument, 0, 'H'},
|
||||
{"host", required_argument, 0, 'H'}, /* backward compatibility */
|
||||
{"hostname", required_argument, 0, 'H'},
|
||||
{"port", required_argument,0,'p'},
|
||||
{"output", required_argument, 0, 'O'},
|
||||
{"name", required_argument, 0, 'n'},
|
||||
|
|
|
@ -94,8 +94,8 @@ main (int argc, char **argv)
|
|||
timeout_interval_dig = timeout_interval / number_tries + number_tries;
|
||||
|
||||
/* get the command to run */
|
||||
xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s +tries=%d +time=%d",
|
||||
PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport, number_tries, timeout_interval_dig);
|
||||
xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d",
|
||||
PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig);
|
||||
|
||||
alarm (timeout_interval);
|
||||
gettimeofday (&tv, NULL);
|
||||
|
@ -296,7 +296,10 @@ process_arguments (int argc, char **argv)
|
|||
dns_server = argv[c];
|
||||
}
|
||||
else {
|
||||
dns_server = strdup ("127.0.0.1");
|
||||
if (strcmp(query_transport,"-6") == 0)
|
||||
dns_server = strdup("::1");
|
||||
else
|
||||
dns_server = strdup ("127.0.0.1");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ main (int argc, char **argv)
|
|||
char *details;
|
||||
char *perf;
|
||||
char *preamble;
|
||||
char *flag_header;
|
||||
double inode_space_pct;
|
||||
double warning_high_tide;
|
||||
double critical_high_tide;
|
||||
|
@ -353,18 +354,23 @@ main (int argc, char **argv)
|
|||
if (disk_result==STATE_OK && erronly && !verbose)
|
||||
continue;
|
||||
|
||||
xasprintf (&output, "%s %s %.0f %s (%.0f%%",
|
||||
output,
|
||||
if(disk_result && verbose >= 1) {
|
||||
xasprintf(&flag_header, " %s [", state_text (disk_result));
|
||||
} else {
|
||||
xasprintf(&flag_header, "");
|
||||
}
|
||||
xasprintf (&output, "%s%s %s %.0f %s (%.0f%%",
|
||||
output, flag_header,
|
||||
(!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
|
||||
path->dfree_units,
|
||||
units,
|
||||
path->dfree_pct);
|
||||
if (path->dused_inodes_percent < 0) {
|
||||
xasprintf(&output, "%s inode=-);", output);
|
||||
xasprintf(&output, "%s inode=-)%s;", output, (disk_result ? "]" : ""));
|
||||
} else {
|
||||
xasprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent );
|
||||
xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : ""));
|
||||
}
|
||||
|
||||
free(flag_header);
|
||||
/* TODO: Need to do a similar debug line
|
||||
xasprintf (&details, _("%s\n\
|
||||
%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
|
||||
|
|
|
@ -136,6 +136,28 @@ main (int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
/* bug ID: 2946553 - Older versions of bind will use all available dns
|
||||
servers, we have to match the one specified */
|
||||
if (strstr (chld_out.line[i], "Server:") && strlen(dns_server) > 0) {
|
||||
temp_buffer = strchr (chld_out.line[i], ':');
|
||||
temp_buffer++;
|
||||
|
||||
/* Strip leading tabs */
|
||||
for (; *temp_buffer != '\0' && *temp_buffer == '\t'; temp_buffer++)
|
||||
/* NOOP */;
|
||||
|
||||
strip(temp_buffer);
|
||||
if (temp_buffer==NULL || strlen(temp_buffer)==0) {
|
||||
die (STATE_CRITICAL,
|
||||
_("DNS CRITICAL - '%s' returned empty server string\n"),
|
||||
NSLOOKUP_COMMAND);
|
||||
}
|
||||
|
||||
if (strcmp(temp_buffer, dns_server) != 0) {
|
||||
die (STATE_CRITICAL, _("DNS CRITICAL - No response from DNS %s\n"), dns_server);
|
||||
}
|
||||
}
|
||||
|
||||
/* the server is responding, we just got the host name... */
|
||||
if (strstr (chld_out.line[i], "Name:"))
|
||||
parse_address = TRUE;
|
||||
|
|
|
@ -39,7 +39,7 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
#include "netutils.h"
|
||||
|
||||
#define DEFAULT_COMMUNITY "public"
|
||||
|
||||
#define DEFAULT_PORT "161"
|
||||
|
||||
const char *option_summary = "-H host [-C community]\n";
|
||||
|
||||
|
@ -66,6 +66,7 @@ void print_usage (void);
|
|||
|
||||
char *community = NULL;
|
||||
char *address = NULL;
|
||||
char *port = NULL;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -119,8 +120,8 @@ main (int argc, char **argv)
|
|||
HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
|
||||
|
||||
/* get the command to run */
|
||||
sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community,
|
||||
address, query_string);
|
||||
sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%hd %s", PATH_TO_SNMPGET, community,
|
||||
address, port, query_string);
|
||||
|
||||
/* run the command */
|
||||
child_process = spopen (command_line);
|
||||
|
@ -313,7 +314,7 @@ process_arguments (int argc, char **argv)
|
|||
{"community", required_argument, 0, 'C'},
|
||||
/* {"critical", required_argument,0,'c'}, */
|
||||
/* {"warning", required_argument,0,'w'}, */
|
||||
/* {"port", required_argument,0,'P'}, */
|
||||
{"port", required_argument,0,'p'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
|
@ -324,7 +325,7 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "+hVH:C:", longopts, &option);
|
||||
c = getopt_long (argc, argv, "+hVH:C:p:", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF || c == 1)
|
||||
break;
|
||||
|
@ -341,6 +342,12 @@ process_arguments (int argc, char **argv)
|
|||
case 'C': /* community */
|
||||
community = strscpy (community, optarg);
|
||||
break;
|
||||
case 'p':
|
||||
if (!is_intpos(optarg))
|
||||
usage2 (_("Port must be a positive short integer"), optarg);
|
||||
else
|
||||
port = atoi(optarg);
|
||||
break;
|
||||
case 'V': /* version */
|
||||
print_revision (progname, NP_VERSION);
|
||||
exit (STATE_OK);
|
||||
|
@ -369,6 +376,13 @@ process_arguments (int argc, char **argv)
|
|||
community = strdup (DEFAULT_COMMUNITY);
|
||||
}
|
||||
|
||||
if (port == NULL) {
|
||||
if (argv[c] != NULL )
|
||||
port = argv[c];
|
||||
else
|
||||
port = atoi (DEFAULT_PORT);
|
||||
}
|
||||
|
||||
return validate_arguments ();
|
||||
}
|
||||
|
||||
|
@ -402,6 +416,10 @@ print_help (void)
|
|||
printf (" %s", _("The SNMP community name "));
|
||||
printf (_("(default=%s)"), DEFAULT_COMMUNITY);
|
||||
printf ("\n");
|
||||
printf (" %s\n", "-p, --port=STRING");
|
||||
printf (" %s", _("Specify the port to check "));
|
||||
printf (_("(default=%s)"), DEFAULT_PORT);
|
||||
printf ("\n");
|
||||
|
||||
printf (UT_SUPPORT);
|
||||
}
|
||||
|
@ -412,5 +430,5 @@ void
|
|||
print_usage (void)
|
||||
{
|
||||
printf ("%s\n", _("Usage:"));
|
||||
printf ("%s -H host [-C community]\n", progname);
|
||||
printf ("%s -H host [-C community] [-p port]\n", progname);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ const char *email = "devel@monitoring-plugins.org";
|
|||
#include "netutils.h"
|
||||
|
||||
#include <mysql.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <errmsg.h>
|
||||
|
||||
char *db_user = NULL;
|
||||
|
@ -59,6 +60,7 @@ char *opt_file = NULL;
|
|||
char *opt_group = NULL;
|
||||
unsigned int db_port = MYSQL_PORT;
|
||||
int check_slave = 0, warn_sec = 0, crit_sec = 0;
|
||||
int ignore_auth = 0;
|
||||
int verbose = 0;
|
||||
|
||||
static double warning_time = 0;
|
||||
|
@ -136,7 +138,16 @@ main (int argc, char **argv)
|
|||
mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
|
||||
/* establish a connection to the server and error checking */
|
||||
if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
|
||||
if (mysql_errno (&mysql) == CR_UNKNOWN_HOST)
|
||||
if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR)
|
||||
{
|
||||
printf("MySQL OK - Version: %s (protocol %d)\n",
|
||||
mysql_get_server_info(&mysql),
|
||||
mysql_get_proto_info(&mysql)
|
||||
);
|
||||
mysql_close (&mysql);
|
||||
return STATE_OK;
|
||||
}
|
||||
else if (mysql_errno (&mysql) == CR_UNKNOWN_HOST)
|
||||
die (STATE_WARNING, "%s\n", mysql_error (&mysql));
|
||||
else if (mysql_errno (&mysql) == CR_VERSION_ERROR)
|
||||
die (STATE_WARNING, "%s\n", mysql_error (&mysql));
|
||||
|
@ -341,6 +352,7 @@ process_arguments (int argc, char **argv)
|
|||
{"critical", required_argument, 0, 'c'},
|
||||
{"warning", required_argument, 0, 'w'},
|
||||
{"check-slave", no_argument, 0, 'S'},
|
||||
{"ignore-auth", no_argument, 0, 'n'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"version", no_argument, 0, 'V'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
|
@ -357,7 +369,7 @@ process_arguments (int argc, char **argv)
|
|||
return ERROR;
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "hlvVSP:p:u:d:H:s:c:w:a:k:C:D:L:f:g:", longopts, &option);
|
||||
c = getopt_long (argc, argv, "hlvVnSP:p:u:d:H:s:c:w:a:k:C:D:L:f:g:", longopts, &option);
|
||||
|
||||
if (c == -1 || c == EOF)
|
||||
break;
|
||||
|
@ -419,6 +431,9 @@ process_arguments (int argc, char **argv)
|
|||
case 'S':
|
||||
check_slave = 1; /* check-slave */
|
||||
break;
|
||||
case 'n':
|
||||
ignore_auth = 1; /* ignore-auth */
|
||||
break;
|
||||
case 'w':
|
||||
warning = optarg;
|
||||
warning_time = strtod (warning, NULL);
|
||||
|
@ -506,6 +521,9 @@ print_help (void)
|
|||
printf (UT_EXTRA_OPTS);
|
||||
|
||||
printf (UT_HOST_PORT, 'P', myport);
|
||||
printf (" %s\n", "-n, --ignore-auth");
|
||||
printf (" %s\n", _("Ignore authentication failure and check for mysql connectivity only"));
|
||||
|
||||
printf (" %s\n", "-s, --socket=STRING");
|
||||
printf (" %s\n", _("Use the specified socket (has no effect if -H is used)"));
|
||||
|
||||
|
|
|
@ -560,7 +560,7 @@ char *perfd_truechimers (int num_truechimers)
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int result, offset_result, stratum, num_truechimers;
|
||||
int result, offset_result, stratum, num_truechimers, oresult, jresult, sresult, tresult;
|
||||
double offset=0, jitter=0;
|
||||
char *result_line, *perfdata_line;
|
||||
|
||||
|
@ -597,15 +597,22 @@ int main(int argc, char *argv[]){
|
|||
result = STATE_UNKNOWN;
|
||||
result = max_state_alt(result, get_status(fabs(offset), offset_thresholds));
|
||||
}
|
||||
oresult = result;
|
||||
|
||||
if(do_truechimers) {
|
||||
tresult = get_status(num_truechimers, truechimer_thresholds);
|
||||
result = max_state_alt(result, tresult);
|
||||
}
|
||||
|
||||
if(do_truechimers)
|
||||
result = max_state_alt(result, get_status(num_truechimers, truechimer_thresholds));
|
||||
if(do_stratum) {
|
||||
sresult = get_status(stratum, stratum_thresholds);
|
||||
result = max_state_alt(result, sresult);
|
||||
}
|
||||
|
||||
if(do_stratum)
|
||||
result = max_state_alt(result, get_status(stratum, stratum_thresholds));
|
||||
|
||||
if(do_jitter)
|
||||
result = max_state_alt(result, get_status(jitter, jitter_thresholds));
|
||||
if(do_jitter) {
|
||||
jresult = get_status(jitter, jitter_thresholds);
|
||||
result = max_state_alt(result, jresult);
|
||||
}
|
||||
|
||||
switch (result) {
|
||||
case STATE_CRITICAL :
|
||||
|
@ -629,20 +636,43 @@ int main(int argc, char *argv[]){
|
|||
if(offset_result == STATE_UNKNOWN){
|
||||
xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
|
||||
xasprintf(&perfdata_line, "");
|
||||
} else if (oresult == STATE_WARNING) {
|
||||
xasprintf(&result_line, "%s %s %.10g secs (WARNING)", result_line, _("Offset"), offset);
|
||||
} else if (oresult == STATE_CRITICAL) {
|
||||
xasprintf(&result_line, "%s %s %.10g secs (CRITICAL)", result_line, _("Offset"), offset);
|
||||
} else {
|
||||
xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
|
||||
xasprintf(&perfdata_line, "%s", perfd_offset(offset));
|
||||
}
|
||||
}
|
||||
xasprintf(&perfdata_line, "%s", perfd_offset(offset));
|
||||
|
||||
if (do_jitter) {
|
||||
xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
|
||||
if (jresult == STATE_WARNING) {
|
||||
xasprintf(&result_line, "%s, jitter=%f (WARNING)", result_line, jitter);
|
||||
} else if (jresult == STATE_CRITICAL) {
|
||||
xasprintf(&result_line, "%s, jitter=%f (CRITICAL)", result_line, jitter);
|
||||
} else {
|
||||
xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
|
||||
}
|
||||
xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_jitter(jitter));
|
||||
}
|
||||
if (do_stratum) {
|
||||
xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
|
||||
if (sresult == STATE_WARNING) {
|
||||
xasprintf(&result_line, "%s, stratum=%i (WARNING)", result_line, stratum);
|
||||
} else if (sresult == STATE_CRITICAL) {
|
||||
xasprintf(&result_line, "%s, stratum=%i (CRITICAL)", result_line, stratum);
|
||||
} else {
|
||||
xasprintf(&result_line, "%s, stratum=%i", result_line, stratum);
|
||||
}
|
||||
xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_stratum(stratum));
|
||||
}
|
||||
if (do_truechimers) {
|
||||
xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
|
||||
if (tresult == STATE_WARNING) {
|
||||
xasprintf(&result_line, "%s, truechimers=%i (WARNING)", result_line, num_truechimers);
|
||||
} else if (tresult == STATE_CRITICAL) {
|
||||
xasprintf(&result_line, "%s, truechimers=%i (CRITICAL)", result_line, num_truechimers);
|
||||
} else {
|
||||
xasprintf(&result_line, "%s, truechimers=%i", result_line, num_truechimers);
|
||||
}
|
||||
xasprintf(&perfdata_line, "%s %s", perfdata_line, perfd_truechimers(num_truechimers));
|
||||
}
|
||||
printf("%s|%s\n", result_line, perfdata_line);
|
||||
|
@ -651,8 +681,6 @@ int main(int argc, char *argv[]){
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void print_help(void){
|
||||
print_revision(progname, NP_VERSION);
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ static int verbose=0;
|
|||
static int quiet=0;
|
||||
static char *owarn="60";
|
||||
static char *ocrit="120";
|
||||
static int time_offset=0;
|
||||
|
||||
int process_arguments (int, char **);
|
||||
thresholds *offset_thresholds = NULL;
|
||||
|
@ -400,7 +401,7 @@ double offset_request(const char *host, int *status){
|
|||
gettimeofday(&recv_time, NULL);
|
||||
DBG(print_ntp_message(&req[i]));
|
||||
respnum=servers[i].num_responses++;
|
||||
servers[i].offset[respnum]=calc_offset(&req[i], &recv_time);
|
||||
servers[i].offset[respnum]=calc_offset(&req[i], &recv_time)+time_offset;
|
||||
if(verbose) {
|
||||
printf("offset %.10g\n", servers[i].offset[respnum]);
|
||||
}
|
||||
|
@ -455,6 +456,7 @@ int process_arguments(int argc, char **argv){
|
|||
{"use-ipv4", no_argument, 0, '4'},
|
||||
{"use-ipv6", no_argument, 0, '6'},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"time-offset", optional_argument, 0, 'o'},
|
||||
{"warning", required_argument, 0, 'w'},
|
||||
{"critical", required_argument, 0, 'c'},
|
||||
{"timeout", required_argument, 0, 't'},
|
||||
|
@ -468,7 +470,7 @@ int process_arguments(int argc, char **argv){
|
|||
usage ("\n");
|
||||
|
||||
while (1) {
|
||||
c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:", longopts, &option);
|
||||
c = getopt_long (argc, argv, "Vhv46qw:c:t:H:p:o:", longopts, &option);
|
||||
if (c == -1 || c == EOF || c == 1)
|
||||
break;
|
||||
|
||||
|
@ -504,6 +506,9 @@ int process_arguments(int argc, char **argv){
|
|||
case 't':
|
||||
socket_timeout=atoi(optarg);
|
||||
break;
|
||||
case 'o':
|
||||
time_offset=atoi(optarg);
|
||||
break;
|
||||
case '4':
|
||||
address_family = AF_INET;
|
||||
break;
|
||||
|
@ -616,6 +621,8 @@ void print_help(void){
|
|||
printf (" %s\n", _("Offset to result in warning status (seconds)"));
|
||||
printf (" %s\n", "-c, --critical=THRESHOLD");
|
||||
printf (" %s\n", _("Offset to result in critical status (seconds)"));
|
||||
printf (" %s\n", "-o, --time_offset=INTEGER");
|
||||
printf (" %s\n", _("Expected offset of the ntp server relative to local server (seconds)"));
|
||||
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
||||
printf (UT_VERBOSE);
|
||||
|
||||
|
@ -628,6 +635,8 @@ void print_help(void){
|
|||
printf("%s\n", _("Notes:"));
|
||||
printf(" %s\n", _("If you'd rather want to monitor an NTP server, please use"));
|
||||
printf(" %s\n", _("check_ntp_peer."));
|
||||
printf(" %s\n", _("--time-offset is usefull for compensating for servers with known"));
|
||||
printf(" %s\n", _("and expected clock skew."));
|
||||
printf("\n");
|
||||
printf(UT_THRESHOLDS_NOTES);
|
||||
|
||||
|
@ -642,6 +651,6 @@ void
|
|||
print_usage(void)
|
||||
{
|
||||
printf ("%s\n", _("Usage:"));
|
||||
printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose]\n", progname);
|
||||
printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose] [-o <time offset>]\n", progname);
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
else if (!strncmp(SERVICE, "JABBER", 6)) {
|
||||
SEND = "<stream:stream to=\'host\' xmlns=\'jabber:client\' xmlns:stream=\'http://etherx.jabber.org/streams\'>\n";
|
||||
EXPECT = "<?xml version=\'1.0\'?><stream:stream xmlns=\'jabber:client\' xmlns:stream=\'http://etherx.jabber.org/streams\'";
|
||||
EXPECT = "<?xml version=\'1.0\'";
|
||||
QUIT = "</stream:stream>\n";
|
||||
flags |= FLAG_HIDE_OUTPUT;
|
||||
PORT = 5222;
|
||||
|
|
|
@ -167,11 +167,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
|
|||
char port_str[6], host[MAX_HOST_ADDRESS_LENGTH];
|
||||
size_t len;
|
||||
int socktype, result;
|
||||
short is_socket = (host_name[0] == '/');
|
||||
|
||||
socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
|
||||
|
||||
/* as long as it doesn't start with a '/', it's assumed a host or ip */
|
||||
if(host_name[0] != '/'){
|
||||
if (!is_socket){
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
hints.ai_family = address_family;
|
||||
hints.ai_protocol = proto;
|
||||
|
@ -253,7 +254,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
|
|||
return econn_refuse_state;
|
||||
break;
|
||||
case STATE_CRITICAL: /* user did not set econn_refuse_state */
|
||||
printf ("%s\n", strerror(errno));
|
||||
if (is_socket)
|
||||
printf("connect to file socket %s: %s\n", host_name, strerror(errno));
|
||||
else
|
||||
printf("connect to address %s and port %d: %s\n",
|
||||
host_name, port, strerror(errno));
|
||||
return econn_refuse_state;
|
||||
break;
|
||||
default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
|
||||
|
@ -262,7 +267,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
|
|||
}
|
||||
}
|
||||
else {
|
||||
printf ("%s\n", strerror(errno));
|
||||
if (is_socket)
|
||||
printf("connect to file socket %s: %s\n", host_name, strerror(errno));
|
||||
else
|
||||
printf("connect to address %s and port %d: %s\n",
|
||||
host_name, port, strerror(errno));
|
||||
return STATE_CRITICAL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
|
|||
struct tm stamp;
|
||||
float time_left;
|
||||
int days_left;
|
||||
char timestamp[17] = "";
|
||||
char timestamp[50] = "";
|
||||
time_t tm_t;
|
||||
|
||||
certificate=SSL_get_peer_certificate(s);
|
||||
if (!certificate) {
|
||||
|
@ -211,10 +212,8 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
|
|||
|
||||
time_left = difftime(timegm(&stamp), time(NULL));
|
||||
days_left = time_left / 86400;
|
||||
snprintf
|
||||
(timestamp, 17, "%02d/%02d/%04d %02d:%02d",
|
||||
stamp.tm_mon + 1,
|
||||
stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min);
|
||||
tm_t = mktime (&stamp);
|
||||
strftime(timestamp, 50, "%c", localtime(&tm_t));
|
||||
|
||||
if (days_left > 0 && days_left <= days_till_exp_warn) {
|
||||
printf (_("%s - Certificate '%s' expires in %d day(s) (%s).\n"), (days_left>days_till_exp_crit)?"WARNING":"CRITICAL", cn, days_left, timestamp);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
'NP_HOST_SNMP' => '',
|
||||
'NP_HOST_TCP_FTP' => '',
|
||||
'NP_HOST_TCP_HPJD' => '',
|
||||
'NP_HOST_HPJD_PORT_INVALID' => '161',
|
||||
'NP_HOST_HPJD_PORT_VALID' => '',
|
||||
'NP_HOST_TCP_HTTP' => 'localhost',
|
||||
'NP_HOST_TCP_HTTP2' => 'labs.consol.de',
|
||||
'NP_HOST_TCP_IMAP' => 'imap.web.de',
|
||||
|
|
|
@ -10,7 +10,7 @@ use NPTest;
|
|||
|
||||
plan skip_all => "check_dns not compiled" unless (-x "check_dns");
|
||||
|
||||
plan tests => 14;
|
||||
plan tests => 16;
|
||||
|
||||
my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
|
||||
|
||||
|
@ -43,6 +43,12 @@ my $dns_server = getTestParameter(
|
|||
"A non default (remote) DNS server",
|
||||
);
|
||||
|
||||
my $host_nonresponsive = getTestParameter(
|
||||
"NP_HOST_NONRESPONSIVE",
|
||||
"The hostname of system not responsive to network requests",
|
||||
"10.0.0.1",
|
||||
);
|
||||
|
||||
my $res;
|
||||
|
||||
$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5");
|
||||
|
@ -54,7 +60,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed");
|
|||
|
||||
$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5");
|
||||
cmp_ok( $res->return_code, '==', 1, "Warning threshold passed");
|
||||
like( $res->output, "/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/", "Output performance data OK" );
|
||||
like( $res->output, '/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/', "Output performance data OK" );
|
||||
|
||||
$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1");
|
||||
cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid");
|
||||
|
@ -66,6 +72,10 @@ like ( $res->output, $successOutput, "Output OK" );
|
|||
$res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1");
|
||||
cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server");
|
||||
|
||||
$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -s $host_nonresponsive -t 2");
|
||||
cmp_ok( $res->return_code, '==', 2, "Got no answer from unresponsive server");
|
||||
like ( $res->output, "/CRITICAL - /", "Output OK");
|
||||
|
||||
$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5");
|
||||
cmp_ok( $res->return_code, '==', 0, "Got expected address");
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ use NPTest;
|
|||
|
||||
plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
|
||||
|
||||
plan tests => 5;
|
||||
|
||||
my $successOutput = '/^Printer ok - /';
|
||||
my $failureOutput = '/Timeout: No [Rr]esponse from /';
|
||||
|
@ -20,31 +19,53 @@ my $host_tcp_hpjd = getTestParameter(
|
|||
"A host (usually a printer) providing the HP-JetDirect Services"
|
||||
);
|
||||
|
||||
my $host_hpjd_port_invalid = getTestParameter(
|
||||
"NP_HOST_HPJD_PORT_INVALID",
|
||||
"A port that HP-JetDirect Services is not listening on",
|
||||
"162"
|
||||
);
|
||||
|
||||
my $host_hpjd_port_valid = getTestParameter(
|
||||
"NP_HOST_HPJD_PORT_VALID",
|
||||
"The port that HP-JetDirect Services is currently listening on",
|
||||
"161"
|
||||
);
|
||||
|
||||
my $host_nonresponsive = getTestParameter(
|
||||
"NP_HOST_NONRESPONSIVE",
|
||||
"The hostname of system not responsive to network requests",
|
||||
"10.0.0.1",
|
||||
"10.0.0.1"
|
||||
);
|
||||
|
||||
my $hostname_invalid = getTestParameter(
|
||||
"NP_HOSTNAME_INVALID",
|
||||
"An invalid (not known to DNS) hostname",
|
||||
"nosuchhost",
|
||||
"nosuchhost"
|
||||
);
|
||||
|
||||
my $tests = $host_tcp_hpjd ? 9 : 5;
|
||||
plan tests => $tests;
|
||||
my $res;
|
||||
|
||||
SKIP: {
|
||||
skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd;
|
||||
$res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd");
|
||||
cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" );
|
||||
$res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd");
|
||||
cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding" );
|
||||
like ( $res->output, $successOutput, "Output correct" );
|
||||
|
||||
$res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_valid");
|
||||
cmp_ok( $res->return_code, 'eq', 0, "Jetdirect responding on port $host_hpjd_port_valid" );
|
||||
like ( $res->output, $successOutput, "Output correct" );
|
||||
|
||||
$res = NPTest->testCmd("./check_hpjd -H $host_tcp_hpjd -p $host_hpjd_port_invalid");
|
||||
cmp_ok( $res->return_code, 'eq', 2, "Jetdirect not responding on port $host_hpjd_port_invalid" );
|
||||
like ( $res->output, $failureOutput, "Output correct" );
|
||||
}
|
||||
|
||||
$res = NPTest->testCmd("./check_hpjd $host_nonresponsive");
|
||||
$res = NPTest->testCmd("./check_hpjd -H $host_nonresponsive");
|
||||
cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
|
||||
like ( $res->output, $failureOutput, "Output OK" );
|
||||
|
||||
$res = NPTest->testCmd("./check_hpjd $hostname_invalid");
|
||||
$res = NPTest->testCmd("./check_hpjd -H $hostname_invalid");
|
||||
cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'
|
|||
my $ntp_warnmatch1 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
|
||||
my $ntp_critmatch1 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
|
||||
my $ntp_okmatch2 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
|
||||
my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
|
||||
my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
|
||||
my $ntp_warnmatch2 = '/^NTP\sWARNING:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+,\sstratum=[0-9]{1,2}\s\(WARNING\),\struechimers=[0-9]+/';
|
||||
my $ntp_critmatch2 = '/^NTP\sCRITICAL:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs,\sjitter=[0-9]+\.[0-9]+\s\(CRITICAL\),\sstratum=[0-9]{1,2},\struechimers=[0-9]+/';
|
||||
my $ntp_noresponse = '/^(CRITICAL - Socket timeout after 3 seconds)|(NTP CRITICAL: No response from NTP server)$/';
|
||||
my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_invalid . '/';
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use strict;
|
||||
use Test::More;
|
||||
use Cwd;
|
||||
use NPTest;
|
||||
|
||||
# 15 tests in the first part, 9 in timeout tests and 2 * 32 in the last loops
|
||||
|
@ -13,7 +14,7 @@ plan tests => 88;
|
|||
|
||||
my $res;
|
||||
|
||||
my $PWD = $ENV{PWD};
|
||||
my $PWD = getcwd();
|
||||
|
||||
$res = NPTest->testCmd( "./negate" );
|
||||
is( $res->return_code, 3, "Not enough parameters");
|
||||
|
@ -50,7 +51,7 @@ is( $res->output, "OK: a dummy okay", "The quoted string is passed through to su
|
|||
$res = NPTest->testCmd( "./negate '$PWD/check_dummy 0' 'a dummy okay'" );
|
||||
is( $res->output, "No data returned from command", "Bad command, as expected (trying to execute './check_dummy 0')");
|
||||
|
||||
$res = NPTest->testCmd( './negate $PWD/check_dummy 0 \'$$ a dummy okay\'' );
|
||||
$res = NPTest->testCmd( './negate '.$PWD.'/check_dummy 0 \'$$ a dummy okay\'' );
|
||||
is( $res->output, 'OK: $$ a dummy okay', 'Proves that $$ is not being expanded again' );
|
||||
|
||||
my %state = (
|
||||
|
|
|
@ -186,21 +186,21 @@ SKIP: {
|
|||
|
||||
$result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
|
||||
is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
|
||||
is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on 03/03/2019 21:41.', "output ok" );
|
||||
is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:00 2019.', "output ok" );
|
||||
|
||||
$result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
|
||||
is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
|
||||
like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" );
|
||||
like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
|
||||
|
||||
# Expired cert tests
|
||||
$result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
|
||||
is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
|
||||
like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" );
|
||||
like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
|
||||
|
||||
$result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
|
||||
is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
|
||||
is( $result->output,
|
||||
'CRITICAL - Certificate \'Ton Voon\' expired on 03/05/2009 00:13.',
|
||||
'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:00 2009.',
|
||||
"output ok" );
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,16 @@ if ($@) {
|
|||
plan skip_all => "Missing required module for test: $@";
|
||||
} else {
|
||||
if (-x "./check_snmp") {
|
||||
plan tests => $tests;
|
||||
# check if snmpd has perl support
|
||||
my $test = `snmpd -c tests/conf/snmpd.conf -C -r -H 2>&1`;
|
||||
if(!defined $test) {
|
||||
plan skip_all => "snmpd required";
|
||||
}
|
||||
elsif($test =~ m/Warning: Unknown token: perl/) {
|
||||
plan skip_all => "snmpd has no perl support";
|
||||
} else {
|
||||
plan tests => $tests;
|
||||
}
|
||||
} else {
|
||||
plan skip_all => "No check_snmp compiled";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue