Code

The "--serverip" and "--requestedip" options now accept host names, too.
[nagiosplug.git] / plugins / check_dummy.c
1 /******************************************************************************
2 *
3 * Nagios check_dummy plugin
4 *
5 * License: GPL
6 * Copyright (c) 1999-2006 nagios-plugins team
7 *
8 * Last Modified: $Date$
9 *
10 * Description:
11 *
12 * This file contains the check_dummy plugin
13 *
14 *  This plugin will simply return the state corresponding to the numeric value
15 *
16 *
17 * License Information:
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33  $Id$
34  
35 ******************************************************************************/
37 const char *progname = "check_dummy";
38 const char *revision = "$Revision$";
39 const char *copyright = "1999-2006";
40 const char *email = "nagiosplug-devel@lists.sourceforge.net";
42 #include "common.h"
43 #include "utils.h"
45 void print_help (void);
46 void print_usage (void);
49 int
50 main (int argc, char **argv)
51 {
52   int result = STATE_UNKNOWN;
54   setlocale (LC_ALL, "");
55   bindtextdomain (PACKAGE, LOCALEDIR);
56   textdomain (PACKAGE);
58   if (argc < 2)
59     usage4 (_("Could not parse arguments"));
60   else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
61     print_revision (progname, revision);
62     exit (STATE_OK);
63   }
64   else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
65     print_help ();
66     exit (STATE_OK);
67   }
68   else if (!is_integer (argv[1]))
69     usage4 (_("Arguments to check_dummy must be an integer"));
70   else
71     result = atoi (argv[1]);
73   switch (result) {
74   case STATE_OK:
75     printf (_("OK"));
76     break;
77   case STATE_WARNING:
78     printf (_("WARNING"));
79     break;
80   case STATE_CRITICAL:
81     printf (_("CRITICAL"));
82     break;
83   case STATE_UNKNOWN:
84     printf (_("UNKNOWN"));
85     break;
86   default:
87     printf (_("UNKNOWN"));
88     printf (": ");
89     printf (_("Status %d is not a supported error state\n"), result);
90     return STATE_UNKNOWN;
91   }
93   if (argc >= 3) 
94     printf (": %s", argv[2]);
96   printf("\n");
98   return result;
99 }
103 void
104 print_help (void)
106   print_revision (progname, revision);
108   printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
109   printf (COPYRIGHT, copyright, email);
111   printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
112  
113   printf ("%s\n", _("of the <state> argument with optional text"));
115   printf ("\n\n");
116   
117   print_usage ();
119   printf (_(UT_HELP_VRSN));
121   printf (_(UT_SUPPORT));
126 void
127 print_usage (void)
129   printf (_("Usage:"));
130   printf (" %s <integer state> [optional text]\n", progname);