summaryrefslogtreecommitdiffstats
path: root/web/attachments/230926-check_ntp.c.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/230926-check_ntp.c.patch')
-rw-r--r--web/attachments/230926-check_ntp.c.patch70
1 files changed, 70 insertions, 0 deletions
diff --git a/web/attachments/230926-check_ntp.c.patch b/web/attachments/230926-check_ntp.c.patch
new file mode 100644
index 0000000..7b59002
--- /dev/null
+++ b/web/attachments/230926-check_ntp.c.patch
@@ -0,0 +1,70 @@
1--- check_ntp.c.orig 2007-04-10 08:17:18.000000000 +0100
2+++ check_ntp.c 2007-05-29 12:41:58.000000000 +0100
3@@ -47,6 +47,7 @@
4
5 static char *server_address=NULL;
6 static int verbose=0;
7+static int max_hosts=0;
8 static double owarn=60;
9 static double ocrit=120;
10 static short do_jitter=0;
11@@ -372,7 +373,15 @@
12 }
13
14 /* count the number of returned hosts, and allocate stuff accordingly */
15- for(ai_tmp=ai; ai_tmp!=NULL; ai_tmp=ai_tmp->ai_next){ num_hosts++; }
16+ for(ai_tmp=ai; ai_tmp!=NULL; ai_tmp=ai_tmp->ai_next){
17+ num_hosts++;
18+ /* Reached max # hosts to compare ? */
19+ if(max_hosts && num_hosts >= max_hosts && ai_tmp->ai_next) {
20+printf("chopping at %d\n", num_hosts);
21+ freeaddrinfo(ai_tmp->ai_next);
22+ ai_tmp->ai_next = NULL;
23+ }
24+ }
25 req=(ntp_message*)malloc(sizeof(ntp_message)*num_hosts);
26 if(req==NULL) die(STATE_UNKNOWN, "can not allocate ntp message array");
27 socklist=(int*)malloc(sizeof(int)*num_hosts);
28@@ -651,6 +660,7 @@
29 {"critical", required_argument, 0, 'c'},
30 {"jwarn", required_argument, 0, 'j'},
31 {"jcrit", required_argument, 0, 'k'},
32+ {"maxhosts", required_argument, 0, 'm'},
33 {"timeout", required_argument, 0, 't'},
34 {"hostname", required_argument, 0, 'H'},
35 {0, 0, 0, 0}
36@@ -661,7 +671,7 @@
37 usage ("\n");
38
39 while (1) {
40- c = getopt_long (argc, argv, "Vhv46w:c:j:k:t:H:", longopts, &option);
41+ c = getopt_long (argc, argv, "Vhv46w:c:j:k:t:H:m:", longopts, &option);
42 if (c == -1 || c == EOF || c == 1)
43 break;
44
45@@ -677,6 +687,9 @@
46 case 'v':
47 verbose++;
48 break;
49+ case 'm':
50+ max_hosts = atoi(optarg);
51+ break;
52 case 'w':
53 owarn = atof(optarg);
54 break;
55@@ -848,6 +861,8 @@
56 printf (" %s\n", _("Warning value for jitter"));
57 printf (" %s\n", "-k, --critical=DOUBLE");
58 printf (" %s\n", _("Critical value for jitter"));
59+ printf (" %s\n", "-m, --maxhosts=INTEGER");
60+ printf (" %s\n", _("Max hosts to check - for where host expands to multiple addresses"));
61 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
62 printf (_(UT_VERBOSE));
63 printf (_(UT_SUPPORT));
64@@ -857,5 +872,5 @@
65 print_usage(void)
66 {
67 printf (_("Usage:"));
68- printf("%s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n", progname);
69+ printf("%s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose] [-m <max hosts to check>]\n", progname);
70 }