summaryrefslogtreecommitdiffstats
path: root/plugins/negate.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/negate.c')
-rw-r--r--plugins/negate.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/plugins/negate.c b/plugins/negate.c
index 81a08212..4bd09deb 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios negate plugin 3* Monitoring negate plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2002-2008 Nagios Plugins Development Team 6* Copyright (c) 2002-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "negate"; 32const char *progname = "negate";
33const char *copyright = "2002-2008"; 33const char *copyright = "2002-2008";
34const char *email = "devel@nagios-plugins.org"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#define DEFAULT_TIMEOUT 11 36#define DEFAULT_TIMEOUT 11
37 37
@@ -45,7 +45,6 @@ const char *email = "devel@nagios-plugins.org";
45 45
46static const char **process_arguments (int, char **); 46static const char **process_arguments (int, char **);
47int validate_arguments (char **); 47int validate_arguments (char **);
48int translate_state (char *);
49void print_help (void); 48void print_help (void);
50void print_usage (void); 49void print_usage (void);
51int subst_text = FALSE; 50int subst_text = FALSE;
@@ -166,27 +165,27 @@ process_arguments (int argc, char **argv)
166 timeout_interval = atoi (optarg); 165 timeout_interval = atoi (optarg);
167 break; 166 break;
168 case 'T': /* Result to return on timeouts */ 167 case 'T': /* Result to return on timeouts */
169 if ((timeout_state = translate_state(optarg)) == ERROR) 168 if ((timeout_state = mp_translate_state(optarg)) == ERROR)
170 usage4 (_("Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 169 usage4 (_("Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
171 break; 170 break;
172 case 'o': /* replacement for OK */ 171 case 'o': /* replacement for OK */
173 if ((state[STATE_OK] = translate_state(optarg)) == ERROR) 172 if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR)
174 usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 173 usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
175 permute = FALSE; 174 permute = FALSE;
176 break; 175 break;
177 176
178 case 'w': /* replacement for WARNING */ 177 case 'w': /* replacement for WARNING */
179 if ((state[STATE_WARNING] = translate_state(optarg)) == ERROR) 178 if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR)
180 usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 179 usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
181 permute = FALSE; 180 permute = FALSE;
182 break; 181 break;
183 case 'c': /* replacement for CRITICAL */ 182 case 'c': /* replacement for CRITICAL */
184 if ((state[STATE_CRITICAL] = translate_state(optarg)) == ERROR) 183 if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR)
185 usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 184 usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
186 permute = FALSE; 185 permute = FALSE;
187 break; 186 break;
188 case 'u': /* replacement for UNKNOWN */ 187 case 'u': /* replacement for UNKNOWN */
189 if ((state[STATE_UNKNOWN] = translate_state(optarg)) == ERROR) 188 if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR)
190 usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 189 usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
191 permute = FALSE; 190 permute = FALSE;
192 break; 191 break;
@@ -218,24 +217,6 @@ validate_arguments (char **command_line)
218} 217}
219 218
220 219
221int
222translate_state (char *state_text)
223{
224 char *temp_ptr;
225 for (temp_ptr = state_text; *temp_ptr; temp_ptr++) {
226 *temp_ptr = toupper(*temp_ptr);
227 }
228 if (!strcmp(state_text,"OK") || !strcmp(state_text,"0"))
229 return STATE_OK;
230 if (!strcmp(state_text,"WARNING") || !strcmp(state_text,"1"))
231 return STATE_WARNING;
232 if (!strcmp(state_text,"CRITICAL") || !strcmp(state_text,"2"))
233 return STATE_CRITICAL;
234 if (!strcmp(state_text,"UNKNOWN") || !strcmp(state_text,"3"))
235 return STATE_UNKNOWN;
236 return ERROR;
237}
238
239void 220void
240print_help (void) 221print_help (void)
241{ 222{
@@ -252,7 +233,7 @@ print_help (void)
252 233
253 printf (UT_HELP_VRSN); 234 printf (UT_HELP_VRSN);
254 235
255 printf (UT_TIMEOUT, timeout_interval); 236 printf (UT_PLUG_TIMEOUT, timeout_interval);
256 printf (" %s\n", _("Keep timeout longer than the plugin timeout to retain CRITICAL status.")); 237 printf (" %s\n", _("Keep timeout longer than the plugin timeout to retain CRITICAL status."));
257 printf (" -T, --timeout-result=STATUS\n"); 238 printf (" -T, --timeout-result=STATUS\n");
258 printf (" %s\n", _("Custom result on Negate timeouts; see below for STATUS definition\n")); 239 printf (" %s\n", _("Custom result on Negate timeouts; see below for STATUS definition\n"));