Code

ff600a7956b9a78fbc1defbafa7672bf413d4406
[nagiosplug.git] / plugins / check_dummy.c
1 /*****************************************************************************
2
3 * Nagios check_dummy plugin
4
5 * License: GPL
6 * Copyright (c) 1999-2007 Nagios Plugins Development 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 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 * GNU General Public License for more details.
26
27 * You should have received a copy of the GNU General Public License
28 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
29
30 * $Id$
31
32 *****************************************************************************/
34 const char *progname = "check_dummy";
35 const char *revision = "$Revision$";
36 const char *copyright = "1999-2007";
37 const char *email = "nagiosplug-devel@lists.sourceforge.net";
39 #include "common.h"
40 #include "utils.h"
42 void print_help (void);
43 void print_usage (void);
46 int
47 main (int argc, char **argv)
48 {
49   int result = STATE_UNKNOWN;
51   setlocale (LC_ALL, "");
52   bindtextdomain (PACKAGE, LOCALEDIR);
53   textdomain (PACKAGE);
55   if (argc < 2)
56     usage4 (_("Could not parse arguments"));
57   else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
58     print_revision (progname, revision);
59     exit (STATE_OK);
60   }
61   else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
62     print_help ();
63     exit (STATE_OK);
64   }
65   else if (!is_integer (argv[1]))
66     usage4 (_("Arguments to check_dummy must be an integer"));
67   else
68     result = atoi (argv[1]);
70   switch (result) {
71   case STATE_OK:
72     printf (_("OK"));
73     break;
74   case STATE_WARNING:
75     printf (_("WARNING"));
76     break;
77   case STATE_CRITICAL:
78     printf (_("CRITICAL"));
79     break;
80   case STATE_UNKNOWN:
81     printf (_("UNKNOWN"));
82     break;
83   default:
84     printf (_("UNKNOWN"));
85     printf (": ");
86     printf (_("Status %d is not a supported error state\n"), result);
87     return STATE_UNKNOWN;
88   }
90   if (argc >= 3)
91     printf (": %s", argv[2]);
93   printf("\n");
95   return result;
96 }
100 void
101 print_help (void)
103   print_revision (progname, revision);
105   printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
106   printf (COPYRIGHT, copyright, email);
108   printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
110   printf ("%s\n", _("of the <state> argument with optional text"));
112   printf ("\n\n");
114   print_usage ();
116   printf (_(UT_HELP_VRSN));
118   printf (_(UT_SUPPORT));
123 void
124 print_usage (void)
126   printf (_("Usage:"));
127   printf (" %s <integer state> [optional text]\n", progname);