summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40451e9)
raw | patch | inline | side by side (parent: 40451e9)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Wed, 20 Aug 2003 09:54:12 +0000 (09:54 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Wed, 20 Aug 2003 09:54:12 +0000 (09:54 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@687 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_time.c | patch | blob | history |
diff --git a/plugins/check_time.c b/plugins/check_time.c
index 49e7c87daf4d7d2d2a7e041f8806eda67dfa210f..e6c3c7167cdb0d4ed098db8044ce666f248524de 100644 (file)
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
int check_critical_diff = FALSE;
int server_port = TIME_PORT;
char *server_address = NULL;
+int use_udp = FALSE;
int process_arguments (int, char **);
void print_help (void);
time (&start_time);
/* try to connect to the host at the given port number */
- if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK) {
+ if (use_udp) {
+ result = my_udp_connect (server_address, server_port, &sd);
+ } else {
+ result = my_tcp_connect (server_address, server_port, &sd);
+ }
+
+ if (result != STATE_OK) {
if (check_critical_time == TRUE)
result = STATE_CRITICAL;
else if (check_warning_time == TRUE)
server_address, server_port);
}
+ if (use_udp) {
+ if (send (sd, "", 0, 0) < 0) {
+ if (check_critical_time == TRUE)
+ result = STATE_CRITICAL;
+ else if (check_warning_time == TRUE)
+ result = STATE_WARNING;
+ else
+ result = STATE_UNKNOWN;
+ die (result,
+ _("TIME UNKNOWN - could not send UDP request to server %s, port %d\n"),
+ server_address, server_port);
+ }
+ }
+
/* watch for the connection string */
result = recv (sd, (void *)&raw_server_time, sizeof (raw_server_time), 0);
{"warning-connect", required_argument, 0, 'W'},
{"critical-connect", required_argument, 0, 'C'},
{"port", required_argument, 0, 'p'},
+ {"udp", no_argument, 0, 'u'},
{"timeout", required_argument, 0, 't'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
}
while (1) {
- c = getopt_long (argc, argv, "hVH:w:c:W:C:p:t:", longopts,
+ c = getopt_long (argc, argv, "hVH:w:c:W:C:p:t:u", longopts,
&option);
if (c == -1 || c == EOF)
else
socket_timeout = atoi (optarg);
break;
+ case 'u': /* udp */
+ use_udp = TRUE;
}
}
printf (_(UT_HOST_PORT), 'p', myport);
printf (_("\
+ -u, --udp\n\
+ Use UDP to connect, not TCP\n\
-w, --warning-variance=INTEGER\n\
Time difference (sec.) necessary to result in a warning status\n\
-c, --critical-variance=INTEGER\n\
print_usage (void)
{
printf (_("\
-Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\
+Usage: %s -H <host_address> [-p port] [-u] [-w variance] [-c variance]\n\
[-W connect_time] [-C connect_time] [-t timeout]\n"), progname);
printf (_(UT_HLP_VRS), progname, progname);
}