diff options
Diffstat (limited to 'web/attachments/52602-nagios.time.diff')
-rw-r--r-- | web/attachments/52602-nagios.time.diff | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/web/attachments/52602-nagios.time.diff b/web/attachments/52602-nagios.time.diff new file mode 100644 index 0000000..f6ccc62 --- /dev/null +++ b/web/attachments/52602-nagios.time.diff | |||
@@ -0,0 +1,89 @@ | |||
1 | --- /tmp/nagios-plugins-1.3.0/plugins/check_time.c 2003-02-15 23:48:46.000000000 +1100 | ||
2 | +++ nagios-plugins-1.3.0/plugins/check_time.c 2003-06-06 10:43:32.000000000 +1000 | ||
3 | @@ -61,7 +61,7 @@ | ||
4 | int check_critical_diff = FALSE; | ||
5 | int server_port = TIME_PORT; | ||
6 | char *server_address = NULL; | ||
7 | - | ||
8 | +int use_udp = FALSE; | ||
9 | |||
10 | int process_arguments (int, char **); | ||
11 | void print_usage (void); | ||
12 | @@ -85,7 +85,13 @@ | ||
13 | time (&start_time); | ||
14 | |||
15 | /* try to connect to the host at the given port number */ | ||
16 | - if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) { | ||
17 | + if (use_udp) { | ||
18 | + result = my_udp_connect (server_address, server_port, &sd); | ||
19 | + } else { | ||
20 | + result = my_tcp_connect (server_address, server_port, &sd); | ||
21 | + } | ||
22 | + | ||
23 | + if (result != STATE_OK) { | ||
24 | if (check_critical_time == TRUE) | ||
25 | result = STATE_CRITICAL; | ||
26 | else if (check_warning_time == TRUE) | ||
27 | @@ -94,7 +100,21 @@ | ||
28 | result = STATE_UNKNOWN; | ||
29 | terminate (result, | ||
30 | "TIME UNKNOWN - could not connect to server %s, port %d\n", | ||
31 | - server_address, server_port); | ||
32 | + server_address, server_port); | ||
33 | + } | ||
34 | + | ||
35 | + if (use_udp) { | ||
36 | + if (send (sd, "", 0, 0) < 0) { | ||
37 | + if (check_critical_time == TRUE) | ||
38 | + result = STATE_CRITICAL; | ||
39 | + else if (check_warning_time == TRUE) | ||
40 | + result = STATE_WARNING; | ||
41 | + else | ||
42 | + result = STATE_UNKNOWN; | ||
43 | + terminate (result, | ||
44 | + "TIME UNKNOWN - could not send UDP request to server %s, port %d\n", | ||
45 | + server_address, server_port); | ||
46 | + } | ||
47 | } | ||
48 | |||
49 | /* watch for the connection string */ | ||
50 | @@ -170,6 +190,7 @@ | ||
51 | {"timeout", required_argument, 0, 't'}, | ||
52 | {"version", no_argument, 0, 'V'}, | ||
53 | {"help", no_argument, 0, 'h'}, | ||
54 | + {"udp", no_argument, 0, 'u'}, | ||
55 | {0, 0, 0, 0} | ||
56 | }; | ||
57 | #endif | ||
58 | @@ -193,10 +214,10 @@ | ||
59 | while (1) { | ||
60 | #ifdef HAVE_GETOPT_H | ||
61 | c = | ||
62 | - getopt_long (argc, argv, "hVH:w:c:W:C:p:t:", long_options, | ||
63 | + getopt_long (argc, argv, "hVH:w:c:W:C:p:t:u", long_options, | ||
64 | &option_index); | ||
65 | #else | ||
66 | - c = getopt (argc, argv, "hVH:w:c:W:C:p:t:"); | ||
67 | + c = getopt (argc, argv, "hVH:w:c:W:C:p:t:u"); | ||
68 | #endif | ||
69 | |||
70 | if (c == -1 || c == EOF) | ||
71 | @@ -275,6 +296,9 @@ | ||
72 | usage ("Timeout interval must be a nonnegative integer\n"); | ||
73 | socket_timeout = atoi (optarg); | ||
74 | break; | ||
75 | + case 'u': | ||
76 | + /* udp */ | ||
77 | + use_udp = TRUE; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | @@ -338,6 +362,8 @@ | ||
82 | " Seconds before connection times out (default: %d)\n" | ||
83 | " -p, --port=INTEGER\n" | ||
84 | " Port number (default: %d)\n" | ||
85 | + " -u, --udp\n" | ||
86 | + " Use UDP to connect, not TCP\n" | ||
87 | " -h, --help\n" | ||
88 | " Print detailed help screen\n" | ||
89 | " -V, --version\n" | ||