summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/Makefile.am6
-rw-r--r--plugins/check_dns.c2
-rw-r--r--plugins/check_ldap.c59
-rw-r--r--plugins/check_mrtg.c2
-rw-r--r--plugins/check_mrtgtraf.c135
-rw-r--r--plugins/check_nwstat.c4
-rw-r--r--plugins/check_radius.c20
-rw-r--r--plugins/utils.c4
-rw-r--r--plugins/version.h.in1
9 files changed, 92 insertions, 141 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 6747fa3..23c713a 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -2,7 +2,7 @@
2 2
3VPATH = $(top_srcdir) $(top_srcdir)/plugins $(top_srcdir)/plugins/t 3VPATH = $(top_srcdir) $(top_srcdir)/plugins $(top_srcdir)/plugins/t
4 4
5INCLUDES = @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@ 5INCLUDES = @SSLINCLUDE@
6 6
7libexec_PROGRAMS = check_disk check_dummy check_http check_load \ 7libexec_PROGRAMS = check_disk check_dummy check_http check_load \
8 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \ 8 check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \
@@ -119,6 +119,10 @@ check_imap_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS)
119check_nntp_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS) 119check_nntp_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS)
120check_pop_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS) 120check_pop_DEPENDENCIES = check_tcp.c $(NETOBJS) $(DEPLIBS)
121 121
122check_mysql_INCLUDES = @MYSQLINCLUDE@
123check_pgsql_INCLUDES = @PGINCLUDE@
124check_ldap_INCLUDES = @LDAPINCLUDE@
125
122############################################################################## 126##############################################################################
123# secondary dependencies 127# secondary dependencies
124 128
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index f9cf288..714ecab 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -88,7 +88,7 @@ main (int argc, char **argv)
88 } 88 }
89 89
90 /* get the command to run */ 90 /* get the command to run */
91 sprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server); 91 asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);
92 92
93 alarm (timeout_interval); 93 alarm (timeout_interval);
94 time (&start_time); 94 time (&start_time);
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index d3f0615..213dc4a 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -34,7 +34,6 @@
34#define UNKNOWN -1 34#define UNKNOWN -1
35 35
36int process_arguments (int, char **); 36int process_arguments (int, char **);
37int call_getopt (int, char **);
38int validate_arguments (void); 37int validate_arguments (void);
39static void print_help (void); 38static void print_help (void);
40static void print_usage (void); 39static void print_usage (void);
@@ -124,35 +123,10 @@ process_arguments (int argc, char **argv)
124{ 123{
125 int c; 124 int c;
126 125
127 if (argc < 2)
128 return ERROR;
129
130 for (c = 1; c < argc; c++) {
131 if (strcmp ("-to", argv[c]) == 0)
132 strcpy (argv[c], "-t");
133 }
134
135 c = 0;
136 while (c += (call_getopt (argc - c, &argv[c]))) {
137 if (argc <= c)
138 break;
139 if (ld_host[0] == 0) {
140 strncpy (ld_host, argv[c], sizeof (ld_host) - 1);
141 ld_host[sizeof (ld_host) - 1] = 0;
142 }
143 }
144
145 return c;
146}
147
148int
149call_getopt (int argc, char **argv)
150{
151 int c, i = 1;
152#ifdef HAVE_GETOPT_H 126#ifdef HAVE_GETOPT_H
153 int option_index = 0; 127 int option_index = 0;
154 /* initialize the long option struct */ 128 /* initialize the long option struct */
155 static struct option long_options[] = { 129 static struct option longopts[] = {
156 {"help", no_argument, 0, 'h'}, 130 {"help", no_argument, 0, 'h'},
157 {"version", no_argument, 0, 'V'}, 131 {"version", no_argument, 0, 'V'},
158 {"timeout", required_argument, 0, 't'}, 132 {"timeout", required_argument, 0, 't'},
@@ -168,15 +142,17 @@ call_getopt (int argc, char **argv)
168 }; 142 };
169#endif 143#endif
170 144
171 for (c = 1; c < argc; c++) 145 if (argc < 2)
146 return ERROR;
147
148 for (c = 1; c < argc; c++) {
172 if (strcmp ("-to", argv[c]) == 0) 149 if (strcmp ("-to", argv[c]) == 0)
173 strcpy (argv[c], "-t"); 150 strcpy (argv[c], "-t");
151 }
174 152
175 while (1) { 153 while (1) {
176#ifdef HAVE_GETOPT_H 154#ifdef HAVE_GETOPT_H
177 c = 155 c = getopt_long (argc, argv, "hVt:c:w:H:b:p:a:D:P:", longopts, &option_index);
178 getopt_long (argc, argv, "+hVt:c:w:H:b:p:a:D:P:", long_options,
179 &option_index);
180#else 156#else
181 c = getopt (argc, argv, "+?hVt:c:w:H:b:p:a:D:P:"); 157 c = getopt (argc, argv, "+?hVt:c:w:H:b:p:a:D:P:");
182#endif 158#endif
@@ -184,20 +160,6 @@ call_getopt (int argc, char **argv)
184 if (c == -1 || c == EOF) 160 if (c == -1 || c == EOF)
185 break; 161 break;
186 162
187 i++;
188 switch (c) {
189 case 't':
190 case 'c':
191 case 'w':
192 case 'H':
193 case 'b':
194 case 'p':
195 case 'a':
196 case 'D':
197 case 'P':
198 i++;
199 }
200
201 switch (c) { 163 switch (c) {
202 case 'h': /* help */ 164 case 'h': /* help */
203 print_help (); 165 print_help ();
@@ -239,7 +201,12 @@ call_getopt (int argc, char **argv)
239 break; 201 break;
240 } 202 }
241 } 203 }
242 return i; 204
205 if (ld_host[0] == 0) {
206 asprintf (&ld_host, "%s", argv[c]);
207 }
208
209 return validate_arguments ();
243} 210}
244 211
245int 212int
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c
index 4d297aa..80c9b00 100644
--- a/plugins/check_mrtg.c
+++ b/plugins/check_mrtg.c
@@ -332,7 +332,7 @@ process_arguments (int argc, char **argv)
332 value_warning_threshold = strtoul (argv[c++], NULL, 10); 332 value_warning_threshold = strtoul (argv[c++], NULL, 10);
333 } 333 }
334 334
335 if (vargc > c && alue_critical_threshold == 0) { 335 if (argc > c && value_critical_threshold == 0) {
336 value_critical_threshold = strtoul (argv[c++], NULL, 10); 336 value_critical_threshold = strtoul (argv[c++], NULL, 10);
337 } 337 }
338 338
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c
index 11f5146..d33ebd9 100644
--- a/plugins/check_mrtgtraf.c
+++ b/plugins/check_mrtgtraf.c
@@ -55,7 +55,6 @@
55#define PROGNAME "check_mrtgtraf" 55#define PROGNAME "check_mrtgtraf"
56 56
57int process_arguments (int, char **); 57int process_arguments (int, char **);
58int call_getopt (int, char **);
59int validate_arguments (void); 58int validate_arguments (void);
60void print_help (void); 59void print_help (void);
61void print_usage (void); 60void print_usage (void);
@@ -77,7 +76,7 @@ main (int argc, char **argv)
77 char input_buffer[MAX_INPUT_BUFFER]; 76 char input_buffer[MAX_INPUT_BUFFER];
78 char *temp_buffer; 77 char *temp_buffer;
79 time_t current_time; 78 time_t current_time;
80 char error_message[MAX_INPUT_BUFFER]; 79 char *error_message;
81 time_t timestamp = 0L; 80 time_t timestamp = 0L;
82 unsigned long average_incoming_rate = 0L; 81 unsigned long average_incoming_rate = 0L;
83 unsigned long average_outgoing_rate = 0L; 82 unsigned long average_outgoing_rate = 0L;
@@ -198,7 +197,7 @@ main (int argc, char **argv)
198 if (incoming_rate > incoming_critical_threshold 197 if (incoming_rate > incoming_critical_threshold
199 || outgoing_rate > outgoing_critical_threshold) { 198 || outgoing_rate > outgoing_critical_threshold) {
200 result = STATE_CRITICAL; 199 result = STATE_CRITICAL;
201 sprintf (error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s", 200 asprintf (&error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s",
202 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate, 201 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate,
203 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max", 202 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max",
204 adjusted_outgoing_rate, outgoing_speed_rating); 203 adjusted_outgoing_rate, outgoing_speed_rating);
@@ -206,7 +205,7 @@ main (int argc, char **argv)
206 else if (incoming_rate > incoming_warning_threshold 205 else if (incoming_rate > incoming_warning_threshold
207 || outgoing_rate > outgoing_warning_threshold) { 206 || outgoing_rate > outgoing_warning_threshold) {
208 result = STATE_WARNING; 207 result = STATE_WARNING;
209 sprintf (error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s", 208 asprintf (&error_message, "%s. In = %0.1f %s, %s. Out = %0.1f %s",
210 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate, 209 (use_average == TRUE) ? "Ave" : "Max", adjusted_incoming_rate,
211 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max", 210 incoming_speed_rating, (use_average == TRUE) ? "Ave" : "Max",
212 adjusted_outgoing_rate, outgoing_speed_rating); 211 adjusted_outgoing_rate, outgoing_speed_rating);
@@ -233,68 +232,9 @@ process_arguments (int argc, char **argv)
233{ 232{
234 int c; 233 int c;
235 234
236 if (argc < 2)
237 return ERROR;
238
239 for (c = 1; c < argc; c++) {
240 if (strcmp ("-to", argv[c]) == 0)
241 strcpy (argv[c], "-t");
242 else if (strcmp ("-wt", argv[c]) == 0)
243 strcpy (argv[c], "-w");
244 else if (strcmp ("-ct", argv[c]) == 0)
245 strcpy (argv[c], "-c");
246 }
247
248
249
250 c = 0;
251 while ((c += (call_getopt (argc - c, &argv[c]))) < argc) {
252
253 if (is_option (argv[c]))
254 continue;
255
256 if (log_file == NULL) {
257 log_file = argv[c];
258 }
259 else if (expire_minutes == -1) {
260 expire_minutes = atoi (optarg);
261 }
262 else if (strcmp (argv[c], "MAX") == 0) {
263 use_average = FALSE;
264 }
265 else if (strcmp (argv[c], "AVG") == 0) {
266 use_average = TRUE;
267 }
268 else if (incoming_warning_threshold == 0) {
269 incoming_warning_threshold = strtoul (argv[c], NULL, 10);
270 }
271 else if (incoming_critical_threshold == 0) {
272 incoming_critical_threshold = strtoul (argv[c], NULL, 10);
273 }
274 else if (outgoing_warning_threshold == 0) {
275 outgoing_warning_threshold = strtoul (argv[c], NULL, 10);
276 }
277 else if (outgoing_critical_threshold == 0) {
278 outgoing_critical_threshold = strtoul (argv[c], NULL, 10);
279 }
280 }
281
282 return validate_arguments ();
283}
284
285
286
287
288
289
290int
291call_getopt (int argc, char **argv)
292{
293 int c, i = 0;
294
295#ifdef HAVE_GETOPT_H 235#ifdef HAVE_GETOPT_H
296 int option_index = 0; 236 int option_index = 0;
297 static struct option long_options[] = { 237 static struct option longopts[] = {
298 {"logfile", required_argument, 0, 'F'}, 238 {"logfile", required_argument, 0, 'F'},
299 {"expires", required_argument, 0, 'e'}, 239 {"expires", required_argument, 0, 'e'},
300 {"aggregation", required_argument, 0, 'a'}, 240 {"aggregation", required_argument, 0, 'a'},
@@ -308,29 +248,29 @@ call_getopt (int argc, char **argv)
308 }; 248 };
309#endif 249#endif
310 250
251 if (argc < 2)
252 return ERROR;
253
254 for (c = 1; c < argc; c++) {
255 if (strcmp ("-to", argv[c]) == 0)
256 strcpy (argv[c], "-t");
257 else if (strcmp ("-wt", argv[c]) == 0)
258 strcpy (argv[c], "-w");
259 else if (strcmp ("-ct", argv[c]) == 0)
260 strcpy (argv[c], "-c");
261 }
262
311 while (1) { 263 while (1) {
312#ifdef HAVE_GETOPT_H 264#ifdef HAVE_GETOPT_H
313 c = 265 c = getopt_long (argc, argv, "hVF:e:a:c:w:", longopts, &option_index);
314 getopt_long (argc, argv, "+hVF:e:a:c:w:", long_options, &option_index);
315#else 266#else
316 c = getopt (argc, argv, "+hVF:e:a:c:w:"); 267 c = getopt (argc, argv, "hVF:e:a:c:w:");
317#endif 268#endif
318 269
319 i++; 270 if (c == -1 || c == EOF)
320
321 if (c == -1 || c == EOF || c == 1)
322 break; 271 break;
323 272
324 switch (c) { 273 switch (c) {
325 case 'F':
326 case 'e':
327 case 'a':
328 case 'c':
329 case 'w':
330 i++;
331 }
332
333 switch (c) {
334 case 'F': /* input file */ 274 case 'F': /* input file */
335 log_file = optarg; 275 log_file = optarg;
336 break; 276 break;
@@ -361,7 +301,42 @@ call_getopt (int argc, char **argv)
361 usage ("Invalid argument\n"); 301 usage ("Invalid argument\n");
362 } 302 }
363 } 303 }
364 return i; 304
305 c = optind;
306 if (argc > c && log_file == NULL) {
307 log_file = argv[c++];
308 }
309
310 if (argc > c && expire_minutes == -1) {
311 expire_minutes = atoi (argv[c++]);
312 }
313
314 if (argc > c && strcmp (argv[c], "MAX") == 0) {
315 use_average = FALSE;
316 c++;
317 }
318 else if (argc > c && strcmp (argv[c], "AVG") == 0) {
319 use_average = TRUE;
320 c++;
321 }
322
323 if (argc > c && incoming_warning_threshold == 0) {
324 incoming_warning_threshold = strtoul (argv[c++], NULL, 10);
325 }
326
327 if (argc > c && incoming_critical_threshold == 0) {
328 incoming_critical_threshold = strtoul (argv[c++], NULL, 10);
329 }
330
331 if (argc > c && outgoing_warning_threshold == 0) {
332 outgoing_warning_threshold = strtoul (argv[c++], NULL, 10);
333 }
334
335 if (argc > c && outgoing_critical_threshold == 0) {
336 outgoing_critical_threshold = strtoul (argv[c++], NULL, 10);
337 }
338
339 return validate_arguments ();
365} 340}
366 341
367 342
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index f8fca73..53deef8 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -296,7 +296,7 @@ int main(int argc, char **argv){
296 result=STATE_CRITICAL; 296 result=STATE_CRITICAL;
297 else if(check_warning_value==TRUE && lru_time <= warning_value) 297 else if(check_warning_value==TRUE && lru_time <= warning_value)
298 result=STATE_WARNING; 298 result=STATE_WARNING;
299 sprintf(&output_message,"LRU sitting time = %lu minutes",lru_time); 299 asprintf(&output_message,"LRU sitting time = %lu minutes",lru_time);
300 300
301 301
302 /* check KB free space on volume */ 302 /* check KB free space on volume */
@@ -590,7 +590,7 @@ int main(int argc, char **argv){
590 590
591 max_service_processes=atoi(recv_buffer); 591 max_service_processes=atoi(recv_buffer);
592 592
593 sprintf(&send_buffer,"S21\r\n"); 593 asprintf(&send_buffer,"S21\r\n");
594 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 594 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
595 if(result!=STATE_OK) 595 if(result!=STATE_OK)
596 return result; 596 return result;
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index 614d467..c346dc7 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -52,7 +52,7 @@
52 Number of times to retry a failed connection\n\ 52 Number of times to retry a failed connection\n\
53 -t, --timeout=INTEGER\n\ 53 -t, --timeout=INTEGER\n\
54 Seconds before connection times out (default: %d)\n\ 54 Seconds before connection times out (default: %d)\n\
55 -v\n\ 55 -v, --verbose\n\
56 Show details for command-line debugging (do not use with nagios server)\n\ 56 Show details for command-line debugging (do not use with nagios server)\n\
57 -h, --help\n\ 57 -h, --help\n\
58 Print detailed help screen\n\ 58 Print detailed help screen\n\
@@ -60,11 +60,17 @@
60 Print version information\n" 60 Print version information\n"
61 61
62#define DESCRIPTION "\ 62#define DESCRIPTION "\
63The password option presents a substantial security issue because the 63This plugin tests a radius server to see if it is accepting connections.\n\
64password can be determined by careful watching of the command line in 64\n\
65a process listing. This risk is exacerbated because nagios will 65The server to test must be specified in the invocation, as well as a user\n\
66run the plugin at regular prdictable intervals. Please be sure that 66name and password. A configuration file may also be present. The format of\n\
67the password used does not allow access to sensitive system resources, 67the configuration file is described in the radiusclient library sources.\n\
68\n\
69The password option presents a substantial security issue because the\n\
70password can be determined by careful watching of the command line in\n\
71a process listing. This risk is exacerbated because nagios will\n\
72run the plugin at regular prdictable intervals. Please be sure that\n\
73the password used does not allow access to sensitive system resources,\n\
68otherwise compormise could occur.\n" 74otherwise compormise could occur.\n"
69 75
70#include "config.h" 76#include "config.h"
@@ -128,7 +134,7 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
128 134
129<sect2> 135<sect2>
130<title>Future Enhancements</title> 136<title>Future Enhancements</title>
131<para>ToDo List</para> 137<para>Todo List</para>
132<itemizedlist> 138<itemizedlist>
133<listitem>Add option to get password from a secured file rather than the command line</listitem> 139<listitem>Add option to get password from a secured file rather than the command line</listitem>
134</itemizedlist> 140</itemizedlist>
diff --git a/plugins/utils.c b/plugins/utils.c
index 5dc6cfd..bf6af88 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -48,7 +48,7 @@ double delta_time (struct timeval tv);
48 48
49void strip (char *); 49void strip (char *);
50char *strscpy (char *dest, const char *src); 50char *strscpy (char *dest, const char *src);
51char *strscat (char *dest, const char *src); 51char *strscat (char *dest, char *src);
52char *strnl (char *str); 52char *strnl (char *str);
53char *strpcpy (char *dest, const char *src, const char *str); 53char *strpcpy (char *dest, const char *src, const char *str);
54char *strpcat (char *dest, const char *src, const char *str); 54char *strpcat (char *dest, const char *src, const char *str);
@@ -406,7 +406,7 @@ strscpy (char *dest, const char *src)
406 *****************************************************************************/ 406 *****************************************************************************/
407 407
408char * 408char *
409strscat (char *dest, const char *src) 409strscat (char *dest, char *src)
410{ 410{
411 411
412 if (dest == NULL) 412 if (dest == NULL)
diff --git a/plugins/version.h.in b/plugins/version.h.in
index e41aaee..6fd1e10 100644
--- a/plugins/version.h.in
+++ b/plugins/version.h.in
@@ -1,2 +1 @@
1#define PACKAGE_VERSION "1.3.0-alpha1"
2#define CVS_DATE "$Date$" #define CVS_DATE "$Date$"