summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index bd06021..7974d14 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -109,7 +109,7 @@ enum
109#endif 109#endif
110 110
111int process_arguments (int, char **); 111int process_arguments (int, char **);
112void print_path (char *mypath); 112void print_path (const char *mypath);
113int validate_arguments (uintmax_t, uintmax_t, double, double, char *); 113int validate_arguments (uintmax_t, uintmax_t, double, double, char *);
114int check_disk (double usp, uintmax_t free_disk); 114int check_disk (double usp, uintmax_t free_disk);
115int walk_name_list (struct name_list *list, const char *name); 115int walk_name_list (struct name_list *list, const char *name);
@@ -216,7 +216,7 @@ main (int argc, char **argv)
216 temp_list = temp_list->name_next; 216 temp_list = temp_list->name_next;
217 } 217 }
218 218
219 die (result, "DISK %s%s\n", state_text (result), output, details); 219 die (result, "DISK %s%s%s\n", state_text (result), output, details);
220 return STATE_UNKNOWN; 220 return STATE_UNKNOWN;
221} 221}
222 222
@@ -453,11 +453,15 @@ process_arguments (int argc, char **argv)
453} 453}
454 454
455 455
456void print_path (char *mypath) 456void
457print_path (const char *mypath)
457{ 458{
458 if (mypath) 459 if (mypath == NULL)
459 printf (" for %s", mypath); 460 printf ("\n");
460 printf ("\n"); 461 else
462 printf (" for %s\n", mypath);
463
464 return;
461} 465}
462 466
463int 467int
@@ -473,14 +477,14 @@ validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, char *mypath
473 printf (_("\ 477 printf (_("\
474INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"), 478INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
475 cp, wp); 479 cp, wp);
476 print_path (path); 480 print_path (mypath);
477 return ERROR; 481 return ERROR;
478 } 482 }
479 else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) { 483 else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) {
480 printf (_("\ 484 printf (_("\
481INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"), 485INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
482 (unsigned long)c, (unsigned long)w); 486 (unsigned long)c, (unsigned long)w);
483 print_path (path); 487 print_path (mypath);
484 return ERROR; 488 return ERROR;
485 } 489 }
486 490
@@ -542,6 +546,7 @@ print_help (void)
542{ 546{
543 print_revision (progname, revision); 547 print_revision (progname, revision);
544 548
549 printf (_("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"));
545 printf (_(COPYRIGHT), copyright, email); 550 printf (_(COPYRIGHT), copyright, email);
546 551
547 printf (_("\ 552 printf (_("\
@@ -596,7 +601,7 @@ and generates an alert if free space is less than one of the threshold values.")
596 check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n\ 601 check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n\
597 Checks /tmp and /var at 10%,5% and / at 100MB, 50MB\n")); 602 Checks /tmp and /var at 10%,5% and / at 100MB, 50MB\n"));
598 603
599 support (); 604 printf (_(UT_SUPPORT));
600} 605}
601 606
602 607
diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c
index d90b140..3db5238 100644
--- a/plugins/check_dummy.c
+++ b/plugins/check_dummy.c
@@ -1,39 +1,21 @@
1/************************************************************* 1/******************************************************************************
2 * 2
3 * CHECK_DUMMY.C 3 This program is free software; you can redistribute it and/or modify
4 * 4 it under the terms of the GNU General Public License as published by
5 * Program: Dummy plugin for Nagios 5 the Free Software Foundation; either version 2 of the License, or
6 * License: GPL 6 (at your option) any later version.
7 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) 7
8 * 8 This program is distributed in the hope that it will be useful,
9 * Last Modified: $Date$ 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * Command line: CHECK_DUMMY <state> 11 GNU General Public License for more details.
12 * 12
13 * Description: 13 You should have received a copy of the GNU General Public License
14 * 14 along with this program; if not, write to the Free Software
15 * This plugin will simply return the state corresponding to the 15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 * numerical value of the <state> argument. 16
17 * 17******************************************************************************/
18 * License Information: 18
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 *
34 **************************************************************/
35
36#include "config.h"
37#include "common.h" 19#include "common.h"
38#include "utils.h" 20#include "utils.h"
39 21
@@ -42,39 +24,18 @@ const char *revision = "$Revision$";
42const char *copyright = "1999-2003"; 24const char *copyright = "1999-2003";
43const char *email = "nagiosplug-devel@lists.sourceforge.net"; 25const char *email = "nagiosplug-devel@lists.sourceforge.net";
44 26
45void 27void print_help (void);
46print_usage (void) 28void print_usage (void);
47{
48 printf (_("Usage: %s <integer state>\n"), progname);
49}
50 29
51void
52print_help (void)
53{
54 print_revision (progname, revision);
55 30
56 printf (_(COPYRIGHT), copyright, email);
57
58 print_usage ();
59
60 printf (_(UT_HELP_VRSN));
61
62 printf (_("\n\
63This plugin will simply return the state corresponding to the numeric value\n\
64of the <state> argument.\n"));
65
66 support ();
67}
68 31
69int 32int
70main (int argc, char **argv) 33main (int argc, char **argv)
71{ 34{
72 int result; 35 int result;
73 36
74 if (argc != 2) { 37 if (argc != 2)
75 printf (_("Incorrect number of arguments supplied\n")); 38 usage (_("Incorrect number of arguments supplied\n"));
76 exit (STATE_UNKNOWN);
77 }
78 else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) { 39 else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
79 print_revision (progname, revision); 40 print_revision (progname, revision);
80 exit (STATE_OK); 41 exit (STATE_OK);
@@ -83,11 +44,10 @@ main (int argc, char **argv)
83 print_help (); 44 print_help ();
84 exit (STATE_OK); 45 exit (STATE_OK);
85 } 46 }
86 else if (!is_integer (argv[1])) { 47 else if (!is_integer (argv[1]))
87 print_usage (); 48 usage (_("Arguments to check_dummy must be an integer\n"));
88 exit (STATE_UNKNOWN); 49 else
89 } 50 result = atoi (argv[1]);
90 result = atoi (argv[1]);
91 51
92 switch (result) { 52 switch (result) {
93 case STATE_OK: 53 case STATE_OK:
@@ -99,10 +59,42 @@ main (int argc, char **argv)
99 case STATE_CRITICAL: 59 case STATE_CRITICAL:
100 printf ("Status is CRITICAL\n"); 60 printf ("Status is CRITICAL\n");
101 break; 61 break;
102 default: 62 case STATE_UNKNOWN:
103 printf ("Status is UNKNOWN\n"); 63 printf ("Status is UNKNOWN\n");
104 result = STATE_UNKNOWN; 64 break;
65 default:
66 printf ("Status %d is not a supported error state\n", result);
67 break;
105 } 68 }
106 69
107 return result; 70 return result;
108} 71}
72
73
74
75void
76print_help (void)
77{
78 print_revision (progname, revision);
79
80 printf (_("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"));
81 printf (_(COPYRIGHT), copyright, email);
82
83 print_usage ();
84
85 printf (_(UT_HELP_VRSN));
86
87 printf (_("\n\
88This plugin will simply return the state corresponding to the numeric value\n\
89of the <state> argument.\n"));
90
91 printf (_(UT_SUPPORT));
92}
93
94
95
96void
97print_usage (void)
98{
99 printf (_("Usage: %s <integer state>\n"), progname);
100}
diff --git a/plugins/popen.c b/plugins/popen.c
index fb855d7..98ba085 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -57,9 +57,11 @@ RETSIGTYPE popen_timeout_alarm_handler (int);
57#define min(a,b) ((a) < (b) ? (a) : (b)) 57#define min(a,b) ((a) < (b) ? (a) : (b))
58#define max(a,b) ((a) > (b) ? (a) : (b)) 58#define max(a,b) ((a) > (b) ? (a) : (b))
59int open_max (void); /* {Prog openmax} */ 59int open_max (void); /* {Prog openmax} */
60void err_sys (const char *, ...); 60static void err_sys (const char *, ...) __attribute__((noreturn,format(printf, 1, 2)));
61char *rtrim (char *, const char *); 61char *rtrim (char *, const char *);
62 62
63char *pname = NULL; /* caller can set this from argv[0] */
64
63/*int *childerr = NULL;*//* ptr to array allocated at run-time */ 65/*int *childerr = NULL;*//* ptr to array allocated at run-time */
64/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */ 66/*extern pid_t *childpid = NULL; *//* ptr to array allocated at run-time */
65static int maxfd; /* from our open_max(), {Prog openmax} */ 67static int maxfd; /* from our open_max(), {Prog openmax} */
@@ -67,7 +69,7 @@ static int maxfd; /* from our open_max(), {Prog openmax} */
67FILE * 69FILE *
68spopen (const char *cmdstring) 70spopen (const char *cmdstring)
69{ 71{
70 char *env[] = { "LC_ALL=C", (char*)0 }; 72 char *env[2];
71 char *cmd = NULL; 73 char *cmd = NULL;
72 char **argv = NULL; 74 char **argv = NULL;
73 char *str; 75 char *str;
@@ -84,6 +86,9 @@ spopen (const char *cmdstring)
84 setrlimit (RLIMIT_CORE, &limit); 86 setrlimit (RLIMIT_CORE, &limit);
85#endif 87#endif
86 88
89 env[0] = strdup("LC_ALL=C");
90 env[1] = '\0';
91
87 /* if no command was passed, return with no error */ 92 /* if no command was passed, return with no error */
88 if (cmdstring == NULL) 93 if (cmdstring == NULL)
89 return (NULL); 94 return (NULL);
@@ -148,13 +153,13 @@ spopen (const char *cmdstring)
148 153
149 if (childpid == NULL) { /* first time through */ 154 if (childpid == NULL) { /* first time through */
150 maxfd = open_max (); /* allocate zeroed out array for child pids */ 155 maxfd = open_max (); /* allocate zeroed out array for child pids */
151 if ((childpid = calloc (maxfd, sizeof (pid_t))) == NULL) 156 if ((childpid = calloc ((size_t)maxfd, sizeof (pid_t))) == NULL)
152 return (NULL); 157 return (NULL);
153 } 158 }
154 159
155 if (child_stderr_array == NULL) { /* first time through */ 160 if (child_stderr_array == NULL) { /* first time through */
156 maxfd = open_max (); /* allocate zeroed out array for child pids */ 161 maxfd = open_max (); /* allocate zeroed out array for child pids */
157 if ((child_stderr_array = calloc (maxfd, sizeof (int))) == NULL) 162 if ((child_stderr_array = calloc ((size_t)maxfd, sizeof (int))) == NULL)
158 return (NULL); 163 return (NULL);
159 } 164 }
160 165
@@ -259,34 +264,22 @@ open_max (void)
259} 264}
260 265
261 266
262static void err_doit (int, const char *, va_list);
263
264char *pname = NULL; /* caller can set this from argv[0] */
265 267
266/* Fatal error related to a system call. 268/* Fatal error related to a system call.
267 * Print a message and die. */ 269 * Print a message and die. */
268 270
269void
270err_sys (const char *fmt, ...)
271{
272 va_list ap;
273
274 va_start (ap, fmt);
275 err_doit (1, fmt, ap);
276 va_end (ap);
277 exit (1);
278}
279
280/* Print a message and return to caller.
281 * Caller specifies "errnoflag". */
282
283#define MAXLINE 2048 271#define MAXLINE 2048
284static void 272static void
285err_doit (int errnoflag, const char *fmt, va_list ap) 273err_sys (const char *fmt, ...)
286{ 274{
275 int errnoflag = 1;
287 int errno_save; 276 int errno_save;
288 char buf[MAXLINE]; 277 char buf[MAXLINE];
289 278
279 va_list ap;
280
281 va_start (ap, fmt);
282 /* err_doit (1, fmt, ap); */
290 errno_save = errno; /* value caller might want printed */ 283 errno_save = errno; /* value caller might want printed */
291 vsprintf (buf, fmt, ap); 284 vsprintf (buf, fmt, ap);
292 if (errnoflag) 285 if (errnoflag)
@@ -295,7 +288,8 @@ err_doit (int errnoflag, const char *fmt, va_list ap)
295 fflush (stdout); /* in case stdout and stderr are the same */ 288 fflush (stdout); /* in case stdout and stderr are the same */
296 fputs (buf, stderr); 289 fputs (buf, stderr);
297 fflush (NULL); /* flushes all stdio output streams */ 290 fflush (NULL); /* flushes all stdio output streams */
298 return; 291 va_end (ap);
292 exit (1);
299} 293}
300 294
301char * 295char *
@@ -313,3 +307,4 @@ rtrim (char *str, const char *tok)
313 } 307 }
314 return str; 308 return str;
315} 309}
310
diff --git a/plugins/utils.c b/plugins/utils.c
index aed03c4..c2261dc 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -54,7 +54,7 @@ max_state (int a, int b)
54 54
55void usage (char *msg) 55void usage (char *msg)
56{ 56{
57 printf (msg); 57 printf ("%s", msg);
58 print_usage (); 58 print_usage ();
59 exit (STATE_UNKNOWN); 59 exit (STATE_UNKNOWN);
60} 60}
diff --git a/plugins/utils.h b/plugins/utils.h
index a852e86..c378e45 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -16,7 +16,7 @@ suite of plugins. */
16void support (void); 16void support (void);
17char *clean_revstring (const char *revstring); 17char *clean_revstring (const char *revstring);
18void print_revision (const char *, const char *); 18void print_revision (const char *, const char *);
19void die (int result, const char *fmt, ...) __attribute__((noreturn)); 19void die (int result, const char *fmt, ...) __attribute__((noreturn,format(printf, 2, 3)));
20 20
21/* Handle timeouts */ 21/* Handle timeouts */
22 22