diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-03-24 21:40:06 -0400 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-03-24 21:40:06 -0400 |
commit | 386b791af2a5c9d95531d2ca047dd8ffc12bcb2e (patch) | |
tree | 8ee5cd653d314e7e097da9fc5ea26642cd7d7769 | |
parent | ab3ada9aacd82356a6e5205f3ae26bbff55524db (diff) | |
download | monitoring-plugins-386b791af2a5c9d95531d2ca047dd8ffc12bcb2e.tar.gz |
Make socket alarm handler customisable (like c459ca07)
-rw-r--r-- | plugins/netutils.c | 7 | ||||
-rw-r--r-- | plugins/netutils.h | 11 |
2 files changed, 12 insertions, 6 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c index 6082cae0..1d6100ab 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c @@ -32,7 +32,6 @@ #include "common.h" #include "netutils.h" -unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; int econn_refuse_state = STATE_CRITICAL; int was_refused = FALSE; #if USE_IPV6 @@ -46,11 +45,11 @@ void socket_timeout_alarm_handler (int sig) { if (sig == SIGALRM) - printf (_("CRITICAL - Socket timeout after %d seconds\n"), socket_timeout); + printf (_("%s - Socket timeout after %d seconds\n"), state_text(socket_timeout_state), socket_timeout); else - printf (_("CRITICAL - Abnormal timeout after %d seconds\n"), socket_timeout); + printf (_("%s - Abnormal timeout after %d seconds\n"), state_text(socket_timeout_state), socket_timeout); - exit (STATE_CRITICAL); + exit (socket_timeout_state); } diff --git a/plugins/netutils.h b/plugins/netutils.h index 6bc5386c..b479b741 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h @@ -45,8 +45,6 @@ # endif /* UNIX_PATH_MAX */ #endif /* HAVE_SYS_UN_H */ -RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); - /* process_request and wrapper macros */ #define process_tcp_request(addr, port, sbuf, rbuf, rsize) \ process_request(addr, port, IPPROTO_TCP, sbuf, rbuf, rsize) @@ -83,7 +81,16 @@ void host_or_die(const char *str); # define is_hostname(addr) resolve_host_or_addr(addr, AF_INET) #endif +#ifdef LOCAL_TIMEOUT_ALARM_HANDLER extern unsigned int socket_timeout; +extern int socket_timeout_state; +RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); +#else +unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; +unsigned int socket_timeout_state = STATE_CRITICAL; +extern RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); +#endif + extern int econn_refuse_state; extern int was_refused; extern int address_family; |