New upstream version 2.3

This commit is contained in:
Jan Wagner 2020-12-10 21:00:09 +01:00
parent c845af032a
commit 5c6ba24b61
129 changed files with 14313 additions and 2999 deletions

View file

@ -54,8 +54,10 @@ host_triplet = @host@
subdir = lib
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -943,6 +945,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1068,6 +1075,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1285,6 +1293,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1295,6 +1308,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View file

@ -57,8 +57,10 @@ EXTRA_PROGRAMS = test_utils$(EXEEXT) test_disk$(EXEEXT) \
subdir = lib/tests
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/gl/m4/00gnulib.m4 $(top_srcdir)/gl/m4/alloca.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/libcurl.m4 \
$(top_srcdir)/m4/np_mysqlclient.m4 \
$(top_srcdir)/m4/uriparser.m4 $(top_srcdir)/gl/m4/00gnulib.m4 \
$(top_srcdir)/gl/m4/alloca.m4 \
$(top_srcdir)/gl/m4/arpa_inet_h.m4 \
$(top_srcdir)/gl/m4/base64.m4 $(top_srcdir)/gl/m4/btowc.m4 \
$(top_srcdir)/gl/m4/codeset.m4 \
@ -951,6 +953,11 @@ LD = @LD@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBCURL = @LIBCURL@
LIBCURLCFLAGS = @LIBCURLCFLAGS@
LIBCURLINCLUDE = @LIBCURLINCLUDE@
LIBCURLLIBS = @LIBCURLLIBS@
LIBCURL_CPPFLAGS = @LIBCURL_CPPFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBICONV = @LIBICONV@
@ -1076,6 +1083,7 @@ PERL = @PERL@
PERLMODS_DIR = @PERLMODS_DIR@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKGCONFIG = @PKGCONFIG@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
@ -1293,6 +1301,11 @@ TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
URIPARSER = @URIPARSER@
URIPARSERCFLAGS = @URIPARSERCFLAGS@
URIPARSERINCLUDE = @URIPARSERINCLUDE@
URIPARSERLIBS = @URIPARSERLIBS@
URIPARSER_CPPFLAGS = @URIPARSER_CPPFLAGS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
@ -1303,6 +1316,7 @@ WTSAPI32LIBS = @WTSAPI32LIBS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
_libcurl_config = @_libcurl_config@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@

View file

