Code

Fix translations when extra-opts aren't enabled
[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 * Description:
9
10 * This file contains the check_dummy plugin
11
12 * This plugin will simply return the state corresponding to the numeric value
13
14
15 * This program is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
19
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 * GNU General Public License for more details.
24
25 * You should have received a copy of the GNU General Public License
26 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27
28
29 *****************************************************************************/
31 const char *progname = "check_dummy";
32 const char *copyright = "1999-2007";
33 const char *email = "nagiosplug-devel@lists.sourceforge.net";
35 #include "common.h"
36 #include "utils.h"
38 void print_help (void);
39 void print_usage (void);
42 int
43 main (int argc, char **argv)
44 {
45   int result = STATE_UNKNOWN;
47   setlocale (LC_ALL, "");
48   bindtextdomain (PACKAGE, LOCALEDIR);
49   textdomain (PACKAGE);
51   if (argc < 2)
52     usage4 (_("Could not parse arguments"));
53   else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
54     print_revision (progname, NP_VERSION);
55     exit (STATE_OK);
56   }
57   else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
58     print_help ();
59     exit (STATE_OK);
60   }
61   else if (!is_integer (argv[1]))
62     usage4 (_("Arguments to check_dummy must be an integer"));
63   else
64     result = atoi (argv[1]);
66   switch (result) {
67   case STATE_OK:
68     printf (_("OK"));
69     break;
70   case STATE_WARNING:
71     printf (_("WARNING"));
72     break;
73   case STATE_CRITICAL:
74     printf (_("CRITICAL"));
75     break;
76   case STATE_UNKNOWN:
77     printf (_("UNKNOWN"));
78     break;
79   default:
80     printf (_("UNKNOWN"));
81     printf (": ");
82     printf (_("Status %d is not a supported error state\n"), result);
83     return STATE_UNKNOWN;
84   }
86   if (argc >= 3)
87     printf (": %s", argv[2]);
89   printf("\n");
91   return result;
92 }
96 void
97 print_help (void)
98 {
99   print_revision (progname, NP_VERSION);
101   printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
102   printf (COPYRIGHT, copyright, email);
104   printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
106   printf ("%s\n", _("of the <state> argument with optional text"));
108   printf ("\n\n");
110   print_usage ();
112   printf (UT_HELP_VRSN);
114   printf (UT_SUPPORT);
119 void
120 print_usage (void)
122   printf (_("Usage:"));
123   printf (" %s <integer state> [optional text]\n", progname);