aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--NEWS5
-rw-r--r--REQUIREMENTS12
-rw-r--r--THANKS.in5
-rw-r--r--configure.ac35
-rwxr-xr-xplugins-scripts/check_ifoperstatus.pl2
-rwxr-xr-xplugins-scripts/check_ifstatus.pl2
-rw-r--r--plugins/check_by_ssh.c7
-rw-r--r--plugins/check_dig.c4
-rw-r--r--plugins/check_disk.c9
-rw-r--r--plugins/check_dns.c6
-rw-r--r--plugins/check_http.c46
-rw-r--r--plugins/check_ide_smart.c26
-rw-r--r--plugins/check_load.c2
-rw-r--r--plugins/check_ntp.c6
-rw-r--r--plugins/check_ntp_time.c8
-rw-r--r--plugins/check_radius.c36
-rw-r--r--plugins/check_smtp.c12
-rw-r--r--plugins/check_snmp.c16
-rw-r--r--plugins/check_tcp.c4
-rw-r--r--plugins/check_users.c60
-rw-r--r--plugins/common.h7
-rw-r--r--plugins/negate.c4
-rw-r--r--plugins/netutils.c15
-rw-r--r--plugins/netutils.h7
-rw-r--r--plugins/sslutils.c15
-rw-r--r--plugins/t/NPTest.cache.travis4
-rw-r--r--plugins/t/check_http.t32
-rw-r--r--plugins/t/check_snmp.t8
-rw-r--r--plugins/t/check_users.t4
-rwxr-xr-xplugins/tests/check_http.t10
-rw-r--r--plugins/utils.c41
-rw-r--r--plugins/utils.h34
33 files changed, 289 insertions, 197 deletions
diff --git a/.travis.yml b/.travis.yml
index 29290fd1..dcf13d58 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,7 +20,7 @@ before_install:
# - mysql -e "create database IF NOT EXISTS test;" -uroot
install:
- - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libfreeradius-client-dev libkrb5-dev libnet-snmp-perl procps
+ - sudo apt-get install -qq --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev libmysqlclient-dev libradcli-dev libkrb5-dev libnet-snmp-perl procps
- sudo apt-get install -qq --no-install-recommends libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd
- sudo apt-get install -qq --no-install-recommends fping snmp netcat smbclient fping pure-ftpd apache2 postfix libhttp-daemon-ssl-perl
- sudo apt-get install -qq --no-install-recommends libdbd-sybase-perl libnet-dns-perl
diff --git a/NEWS b/NEWS
index 2a9ea62c..8a8df6a9 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ This file documents the major additions and syntax changes between releases.
to force TLSv1.1 and TLSv1.2 connections, respectively
The check_http -S/--ssl option now allows for specifying the desired
protocol with a "+" suffix to also accept newer versions
+ check_users: add support for range thresholds (John C. Frickson)
+ check_snmp: add ipv6 support (abrist)
+ check_http: report certificate expire date in UTC (pirtoo / ylfingr)
+ check_radius now supports the radcli library
FIXES
Let check_real terminate lines with CRLF when talking to the server, as
@@ -19,6 +23,7 @@ This file documents the major additions and syntax changes between releases.
Fix check_procs on HP-UX
check_smtp's -e/--expect option can now be combined with -S/--starttls
Fix incorrect performance data thresholds emitted by check_ups
+ check_http: fix host header port handling (odenbach)
WARNINGS
The format of the performance data emitted by check_mrtgtraf has been
diff --git a/REQUIREMENTS b/REQUIREMENTS
index 303fd62b..ac7b5935 100644
--- a/REQUIREMENTS
+++ b/REQUIREMENTS
@@ -50,16 +50,18 @@ check_dbi:
http://libdbi.sourceforge.net/
check_radius:
- - Requires the FreeRADIUS Client library available from:
+ - Requires the radcli library available from:
+ http://radcli.github.io/radcli/
+ - As an alternative, the FreeRADIUS Client library may be used:
http://freeradius.org/freeradius-client/
- - As an alternative, the radiusclient-ng library may be used:
+ - As another alternative, the radiusclient-ng library may be used:
http://sourceforge.net/projects/radiusclient-ng.berlios/
- This plugin also works with the original radiusclient library from
ftp://ftp.cityline.net/pub/radiusclient/
RPM (rpmfind): radiusclient 0.3.2, radiusclient-devel-0.3.2
- However, you probably want to use the FreeRADIUS Client library, as
- both radiusclient and radiusclient-ng are unmaintained and have known
- issues.
+ However, you probably want to use either radcli or the FreeRADIUS
+ Client library, as both radiusclient and radiusclient-ng are
+ unmaintained and have known issues.
check_snmp:
- Requires the NET-SNMP package available from
diff --git a/THANKS.in b/THANKS.in
index 59c90feb..f48a8bd1 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -336,3 +336,8 @@ Nick Peelman
Sebastian Herbszt
Christopher Schultz
Matthias Hähnel
+Roberto Greiner
+Peter (pirtoo)
+ylfingr
+Christian Kujau
+Christopher Odenbach
diff --git a/configure.ac b/configure.ac
index 0a554af6..367e82a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,26 +273,33 @@ AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plug
dnl Check for radius libraries
AS_IF([test "x$with_radius" != "xno"], [
_SAVEDLIBS="$LIBS"
- AC_CHECK_LIB(freeradius-client,rc_read_config)
- if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
+ AC_CHECK_LIB(radcli,rc_read_config)
+ if test "$ac_cv_lib_radcli_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
- RADIUSLIBS="-lfreeradius-client"
+ RADIUSLIBS="-lradcli"
AC_SUBST(RADIUSLIBS)
else
- AC_CHECK_LIB(radiusclient-ng,rc_read_config)
- if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
+ AC_CHECK_LIB(freeradius-client,rc_read_config)
+ if test "$ac_cv_lib_freeradius_client_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
- RADIUSLIBS="-lradiusclient-ng"
+ RADIUSLIBS="-lfreeradius-client"
AC_SUBST(RADIUSLIBS)
else
- AC_CHECK_LIB(radiusclient,rc_read_config)
- if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
+ AC_CHECK_LIB(radiusclient-ng,rc_read_config)
+ if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
- RADIUSLIBS="-lradiusclient"
+ RADIUSLIBS="-lradiusclient-ng"
AC_SUBST(RADIUSLIBS)
else
- AC_MSG_WARN([Skipping radius plugin])
- AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
+ AC_CHECK_LIB(radiusclient,rc_read_config)
+ if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
+ EXTRAS="$EXTRAS check_radius\$(EXEEXT)"
+ RADIUSLIBS="-lradiusclient"
+ AC_SUBST(RADIUSLIBS)
+ else
+ AC_MSG_WARN([Skipping radius plugin])
+ AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
+ fi
fi
fi
fi
@@ -493,15 +500,15 @@ if ! test x"$with_openssl" = x"no"; then
dnl Check for crypto lib
_SAVEDLIBS="$LIBS"
LIBS="-L${with_openssl}/lib"
- AC_CHECK_LIB(crypto,CRYPTO_lock)
- if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
+ AC_CHECK_LIB(crypto,CRYPTO_new_ex_data)
+ if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
dnl Check for SSL lib
AC_CHECK_LIB(ssl,main, SSLLIBS="-lssl -lcrypto",,-lcrypto)
fi
LIBS="$_SAVEDLIBS"
dnl test headers and libs to decide whether check_http should use SSL
- if test "$ac_cv_lib_crypto_CRYPTO_lock" = "yes"; then
+ if test "$ac_cv_lib_crypto_CRYPTO_new_ex_data" = "yes"; then
if test "$ac_cv_lib_ssl_main" = "yes"; then
if test "$FOUNDINCLUDE" = "yes"; then
FOUNDOPENSSL="yes"
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index 3eed4bcb..9ede1633 100755
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -325,7 +325,7 @@ sub print_help() {
printf " (Implies the use of -I)\n";
printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n";
- printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
+ printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
printf " -V (--version) Plugin version\n";
printf " -h (--help) usage help \n\n";
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index 9f2f7c31..32984e53 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -280,7 +280,7 @@ sub print_help() {
printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
printf " privacy password and authEngineID\n";
printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n";
- printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
+ printf " -M (--maxmsgsize) Max message size - useful only for v1 or v2c\n";
printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
printf " -V (--version) Plugin version\n";
printf " -h (--help) usage help \n\n";
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 04bce38d..13d8bc3b 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -100,6 +100,13 @@ main (int argc, char **argv)
result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
+ if (verbose) {
+ for(i = 0; i < chld_out.lines; i++)
+ printf("stdout: %s\n", chld_out.line[i]);
+ for(i = 0; i < chld_err.lines; i++)
+ printf("stderr: %s\n", chld_err.line[i]);
+ }
+
if (skip_stdout == -1) /* --skip-stdout specified without argument */
skip_stdout = chld_out.lines;
if (skip_stderr == -1) /* --skip-stderr specified without argument */
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 473d4b97..da4f0ded 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -48,7 +48,7 @@ void print_usage (void);
#define UNDEFINED 0
#define DEFAULT_PORT 53
-#define DEFAULT_TRIES 3
+#define DEFAULT_TRIES 2
char *query_address = NULL;
char *record_type = "A";
@@ -94,7 +94,7 @@ main (int argc, char **argv)
timeout_interval_dig = timeout_interval / number_tries + number_tries;
/* get the command to run */
- xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d",
+ xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +retry=%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);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 8e793c94..4b5ba5fe 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -58,9 +58,6 @@ const char *email = "devel@monitoring-plugins.org";
# define ERROR -1
#endif
-/* If nonzero, show inode information. */
-static int inode_format = 1;
-
/* If nonzero, show even filesystems with zero size or
uninteresting types. */
static int show_all_fs = 1;
@@ -179,7 +176,7 @@ main (int argc, char **argv)
int temp_result;
struct mount_entry *me;
- struct fs_usage fsp, tmpfsp;
+ struct fs_usage fsp;
struct parameter_list *temp_list, *path;
#ifdef __CYGWIN__
@@ -434,9 +431,7 @@ process_arguments (int argc, char **argv)
int c, err;
struct parameter_list *se;
struct parameter_list *temp_list = NULL, *previous = NULL;
- struct parameter_list *temp_path_select_list = NULL;
- struct mount_entry *me, *temp_me;
- int result = OK;
+ struct mount_entry *me;
regex_t re;
int cflags = REG_NOSUB | REG_EXTENDED;
int default_cflags = cflags;
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 48601f02..54ce7d16 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -81,7 +81,6 @@ main (int argc, char **argv)
double elapsed_time;
long microsec;
struct timeval tv;
- int multi_address;
int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
output chld_out, chld_err;
size_t i;
@@ -249,11 +248,6 @@ main (int argc, char **argv)
elapsed_time = (double)microsec / 1.0e6;
if (result == STATE_OK) {
- if (strchr (address, ',') == NULL)
- multi_address = FALSE;
- else
- multi_address = TRUE;
-
result = get_status(elapsed_time, time_thresholds);
if (result == STATE_OK) {
printf ("DNS %s: ", _("OK"));
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 2038f4a1..2347a6f2 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -91,10 +91,12 @@ struct timeval tv_temp;
int specify_port = FALSE;
int server_port = HTTP_PORT;
+int virtual_port = 0;
char server_port_text[6] = "";
char server_type[6] = "http";
char *server_address;
char *host_name;
+int host_name_length;
char *server_url;
char *user_agent;
int server_url_length;
@@ -391,11 +393,25 @@ process_arguments (int argc, char **argv)
case 'H': /* Host Name (virtual host) */
host_name = strdup (optarg);
if (host_name[0] == '[') {
- if ((p = strstr (host_name, "]:")) != NULL) /* [IPv6]:port */
- server_port = atoi (p + 2);
+ if ((p = strstr (host_name, "]:")) != NULL) { /* [IPv6]:port */
+ virtual_port = atoi (p + 2);
+ /* cut off the port */
+ host_name_length = strlen (host_name) - strlen (p) - 1;
+ free (host_name);
+ host_name = strndup (optarg, host_name_length);
+ if (specify_port == FALSE)
+ server_port = virtual_port;
+ }
} else if ((p = strchr (host_name, ':')) != NULL
- && strchr (++p, ':') == NULL) /* IPv4:port or host:port */
- server_port = atoi (p);
+ && strchr (++p, ':') == NULL) { /* IPv4:port or host:port */
+ virtual_port = atoi (p);
+ /* cut off the port */
+ host_name_length = strlen (host_name) - strlen (p) - 1;
+ free (host_name);
+ host_name = strndup (optarg, host_name_length);
+ if (specify_port == FALSE)
+ server_port = virtual_port;
+ }
break;
case 'I': /* Server IP-address */
server_address = strdup (optarg);
@@ -550,9 +566,12 @@ process_arguments (int argc, char **argv)
if (http_method == NULL)
http_method = strdup ("GET");
- if (client_cert && !client_privkey)
+ if (client_cert && !client_privkey)
usage4 (_("If you use a client certificate you must also specify a private key file"));
+ if (virtual_port == 0)
+ virtual_port = server_port;
+
return TRUE;
}
@@ -922,8 +941,8 @@ check_http (void)
elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
if (check_cert == TRUE) {
result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
- np_net_ssl_cleanup();
if (sd) close(sd);
+ np_net_ssl_cleanup();
return result;
}
}
@@ -958,13 +977,13 @@ check_http (void)
* 14.23). Some server applications/configurations cause trouble if the
* (default) port is explicitly specified in the "Host:" header line.
*/
- if ((use_ssl == FALSE && server_port == HTTP_PORT) ||
- (use_ssl == TRUE && server_port == HTTPS_PORT) ||
+ if ((use_ssl == FALSE && virtual_port == HTTP_PORT) ||
+ (use_ssl == TRUE && virtual_port == HTTPS_PORT) ||
(server_address != NULL && strcmp(http_method, "CONNECT") == 0
&& host_name != NULL && use_ssl == TRUE))
xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
else
- xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port);
+ xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port);
}
}
@@ -1022,6 +1041,10 @@ check_http (void)
microsec_firstbyte = deltime (tv_temp);
elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6;
}
+ while (pos = memchr(buffer, '\0', i)) {
+ /* replace nul character with a blank */
+ *pos = ' ';
+ }
buffer[i] = '\0';
xasprintf (&full_page_new, "%s%s", full_page, buffer);
free (full_page);
@@ -1063,10 +1086,10 @@ check_http (void)
die (STATE_CRITICAL, _("HTTP CRITICAL - No data received from host\n"));
/* close the connection */
+ if (sd) close(sd);
#ifdef HAVE_SSL
np_net_ssl_cleanup();
#endif
- if (sd) close(sd);
/* Save check time */
microsec = deltime (tv);
@@ -1421,6 +1444,9 @@ redir (char *pos, char *status_line)
MAX_PORT, server_type, server_address, server_port, server_url,
display_html ? "</A>" : "");
+ /* reset virtual port */
+ virtual_port = server_port;
+
if (verbose)
printf (_("Redirection to %s://%s:%d%s\n"), server_type,
host_name ? host_name : server_address, server_port, server_url);
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c
index 8d540ca1..46621318 100644
--- a/plugins/check_ide_smart.c
+++ b/plugins/check_ide_smart.c
@@ -166,7 +166,6 @@ enum SmartCommand
char *get_offline_text (int);
int smart_read_values (int, values_t *);
-int values_not_passed (values_t *, thresholds_t *);
int nagios (values_t *, thresholds_t *);
void print_value (value_t *, threshold_t *);
void print_values (values_t *, thresholds_t *);
@@ -340,31 +339,6 @@ smart_read_values (int fd, values_t * values)
int
-values_not_passed (values_t * p, thresholds_t * t)
-{
- value_t * value = p->values;
- threshold_t * threshold = t->thresholds;
- int failed = 0;
- int passed = 0;
- int i;
- for (i = 0; i < NR_ATTRIBUTES; i++) {
- if (value->id && threshold->id && value->id == threshold->id) {
- if (value->value < threshold->threshold) {
- ++failed;
- }
- else {
- ++passed;
- }
- }
- ++value;
- ++threshold;
- }
- return (passed ? -failed : 2);
-}
-
-
-
-int
nagios (values_t * p, thresholds_t * t)
{
value_t * value = p->values;
diff --git a/plugins/check_load.c b/plugins/check_load.c
index a96435f4..b1cc498f 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -160,7 +160,7 @@ main (int argc, char **argv)
sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
}
else {
- printf (_("could not parse load from uptime: %s\n"), result, PATH_TO_UPTIME);
+ printf (_("could not parse load from uptime %s: %s\n"), PATH_TO_UPTIME, result);
return STATE_UNKNOWN;
}
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 75efc289..5ac6c65b 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -297,7 +297,7 @@ void setup_request(ntp_message *p){
* this is done by filtering servers based on stratum, dispersion, and
* finally round-trip delay. */
int best_offset_server(const ntp_server_results *slist, int nservers){
- int i=0, cserver=0, best_server=-1;
+ int cserver=0, best_server=-1;
/* for each server */
for(cserver=0; cserver<nservers; cserver++){
@@ -356,7 +356,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
* we have to do it in a way that our lazy macros don't handle currently :( */
double offset_request(const char *host, int *status){
int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
- int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
+ int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
time_t now_time=0, start_ts=0;
ntp_message *req=NULL;
double avg_offset=0.;
@@ -421,7 +421,6 @@ double offset_request(const char *host, int *status){
* been touched in the past second or so and is still lacking
* some responses. for each of these servers, send a new request,
* and update the "waiting" timestamp with the current time. */
- one_written=0;
now_time=time(NULL);
for(i=0; i<num_hosts; i++){
@@ -431,7 +430,6 @@ double offset_request(const char *host, int *status){
setup_request(&req[i]);
write(socklist[i], &req[i], sizeof(ntp_message));
servers[i].waiting=now_time;
- one_written=1;
break;
}
}
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index 295f86f6..391b2df2 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -244,7 +244,7 @@ void setup_request(ntp_message *p){
* this is done by filtering servers based on stratum, dispersion, and
* finally round-trip delay. */
int best_offset_server(const ntp_server_results *slist, int nservers){
- int i=0, cserver=0, best_server=-1;
+ int cserver=0, best_server=-1;
/* for each server */
for(cserver=0; cserver<nservers; cserver++){
@@ -303,7 +303,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
* we have to do it in a way that our lazy macros don't handle currently :( */
double offset_request(const char *host, int *status){
int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
- int servers_completed=0, one_written=0, one_read=0, servers_readable=0, best_index=-1;
+ int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
time_t now_time=0, start_ts=0;
ntp_message *req=NULL;
double avg_offset=0.;
@@ -368,7 +368,6 @@ double offset_request(const char *host, int *status){
* been touched in the past second or so and is still lacking
* some responses. For each of these servers, send a new request,
* and update the "waiting" timestamp with the current time. */
- one_written=0;
now_time=time(NULL);
for(i=0; i<num_hosts; i++){
@@ -378,7 +377,6 @@ double offset_request(const char *host, int *status){
setup_request(&req[i]);
write(socklist[i], &req[i], sizeof(ntp_message));
servers[i].waiting=now_time;
- one_written=1;
break;
}
}
@@ -635,7 +633,7 @@ 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", _("--time-offset is useful for compensating for servers with known"));
printf(" %s\n", _("and expected clock skew."));
printf("\n");
printf(UT_THRESHOLDS_NOTES);
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 03cbb8b0..b3b8c829 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -36,7 +36,9 @@ const char *email = "devel@monitoring-plugins.org";
#include "utils.h"
#include "netutils.h"
-#if defined(HAVE_LIBFREERADIUS_CLIENT)
+#if defined(HAVE_LIBRADCLI)
+#include <radcli/radcli.h>
+#elif defined(HAVE_LIBFREERADIUS_CLIENT)
#include <freeradius-client.h>
#elif defined(HAVE_LIBRADIUSCLIENT_NG)
#include <radiusclient-ng.h>
@@ -48,22 +50,24 @@ int process_arguments (int, char **);
void print_help (void);
void print_usage (void);
-#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
+#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
#define my_rc_conf_str(a) rc_conf_str(rch,a)
+#if defined(HAVE_LIBRADCLI)
+#define my_rc_send_server(a,b) rc_send_server(rch,a,b,AUTH)
+#else
#define my_rc_send_server(a,b) rc_send_server(rch,a,b)
-#ifdef HAVE_LIBFREERADIUS_CLIENT
+#endif
+#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADCLI)
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f)
#else
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
#endif
-#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
#else
#define my_rc_conf_str(a) rc_conf_str(a)
#define my_rc_send_server(a,b) rc_send_server(a, b)
#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(a,b,c,d,e,f)
-#define my_rc_own_ipaddress() rc_own_ipaddress()
#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(a, b, c, d)
#define my_rc_read_dictionary(a) rc_read_dictionary(a)
#endif
@@ -76,7 +80,7 @@ void print_usage (void);
int my_rc_read_config(char *);
-#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
+#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
rc_handle *rch = NULL;
#endif
@@ -90,7 +94,6 @@ char *config_file = NULL;
unsigned short port = PW_AUTH_UDP_PORT;
int retries = 1;
int verbose = FALSE;
-ENV *env = NULL;
/******************************************************************************
@@ -150,6 +153,8 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
int
main (int argc, char **argv)
{
+ struct sockaddr_storage ss;
+ char name[HOST_NAME_MAX];
char msg[BUFFER_LEN];
SEND_DATA data;
int result = STATE_UNKNOWN;
@@ -185,15 +190,14 @@ main (int argc, char **argv)
die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
}
- if (nasipaddress != NULL) {
- if (rc_good_ipaddr (nasipaddress))
- die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
- if ((client_id = rc_get_ipaddr(nasipaddress)) == 0)
- die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
- } else {
- if ((client_id = my_rc_own_ipaddress ()) == 0)
- die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
+ if (nasipaddress == NULL) {
+ if (gethostname (name, sizeof(name)) != 0)
+ die (STATE_UNKNOWN, _("gethostname() failed!\n"));
+ nasipaddress = name;
}
+ if (!dns_lookup (nasipaddress, &ss, AF_INET)) /* TODO: Support IPv6. */
+ die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
+ client_id = ntohl (((struct sockaddr_in *)&ss)->sin_addr.s_addr);
if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
@@ -399,7 +403,7 @@ print_usage (void)
int my_rc_read_config(char * a)
{
-#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
+#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG) || defined(HAVE_LIBRADCLI)
rch = rc_read_config(a);
return (rch == NULL) ? 1 : 0;
#else
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 1996c6d3..587a7245 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -59,10 +59,6 @@ enum {
#define SMTP_STARTTLS "STARTTLS\r\n"
#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
-#ifndef HOST_MAX_BYTES
-#define HOST_MAX_BYTES 255
-#endif
-
#define EHLO_SUPPORTS_STARTTLS 1
int process_arguments (int, char **);
@@ -239,8 +235,8 @@ main (int argc, char **argv)
result = np_net_ssl_init(sd);
if(result != STATE_OK) {
printf (_("CRITICAL - Cannot create SSL context.\n"));
- np_net_ssl_cleanup();
close(sd);
+ np_net_ssl_cleanup();
return STATE_CRITICAL;
} else {
ssl_established = 1;
@@ -764,10 +760,12 @@ recvlines(char *buf, size_t bufsize)
int
my_close (void)
{
+ int result;
+ result = close(sd);
#ifdef HAVE_SSL
- np_net_ssl_cleanup();
+ np_net_ssl_cleanup();
#endif
- return close(sd);
+ return result;
}
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 9839d6e8..da9638c4 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -152,7 +152,7 @@ state_data *previous_state;
double *previous_value;
size_t previous_size = OID_COUNT_STEP;
int perf_labels = 1;
-
+char* ip_version = "";
static char *fix_snmp_range(char *th)
{
@@ -680,6 +680,8 @@ process_arguments (int argc, char **argv)
{"offset", required_argument, 0, L_OFFSET},
{"invert-search", no_argument, 0, L_INVERT_SEARCH},
{"perf-oids", no_argument, 0, 'O'},
+ {"ipv4", no_argument, 0, '4'},
+ {"ipv6", no_argument, 0, '6'},
{0, 0, 0, 0}
};
@@ -697,7 +699,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
- c = getopt_long (argc, argv, "nhvVOt:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:",
+ c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:",
longopts, &option);
if (c == -1 || c == EOF)
@@ -922,6 +924,13 @@ process_arguments (int argc, char **argv)
case 'O':
perf_labels=0;
break;
+ case '4':
+ break;
+ case '6':
+ xasprintf(&ip_version, "udp6:");
+ if(verbose>2)
+ printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
+ break;
}
}
@@ -1127,6 +1136,7 @@ print_help (void)
printf (UT_HELP_VRSN);
printf (UT_EXTRA_OPTS);
+ printf (UT_IPv46);
printf (UT_HOST_PORT, 'p', DEFAULT_PORT);
@@ -1245,5 +1255,5 @@ print_usage (void)
printf ("[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]\n");
printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
- printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd]\n");
+ printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 6dc9aa96..61333bd7 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -247,8 +247,8 @@ main (int argc, char **argv)
}
}
if(result != STATE_OK){
- np_net_ssl_cleanup();
if(sd) close(sd);
+ np_net_ssl_cleanup();
return result;
}
#endif /* HAVE_SSL */
@@ -321,10 +321,10 @@ main (int argc, char **argv)
if (server_quit != NULL) {
my_send(server_quit, strlen(server_quit));
}
+ if (sd) close (sd);
#ifdef HAVE_SSL
np_net_ssl_cleanup();
#endif
- if (sd) close (sd);
microsec = deltime (tv);
elapsed_time = (double)microsec / 1.0e6;
diff --git a/plugins/check_users.c b/plugins/check_users.c
index 54415a48..f6f4b362 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -54,15 +54,15 @@ int process_arguments (int, char **);
void print_help (void);
void print_usage (void);
-int wusers = -1;
-int cusers = -1;
+char *warning_range = NULL;
+char *critical_range = NULL;
+thresholds *thlds = NULL;
int
main (int argc, char **argv)
{
int users = -1;
int result = STATE_UNKNOWN;
- char *perf;
#if HAVE_WTSAPI32_H
WTS_SESSION_INFO *wtsinfo;
DWORD wtscount;
@@ -77,8 +77,6 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- perf = strdup ("");
-
/* Parse extra opts if any */
argv = np_extra_opts (&argc, argv, progname);
@@ -160,23 +158,15 @@ main (int argc, char **argv)
#endif
/* check the user count against warning and critical thresholds */
- if (users > cusers)
- result = STATE_CRITICAL;
- else if (users > wusers)
- result = STATE_WARNING;
- else if (users >= 0)
- result = STATE_OK;
+ result = get_status((double)users, thlds);
if (result == STATE_UNKNOWN)
printf ("%s\n", _("Unable to read output"));
else {
- xasprintf (&perf, "%s", perfdata ("users", users, "",
- TRUE, wusers,
- TRUE, cusers,
- TRUE, 0,
- FALSE, 0));
- printf (_("USERS %s - %d users currently logged in |%s\n"), state_text (result),
- users, perf);
+ printf (_("USERS %s - %d users currently logged in |%s\n"),
+ state_text(result), users,
+ sperfdata_int("users", users, "", warning_range,
+ critical_range, TRUE, 0, FALSE, 0));
}
return result;
@@ -215,33 +205,27 @@ process_arguments (int argc, char **argv)
print_revision (progname, NP_VERSION);
exit (STATE_UNKNOWN);
case 'c': /* critical */
- if (!is_intnonneg (optarg))
- usage4 (_("Critical threshold must be a positive integer"));
- else
- cusers = atoi (optarg);
+ critical_range = optarg;
break;
case 'w': /* warning */
- if (!is_intnonneg (optarg))
- usage4 (_("Warning threshold must be a positive integer"));
- else
- wusers = atoi (optarg);
+ warning_range = optarg;
break;
}
}
c = optind;
- if (wusers == -1 && argc > c) {
- if (is_intnonneg (argv[c]) == FALSE)
- usage4 (_("Warning threshold must be a positive integer"));
- else
- wusers = atoi (argv[c++]);
- }
- if (cusers == -1 && argc > c) {
- if (is_intnonneg (argv[c]) == FALSE)
- usage4 (_("Warning threshold must be a positive integer"));
- else
- cusers = atoi (argv[c]);
- }
+ if (warning_range == NULL && argc > c)
+ warning_range = argv[c++];
+ if (critical_range == NULL && argc > c)
+ critical_range = argv[c++];
+
+ /* this will abort in case of invalid ranges */
+ set_thresholds (&thlds, warning_range, critical_range);
+
+ if (thlds->warning->end < 0)
+ usage4 (_("Warning threshold must be a positive integer"));
+ if (thlds->critical->end < 0)
+ usage4 (_("Critical threshold must be a positive integer"));
return OK;
}
diff --git a/plugins/common.h b/plugins/common.h
index 01003b3b..8719b502 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -161,6 +161,13 @@
# endif
#endif
+/* openssl 1.1 does not set OPENSSL_NO_SSL2 by default but ships without ssl2 */
+#ifdef OPENSSL_VERSION_NUMBER
+# if OPENSSL_VERSION_NUMBER >= 0x10100000
+# define OPENSSL_NO_SSL2
+# endif
+#endif
+
/*
*
* Standard Values
diff --git a/plugins/negate.c b/plugins/negate.c
index beaed1ea..b320e356 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -59,8 +59,8 @@ static int state[4] = {
int
main (int argc, char **argv)
{
- int found = 0, result = STATE_UNKNOWN;
- char *buf, *sub;
+ int result = STATE_UNKNOWN;
+ char *sub;
char **command_line;
output chld_out, chld_err;
int i;
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 705aaf09..1bb4f076 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -359,20 +359,21 @@ is_addr (const char *address)
}
int
-resolve_host_or_addr (const char *address, int family)
+dns_lookup (const char *in, struct sockaddr_storage *ss, int family)
{
struct addrinfo hints;
struct addrinfo *res;
int retval;
- memset (&hints, 0, sizeof (hints));
+ memset (&hints, 0, sizeof(struct addrinfo));
hints.ai_family = family;
- retval = getaddrinfo (address, NULL, &hints, &res);
+ retval = getaddrinfo (in, NULL, &hints, &res);
if (retval != 0)
return FALSE;
- else {
- freeaddrinfo (res);
- return TRUE;
- }
+
+ if (ss != NULL)
+ memcpy (ss, res->ai_addr, res->ai_addrlen);
+ freeaddrinfo (res);
+ return TRUE;
}
diff --git a/plugins/netutils.h b/plugins/netutils.h
index 2766029e..d7ee0ddd 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -45,6 +45,10 @@
# endif /* UNIX_PATH_MAX */
#endif /* HAVE_SYS_UN_H */
+#ifndef HOST_MAX_BYTES
+# define HOST_MAX_BYTES 255
+#endif
+
/* process_request and wrapper macros */
#define process_tcp_request(addr, port, sbuf, rbuf, rsize) \
process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize)
@@ -71,8 +75,9 @@ int send_request (int sd, int proto, const char *send_buffer, char *recv_buffer,
/* "is_*" wrapper macros and functions */
int is_host (const char *);
int is_addr (const char *);
-int resolve_host_or_addr (const char *, int);
+int 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)
#ifdef USE_IPV6
# define is_inet6_addr(addr) resolve_host_or_addr(addr, AF_INET6)
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 4f9c793c..b412ef3d 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -197,6 +197,7 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
X509_NAME *subj=NULL;
char timestamp[50] = "";
char cn[MAX_CN_LENGTH]= "";
+ char *tz;
int cnlen =-1;
int status=STATE_UNKNOWN;
@@ -264,10 +265,18 @@ int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
(tm->data[10 + offset] - '0') * 10 + (tm->data[11 + offset] - '0');
stamp.tm_isdst = -1;
- time_left = difftime(timegm(&stamp), time(NULL));
+ tm_t = timegm(&stamp);
+ time_left = difftime(tm_t, time(NULL));
days_left = time_left / 86400;
- tm_t = mktime (&stamp);
- strftime(timestamp, 50, "%c", localtime(&tm_t));
+ tz = getenv("TZ");
+ setenv("TZ", "GMT", 1);
+ tzset();
+ strftime(timestamp, 50, "%c %z", localtime(&tm_t));
+ if (tz)
+ setenv("TZ", tz, 1);
+ else
+ unsetenv("TZ");
+ tzset();
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);
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis
index fe8aabdb..5d9c5ff7 100644
--- a/plugins/t/NPTest.cache.travis
+++ b/plugins/t/NPTest.cache.travis
@@ -11,7 +11,7 @@
'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
'NP_HOST_RESPONSIVE' => 'localhost',
'NP_HOST_SMB' => '',
- 'NP_HOST_SNMP' => '',
+ 'NP_HOST_SNMP' => 'localhost',
'NP_HOST_TCP_FTP' => '',
'NP_HOST_TCP_HPJD' => '',
'NP_HOST_HPJD_PORT_INVALID' => '161',
@@ -39,7 +39,7 @@
'NP_SMB_SHARE_SPC' => '',
'NP_SMB_VALID_USER' => '',
'NP_SMB_VALID_USER_PASS' => '',
- 'NP_SNMP_COMMUNITY' => '',
+ 'NP_SNMP_COMMUNITY' => 'public',
'NP_SSH_CONFIGFILE' => '~/.ssh/config',
'NP_SSH_HOST' => 'localhost',
'NP_SSH_IDENTITY' => '~/.ssh/id_dsa',
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index 2b906e30..5a90f02a 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
use POSIX qw/mktime strftime/;
use NPTest;
-plan tests => 42;
+plan tests => 49;
my $successOutput = '/OK.*HTTP.*second/';
@@ -64,6 +64,32 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
# Is also possible to get a socket timeout if DNS is not responding fast enough
like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
+# host header checks
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http");
+like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
+
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http -p 80");
+like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
+
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
+like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
+
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
+like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
+
+SKIP: {
+ skip "No internet access", 3 if $internet_access eq "no";
+
+ $res = NPTest->testCmd("./check_http -v -H www.verisign.com -S");
+ like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
+
+ $res = NPTest->testCmd("./check_http -v -H www.verisign.com:8080 -S -p 443");
+ like( $res->output, '/^Host: www.verisign.com:8080\s*$/ms', "Host Header OK" );
+
+ $res = NPTest->testCmd("./check_http -v -H www.verisign.com:443 -S -p 443");
+ like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
+};
+
SKIP: {
skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
@@ -121,9 +147,9 @@ SKIP: {
$res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com");
like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output");
is( $res->return_code, 0, "Catch cert output exit code" );
- my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)\./);
+ my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
if(!defined $year) {
- die("parsing date failed from: ".$res);
+ die("parsing date failed from: ".$res->output);
}
my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index aefd872a..eff46ea1 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -10,7 +10,7 @@ use NPTest;
BEGIN {
plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp";
- plan tests => 61;
+ plan tests => 63;
}
my $res;
@@ -45,7 +45,7 @@ is( $res->return_code, 3, "Invalid protocol" );
like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
SKIP: {
- skip "no snmp host defined", 48 if ( ! $host_snmp );
+ skip "no snmp host defined", 50 if ( ! $host_snmp );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
@@ -153,6 +153,10 @@ SKIP: {
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0");
cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
+
+ $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunParameters.1");
+ cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
+ is( $res->output, 'SNMP OK - "" | ', "snmp response without datatype" );
}
SKIP: {
diff --git a/plugins/t/check_users.t b/plugins/t/check_users.t
index 39044bb5..088f3b52 100644
--- a/plugins/t/check_users.t
+++ b/plugins/t/check_users.t
@@ -13,7 +13,7 @@ use Test;
use NPTest;
use vars qw($tests);
-BEGIN {$tests = 4; plan tests => $tests}
+BEGIN {$tests = 8; plan tests => $tests}
my $successOutput = '/^USERS OK - [0-9]+ users currently logged in/';
my $failureOutput = '/^USERS CRITICAL - [0-9]+ users currently logged in/';
@@ -22,6 +22,8 @@ my $t;
$t += checkCmd( "./check_users 1000 1000", 0, $successOutput );
$t += checkCmd( "./check_users 0 0", 2, $failureOutput );
+$t += checkCmd( "./check_users -w 0:1000 -c 0:1000", 0, $successOutput );
+$t += checkCmd( "./check_users -w 0:0 -c 0:0", 2, $failureOutput );
exit(0) if defined($Test::Harness::VERSION);
exit($tests - $t);
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index e72d243a..1bc0ecb7 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -17,6 +17,8 @@ use Test::More;
use NPTest;
use FindBin qw($Bin);
+$ENV{'LC_TIME'} = "C";
+
my $common_tests = 70;
my $ssl_only_tests = 8;
# Check that all dependent modules are available
@@ -186,21 +188,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 Sun Mar 3 21:41:28 2019.', "output ok" );
+ is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019 +0000.', "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\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" );
+ like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "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\) \(Sun Mar 3 21:41:28 2019\)./', "output ok" );
+ like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "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 Thu Mar 5 00:13:16 2009.',
+ 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009 +0000.',
"output ok" );
}
diff --git a/plugins/utils.c b/plugins/utils.c
index a864e4aa..231af92b 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -668,3 +668,44 @@ char *sperfdata (const char *label,
return data;
}
+
+char *sperfdata_int (const char *label,
+ int val,
+ const char *uom,
+ char *warn,
+ char *crit,
+ int minp,
+ int minv,
+ int maxp,
+ int maxv)
+{
+ char *data = NULL;
+ if (strpbrk (label, "'= "))
+ xasprintf (&data, "'%s'=", label);
+ else
+ xasprintf (&data, "%s=", label);
+
+ xasprintf (&data, "%s%d", data, val);
+ xasprintf (&data, "%s%s;", data, uom);
+
+ if (warn!=NULL)
+ xasprintf (&data, "%s%s", data, warn);
+
+ xasprintf (&data, "%s;", data);
+
+ if (crit!=NULL)
+ xasprintf (&data, "%s%s", data, crit);
+
+ xasprintf (&data, "%s;", data);
+
+ if (minp)
+ xasprintf (&data, "%s%d", data, minv);
+
+ if (maxp) {
+ xasprintf (&data, "%s;", data);
+ xasprintf (&data, "%s%d", data, maxv);
+ }
+
+ return data;
+}
+
diff --git a/plugins/utils.h b/plugins/utils.h
index 4c4aaccc..a436e1ca 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -94,29 +94,17 @@ const char *state_text (int);
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
-char *perfdata (const char *,
- long int,
- const char *,
- int,
- long int,
- int,
- long int,
- int,
- long int,
- int,
- long int);
-
-char *fperfdata (const char *,
- double,
- const char *,
- int,
- double,
- int,
- double,
- int,
- double,
- int,
- double);
+char *perfdata (const char *, long int, const char *, int, long int,
+ int, long int, int, long int, int, long int);
+
+char *fperfdata (const char *, double, const char *, int, double,
+ int, double, int, double, int, double);
+
+char *sperfdata (const char *, double, const char *, char *, char *,
+ int, double, int, double);
+
+char *sperfdata_int (const char *, int, const char *, char *, char *,
+ int, int, int, int);
/* The idea here is that, although not every plugin will use all of these,
most will or should. Therefore, for consistency, these very common