@ -37,6 +37,9 @@
monitoring_plugin *this_monitoring_plugin=NULL;
unsigned int timeout_state = STATE_CRITICAL;
unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
int _np_state_read_file(FILE *);
void np_init( char *plugin_name, int argc, char **argv ) {
@ -87,10 +90,13 @@ void _get_monitoring_plugin( monitoring_plugin **pointer ){
void
die (int result, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
vprintf (fmt, ap);
va_end (ap);
if(fmt!=NULL) {
va_list ap;
va_start (ap, fmt);
vprintf (fmt, ap);
va_end (ap);
}
if(this_monitoring_plugin!=NULL) {
np_cleanup();
}
@ -356,6 +362,22 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
return value;
}
const char *
state_text (int result)
{
switch (result) {
case STATE_OK:
return "OK";
case STATE_WARNING:
return "WARNING";
case STATE_CRITICAL:
return "CRITICAL";
case STATE_DEPENDENT:
return "DEPENDENT";
default:
return "UNKNOWN";
}
}
/*
* Read a string representing a state (ok, warning... or numeric: 0, 1) and

View file

@ -61,6 +61,10 @@ void print_thresholds(const char *, thresholds *);
int check_range(double, range *);
int get_status(double, thresholds *);
/* Handle timeouts */
extern unsigned int timeout_state;
extern unsigned int timeout_interval;
/* All possible characters in a threshold range */
#define NP_THRESHOLDS_CHARS "-0123456789.:@~"
@ -107,5 +111,6 @@ void np_state_write_string(time_t, char *);
void np_init(char *, int argc, char **argv);
void np_set_args(int argc, char **argv);
void np_cleanup();
const char *state_text (int);
#endif /* _UTILS_BASE_ */

View file

@ -40,6 +40,7 @@
/** includes **/
#include "common.h"
#include "utils.h"
#include "utils_cmd.h"
#include "utils_base.h"
#include <fcntl.h>
@ -65,31 +66,6 @@ extern char **environ;
# define SIG_ERR ((Sigfunc *)-1)
#endif
/* This variable must be global, since there's no way the caller
* can forcibly slay a dead or ungainly running program otherwise.
* Multithreading apps and plugins can initialize it (via CMD_INIT)
* in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
* for the first time.
*
* The check for initialized values is atomic and can
* occur in any number of threads simultaneously. */
static pid_t *_cmd_pids = NULL;
/* Try sysconf(_SC_OPEN_MAX) first, as it can be higher than OPEN_MAX.
* If that fails and the macro isn't defined, we fall back to an educated
* guess. There's no guarantee that our guess is adequate and the program
* will die with SIGSEGV if it isn't and the upper boundary is breached. */
#define DEFAULT_MAXFD 256 /* fallback value if no max open files value is set */
#define MAXFD_LIMIT 8192 /* upper limit of open files */
#ifdef _SC_OPEN_MAX
static long maxfd = 0;
#elif defined(OPEN_MAX)
# define maxfd OPEN_MAX
#else /* sysconf macro unavailable, so guess (may be wildly inaccurate) */
# define maxfd DEFAULT_MAXFD
#endif
/** prototypes **/
static int _cmd_open (char *const *, int *, int *)
__attribute__ ((__nonnull__ (1, 2, 3)));
@ -406,3 +382,19 @@ cmd_file_read ( char *filename, output *out, int flags)
return 0;
}
void
timeout_alarm_handler (int signo)
{
size_t i;
if (signo == SIGALRM) {
printf (_("%s - Plugin timed out after %d seconds\n"),
state_text(timeout_state), timeout_interval);
if(_cmd_pids) for(i = 0; i < maxfd; i++) {
if(_cmd_pids[i] != 0) kill(_cmd_pids[i], SIGKILL);
}
exit (timeout_state);
}
}

View file

@ -32,4 +32,17 @@ void cmd_init (void);
#define CMD_NO_ARRAYS 0x01 /* don't populate arrays at all */
#define CMD_NO_ASSOC 0x02 /* output.line won't point to buf */
/* This variable must be global, since there's no way the caller
* can forcibly slay a dead or ungainly running program otherwise.
* Multithreading apps and plugins can initialize it (via CMD_INIT)
* in an async safe manner PRIOR to calling cmd_run() or cmd_run_array()
* for the first time.
*
* The check for initialized values is atomic and can
* occur in any number of threads simultaneously. */
static pid_t *_cmd_pids = NULL;
RETSIGTYPE timeout_alarm_handler (int);
#endif /* _UTILS_CMD_ */

View file

@ -69,6 +69,8 @@ np_add_parameter(struct parameter_list **list, const char *name)
new_path->dtotal_units = 0;
new_path->inodes_total = 0;
new_path->inodes_free = 0;
new_path->inodes_free_to_root = 0;
new_path->inodes_used = 0;
new_path->dused_inodes_percent = 0;
new_path->dfree_inodes_percent = 0;

View file

@ -24,7 +24,8 @@ struct parameter_list
char *group;
struct mount_entry *best_match;
struct parameter_list *name_next;
uintmax_t total, available, available_to_root, used, inodes_free, inodes_total;
uintmax_t total, available, available_to_root, used,
inodes_free, inodes_free_to_root, inodes_used, inodes_total;
double dfree_pct, dused_pct;
double dused_units, dfree_units, dtotal_units;
double dused_inodes_percent, dfree_inodes_percent;