summaryrefslogtreecommitdiffstats
path: root/web/attachments/38638-patch-nagiosplug-tcp_refusal
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/38638-patch-nagiosplug-tcp_refusal')
-rw-r--r--web/attachments/38638-patch-nagiosplug-tcp_refusal142
1 files changed, 142 insertions, 0 deletions
diff --git a/web/attachments/38638-patch-nagiosplug-tcp_refusal b/web/attachments/38638-patch-nagiosplug-tcp_refusal
new file mode 100644
index 0000000..a7629f2
--- /dev/null
+++ b/web/attachments/38638-patch-nagiosplug-tcp_refusal
@@ -0,0 +1,142 @@
1Index: nagiosplug/plugins/check_tcp.c
2===================================================================
3RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
4retrieving revision 1.10
5diff -u -r1.10 check_tcp.c
6--- nagiosplug/plugins/check_tcp.c 19 Dec 2002 19:30:52 -0000 1.10
7+++ nagiosplug/plugins/check_tcp.c 30 Dec 2002 23:07:44 -0000
8@@ -307,9 +307,11 @@
9 alarm (0);
10
11 printf
12- ("%s %s - %7.3f second response time on port %d",
13+ ("%s %s%s - %7.3f second response time on port %d",
14 SERVICE,
15- state_text (result), elapsed_time, server_port);
16+ state_text (result),
17+ (was_refused)?" (refused)":"",
18+ elapsed_time, server_port);
19
20 if (status && strlen(status) > 0)
21 printf (" [%s]", status);
22@@ -346,6 +348,7 @@
23 {"expect", required_argument, 0, 'e'},
24 {"quit", required_argument, 0, 'q'},
25 {"delay", required_argument, 0, 'd'},
26+ {"refuse", required_argument, 0, 'r'},
27 {"verbose", no_argument, 0, 'v'},
28 {"version", no_argument, 0, 'V'},
29 {"help", no_argument, 0, 'h'},
30@@ -376,10 +379,10 @@
31 while (1) {
32 #ifdef HAVE_GETOPT_H
33 c =
34- getopt_long (argc, argv, "+hVvH:s:e:q:c:w:t:p:C:W:d:S", long_options,
35+ getopt_long (argc, argv, "+hVvH:s:e:q:c:w:t:p:C:W:d:Sr:", long_options,
36 &option_index);
37 #else
38- c = getopt (argc, argv, "+hVvH:s:e:q:c:w:t:p:C:W:d:S");
39+ c = getopt (argc, argv, "+hVvH:s:e:q:c:w:t:p:C:W:d:Sr:");
40 #endif
41
42 if (c == -1 || c == EOF || c == 1)
43@@ -448,6 +451,16 @@
44 case 'q':
45 server_quit = optarg;
46 break;
47+ case 'r':
48+ if (!strncmp(optarg,"ok",2))
49+ econn_refuse_state = STATE_OK;
50+ else if (!strncmp(optarg,"warn",4))
51+ econn_refuse_state = STATE_WARNING;
52+ else if (!strncmp(optarg,"crit",4))
53+ econn_refuse_state = STATE_CRITICAL;
54+ else
55+ usage ("Refuse mut be one of ok, warn, crit\n");
56+ break;
57 case 'd':
58 if (is_intpos (optarg))
59 delay = atoi (optarg);
60@@ -479,7 +492,8 @@
61 {
62 printf
63 ("Usage: %s -H host -p port [-w warn_time] [-c crit_time] [-s send]\n"
64- " [-e expect] [-W wait] [-t to_sec] [-v]\n", PROGNAME);
65+ " [-e expect] [-W wait] [-t to_sec] [-R refuse_state] [-v]\n",
66+ PROGNAME);
67 }
68
69
70@@ -514,6 +528,8 @@
71 " Response time to result in critical status (seconds)\n"
72 " -t, --timeout=INTEGER\n"
73 " Seconds before connection times out (default: %d)\n"
74+ " -r, --refuse=ok|warn|crit\n"
75+ " Accept tcp refusals with states ok,warn, crit (default: crit)\n"
76 " -v"
77 " Show details for command-line debugging (do not use with nagios server)\n"
78 " -h, --help\n"
79@@ -549,7 +565,7 @@
80 time (&start_time);
81
82 /* Make TCP connection */
83- if (my_tcp_connect (server_address, server_port, &sd) == STATE_OK)
84+ if (my_tcp_connect (server_address, server_port, &sd) == STATE_OK && was_refused == FALSE)
85 {
86 /* Do the SSL handshake */
87 if ((ssl = SSL_new (ctx)) != NULL)
88Index: nagiosplug/plugins/netutils.c
89===================================================================
90RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.c,v
91retrieving revision 1.1.1.1
92diff -u -r1.1.1.1 netutils.c
93--- nagiosplug/plugins/netutils.c 28 Feb 2002 06:42:59 -0000 1.1.1.1
94+++ nagiosplug/plugins/netutils.c 30 Dec 2002 23:07:44 -0000
95@@ -39,6 +39,9 @@
96 extern int socket_timeout;
97 RETSIGTYPE socket_timeout_alarm_handler (int);
98
99+extern int econn_refuse_state;
100+extern int was_refused;
101+
102 int process_tcp_request2 (char *, int, char *, char *, int);
103 int process_tcp_request (char *, int, char *, char *, int);
104 int process_udp_request (char *, int, char *, char *, int);
105@@ -307,7 +310,14 @@
106 if (result < 0) {
107 switch (errno) {
108 case ECONNREFUSED:
109- printf ("Connection refused by host\n");
110+ switch (econn_refuse_state) {
111+ case STATE_OK:
112+ case STATE_WARNING:
113+ was_refused = TRUE;
114+ return econn_refuse_state;
115+ default:
116+ printf ("Connection refused by host\n");
117+ }
118 break;
119 case ETIMEDOUT:
120 printf ("Timeout while attempting connection\n");
121@@ -316,7 +326,7 @@
122 printf ("Network is unreachable\n");
123 break;
124 default:
125- printf ("Connection refused or timed out\n");
126+ printf ("Connection refused or timed out: %s\n",strerror (errno));
127 }
128
129 return STATE_CRITICAL;
130Index: nagiosplug/plugins/netutils.h.in
131===================================================================
132RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.h.in,v
133retrieving revision 1.1.1.1
134diff -u -r1.1.1.1 netutils.h.in
135--- nagiosplug/plugins/netutils.h.in 28 Feb 2002 06:42:59 -0000 1.1.1.1
136+++ nagiosplug/plugins/netutils.h.in 30 Dec 2002 23:07:44 -0000
137@@ -61,3 +61,5 @@
138 #include "common.h"
139 #endif
140 int socket_timeout = DEFAULT_SOCKET_TIMEOUT;
141+int econn_refuse_state = STATE_CRITICAL;
142+int was_refused = FALSE;