summaryrefslogtreecommitdiffstats
path: root/plugins/check_udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_udp.c')
-rw-r--r--plugins/check_udp.c125
1 files changed, 71 insertions, 54 deletions
diff --git a/plugins/check_udp.c b/plugins/check_udp.c
index 11b942a4..bd5de586 100644
--- a/plugins/check_udp.c
+++ b/plugins/check_udp.c
@@ -25,56 +25,9 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
25#include "netutils.h" 25#include "netutils.h"
26#include "utils.h" 26#include "utils.h"
27 27
28/* Original Command line:
29 check_udp <host_address> [-p port] [-s send] [-e expect] \
30 [-wt warn_time] [-ct crit_time] [-to to_sec] */
31void
32print_usage (void)
33{
34 printf (_("\
35Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\
36 [-e expect] [-s send] [-t to_sec] [-v]\n"), progname);
37 printf (_(UT_HLP_VRS), progname, progname);
38}
39
40void
41print_help (void)
42{
43 print_revision (progname, revision);
44
45 printf (_("Copyright (c) 1999 Ethan Galstad\n"));
46 printf (_(COPYRIGHT), copyright, email);
47
48 printf (_("\
49This plugin tests an UDP connection with the specified host.\n\n"));
50
51 print_usage ();
52
53 printf (_(UT_HELP_VRSN));
54
55 printf (_(UT_HOST_PORT), 'p', "none");
56
57 printf (_("\
58 -e, --expect=STRING <optional>\n\
59 String to expect in first line of server response\n\
60 -s, --send=STRING <optional>\n\
61 String to send to the server when initiating the connection\n"));
62
63 printf (_(UT_WARN_CRIT));
64
65 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
66
67 printf (_(UT_VERBOSE));
68
69 printf (_("\
70This plugin will attempt to connect to the specified port on the host.\n\
71Successful connects return STATE_OK, refusals and timeouts return\n\
72STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n"));
73
74 printf(_(UT_SUPPORT));
75}
76
77int process_arguments (int, char **); 28int process_arguments (int, char **);
29void print_help (void);
30void print_usage (void);
78 31
79int warning_time = 0; 32int warning_time = 0;
80int check_warning_time = FALSE; 33int check_warning_time = FALSE;
@@ -84,7 +37,7 @@ int verbose = FALSE;
84int server_port = 0; 37int server_port = 0;
85char *server_address = NULL; 38char *server_address = NULL;
86char *server_expect = NULL; 39char *server_expect = NULL;
87char *server_send = ""; 40char *server_send;
88 41
89int 42int
90main (int argc, char **argv) 43main (int argc, char **argv)
@@ -207,24 +160,28 @@ process_arguments (int argc, char **argv)
207 case 'c': /* critical */ 160 case 'c': /* critical */
208 if (!is_intnonneg (optarg)) 161 if (!is_intnonneg (optarg))
209 usage (_("Critical threshold must be a nonnegative integer\n")); 162 usage (_("Critical threshold must be a nonnegative integer\n"));
210 critical_time = atoi (optarg); 163 else
164 critical_time = atoi (optarg);
211 check_critical_time = TRUE; 165 check_critical_time = TRUE;
212 break; 166 break;
213 case 'w': /* warning */ 167 case 'w': /* warning */
214 if (!is_intnonneg (optarg)) 168 if (!is_intnonneg (optarg))
215 usage (_("Warning threshold must be a nonnegative integer\n")); 169 usage (_("Warning threshold must be a nonnegative integer\n"));
216 warning_time = atoi (optarg); 170 else
171 warning_time = atoi (optarg);
217 check_warning_time = TRUE; 172 check_warning_time = TRUE;
218 break; 173 break;
219 case 't': /* timeout */ 174 case 't': /* timeout */
220 if (!is_intnonneg (optarg)) 175 if (!is_intnonneg (optarg))
221 usage (_("Timeout interval must be a nonnegative integer\n")); 176 usage (_("Timeout interval must be a nonnegative integer\n"));
222 socket_timeout = atoi (optarg); 177 else
178 socket_timeout = atoi (optarg);
223 break; 179 break;
224 case 'p': /* port */ 180 case 'p': /* port */
225 if (!is_intnonneg (optarg)) 181 if (!is_intnonneg (optarg))
226 usage (_("Server port must be a nonnegative integer\n")); 182 usage (_("Server port must be a nonnegative integer\n"));
227 server_port = atoi (optarg); 183 else
184 server_port = atoi (optarg);
228 break; 185 break;
229 case 'e': /* expect */ 186 case 'e': /* expect */
230 server_expect = optarg; 187 server_expect = optarg;
@@ -245,5 +202,65 @@ process_arguments (int argc, char **argv)
245 if (server_address == NULL) 202 if (server_address == NULL)
246 usage (_("Host name was not supplied\n")); 203 usage (_("Host name was not supplied\n"));
247 204
205 if (server_send == NULL)
206 server_send = strdup("");
207
248 return c; 208 return c;
249} 209}
210
211
212
213
214
215
216void
217print_help (void)
218{
219 print_revision (progname, revision);
220
221 printf (_("Copyright (c) 1999 Ethan Galstad\n"));
222 printf (_(COPYRIGHT), copyright, email);
223
224 printf (_("\
225This plugin tests an UDP connection with the specified host.\n\n"));
226
227 print_usage ();
228
229 printf (_(UT_HELP_VRSN));
230
231 printf (_(UT_HOST_PORT), 'p', "none");
232
233 printf (_("\
234 -e, --expect=STRING <optional>\n\
235 String to expect in first line of server response\n\
236 -s, --send=STRING <optional>\n\
237 String to send to the server when initiating the connection\n"));
238
239 printf (_(UT_WARN_CRIT));
240
241 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
242
243 printf (_(UT_VERBOSE));
244
245 printf (_("\
246This plugin will attempt to connect to the specified port on the host.\n\
247Successful connects return STATE_OK, refusals and timeouts return\n\
248STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n"));
249
250 printf(_(UT_SUPPORT));
251}
252
253
254
255
256/* Original Command line:
257 check_udp <host_address> [-p port] [-s send] [-e expect] \
258 [-wt warn_time] [-ct crit_time] [-to to_sec] */
259void
260print_usage (void)
261{
262 printf (_("\
263Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\
264 [-e expect] [-s send] [-t to_sec] [-v]\n"), progname);
265 printf (_(UT_HLP_VRS), progname, progname);
266}