summaryrefslogtreecommitdiffstats
path: root/plugins/check_disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_disk.c')
-rw-r--r--plugins/check_disk.c47
1 files changed, 2 insertions, 45 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index d37cc3a..e73a008 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -51,9 +51,6 @@ 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
57 54
58#ifdef __CYGWIN__ 55#ifdef __CYGWIN__
59# include <windows.h> 56# include <windows.h>
@@ -130,7 +127,6 @@ void print_help (void);
130void print_usage (void); 127void print_usage (void);
131double calculate_percent(uintmax_t, uintmax_t); 128double calculate_percent(uintmax_t, uintmax_t);
132void stat_path (struct parameter_list *p); 129void stat_path (struct parameter_list *p);
133void *do_stat_path (void *p);
134void get_stats (struct parameter_list *p, struct fs_usage *fsp); 130void get_stats (struct parameter_list *p, struct fs_usage *fsp);
135void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); 131void get_path_stats (struct parameter_list *p, struct fs_usage *fsp);
136 132
@@ -761,10 +757,10 @@ process_arguments (int argc, char **argv)
761 break; 757 break;
762 case 'V': /* version */ 758 case 'V': /* version */
763 print_revision (progname, NP_VERSION); 759 print_revision (progname, NP_VERSION);
764 exit (STATE_OK); 760 exit (STATE_UNKNOWN);
765 case 'h': /* help */ 761 case 'h': /* help */
766 print_help (); 762 print_help ();
767 exit (STATE_OK); 763 exit (STATE_UNKNOWN);
768 case '?': /* help */ 764 case '?': /* help */
769 usage (_("Unknown argument")); 765 usage (_("Unknown argument"));
770 } 766 }
@@ -967,44 +963,6 @@ print_usage (void)
967void 963void
968stat_path (struct parameter_list *p) 964stat_path (struct parameter_list *p)
969{ 965{
970#ifdef HAVE_PTHREAD_H
971 pthread_t stat_thread;
972 int statdone = 0;
973 int timer = timeout_interval;
974 struct timespec req, rem;
975
976 req.tv_sec = 0;
977 pthread_create(&stat_thread, NULL, do_stat_path, p);
978 while (timer-- > 0) {
979 req.tv_nsec = 10000000;
980 nanosleep(&req, &rem);
981 if (pthread_kill(stat_thread, 0)) {
982 statdone = 1;
983 break;
984 } else {
985 req.tv_nsec = 990000000;
986 nanosleep(&req, &rem);
987 }
988 }
989 if (statdone == 1) {
990 pthread_join(stat_thread, NULL);
991 } else {
992 pthread_detach(stat_thread);
993 if (verbose >= 3)
994 printf("stat did not return within %ds on %s\n", timeout_interval, p->name);
995 printf("DISK %s - ", _("CRITICAL"));
996 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("hangs"), _("Timeout"));
997 }
998#else
999 do_stat_path(p);
1000#endif
1001}
1002
1003void *
1004do_stat_path (void *in)
1005{
1006 struct parameter_list *p = in;
1007
1008 /* Stat entry to check that dir exists and is accessible */ 966 /* Stat entry to check that dir exists and is accessible */
1009 if (verbose >= 3) 967 if (verbose >= 3)
1010 printf("calling stat on %s\n", p->name); 968 printf("calling stat on %s\n", p->name);
@@ -1014,7 +972,6 @@ do_stat_path (void *in)
1014 printf("DISK %s - ", _("CRITICAL")); 972 printf("DISK %s - ", _("CRITICAL"));
1015 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); 973 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno));
1016 } 974 }
1017 return NULL;
1018} 975}
1019 976
1020 977