summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--configure.ac6
-rw-r--r--plugins/Makefile.am2
-rw-r--r--plugins/check_disk.c43
4 files changed, 51 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 70ee659..a923e82 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ This file documents the major additions and syntax changes between releases.
6 thresholds 6 thresholds
7 New check_snmp "-N" option to specify SNMPv3 context name 7 New check_snmp "-N" option to specify SNMPv3 context name
8 New check_nt "-l" parameters: seconds|minutes|hours|days 8 New check_nt "-l" parameters: seconds|minutes|hours|days
9 Make sure check_disk won't hang on hanging (network) file systems
9 10
10 FIXES 11 FIXES
11 Let check_real terminate lines with CRLF when talking to the server, as 12 Let check_real terminate lines with CRLF when talking to the server, as
diff --git a/configure.ac b/configure.ac
index a6c9e79..fb8f950 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,12 @@ AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
156AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv") 156AC_CHECK_LIB(resolv,main,SOCKETLIBS="$SOCKETLIBS -lresolv")
157AC_SUBST(SOCKETLIBS) 157AC_SUBST(SOCKETLIBS)
158 158
159dnl Check for POSIX thread libraries
160AC_CHECK_HEADERS(pthread.h)
161AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="-lpthread",
162 AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="-lpthread -lrt",-lrt))
163AC_SUBST(THREADLIBS)
164
159dnl 165dnl
160dnl check for math-related functions needing -lm 166dnl check for math-related functions needing -lm
161AC_CHECK_HEADERS(math.h) 167AC_CHECK_HEADERS(math.h)
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 0ddf9bd..41906c5 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -71,7 +71,7 @@ check_apt_LDADD = $(BASEOBJS)
71check_cluster_LDADD = $(BASEOBJS) 71check_cluster_LDADD = $(BASEOBJS)
72check_dbi_LDADD = $(NETLIBS) $(DBILIBS) 72check_dbi_LDADD = $(NETLIBS) $(DBILIBS)
73check_dig_LDADD = $(NETLIBS) 73check_dig_LDADD = $(NETLIBS)
74check_disk_LDADD = $(BASEOBJS) 74check_disk_LDADD = $(BASEOBJS) $(THREADLIBS)
75check_dns_LDADD = $(NETLIBS) 75check_dns_LDADD = $(NETLIBS)
76check_dummy_LDADD = $(BASEOBJS) 76check_dummy_LDADD = $(BASEOBJS)
77check_fping_LDADD = $(NETLIBS) 77check_fping_LDADD = $(NETLIBS)
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 0d73a4f..eb573f5 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -51,6 +51,9 @@ const char *email = "devel@monitoring-plugins.org";
51# include <limits.h> 51# include <limits.h>
52#endif 52#endif
53#include "regex.h" 53#include "regex.h"
54#if HAVE_PTHREAD_H
55# include <pthread.h>
56#endif
54 57
55#ifdef __CYGWIN__ 58#ifdef __CYGWIN__
56# include <windows.h> 59# include <windows.h>
@@ -130,6 +133,7 @@ void print_help (void);
130void print_usage (void); 133void print_usage (void);
131double calculate_percent(uintmax_t, uintmax_t); 134double calculate_percent(uintmax_t, uintmax_t);
132void stat_path (struct parameter_list *p); 135void stat_path (struct parameter_list *p);
136void *do_stat_path (void *p);
133void get_stats (struct parameter_list *p, struct fs_usage *fsp); 137void get_stats (struct parameter_list *p, struct fs_usage *fsp);
134void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); 138void get_path_stats (struct parameter_list *p, struct fs_usage *fsp);
135 139
@@ -968,6 +972,44 @@ print_usage (void)
968void 972void
969stat_path (struct parameter_list *p) 973stat_path (struct parameter_list *p)
970{ 974{
975#ifdef HAVE_PTHREAD_H
976 pthread_t stat_thread;
977 int statdone = 0;
978 int timer = timeout_interval;
979 struct timespec req, rem;
980
981 req.tv_sec = 0;
982 pthread_create(&stat_thread, NULL, do_stat_path, p);
983 while (timer-- > 0) {
984 req.tv_nsec = 10000000;
985 nanosleep(&req, &rem);
986 if (pthread_kill(stat_thread, 0)) {
987 statdone = 1;
988 break;
989 } else {
990 req.tv_nsec = 990000000;
991 nanosleep(&req, &rem);
992 }
993 }
994 if (statdone == 1) {
995 pthread_join(stat_thread, NULL);
996 } else {
997 pthread_detach(stat_thread);
998 if (verbose >= 3)
999 printf("stat did not return within %ds on %s\n", timeout_interval, p->name);
1000 printf("DISK %s - ", _("CRITICAL"));
1001 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("hangs"), _("Timeout"));
1002 }
1003#else
1004 do_stat_path(p);
1005#endif
1006}
1007
1008void *
1009do_stat_path (void *in)
1010{
1011 struct parameter_list *p = in;
1012
971 /* Stat entry to check that dir exists and is accessible */ 1013 /* Stat entry to check that dir exists and is accessible */
972 if (verbose >= 3) 1014 if (verbose >= 3)
973 printf("calling stat on %s\n", p->name); 1015 printf("calling stat on %s\n", p->name);
@@ -977,6 +1019,7 @@ stat_path (struct parameter_list *p)
977 printf("DISK %s - ", _("CRITICAL")); 1019 printf("DISK %s - ", _("CRITICAL"));
978 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); 1020 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno));
979 } 1021 }
1022 return NULL;
980} 1023}
981 1024
982 1025