Code

Print optional text
[nagiosplug.git] / plugins / check_dummy.c
1 /******************************************************************************
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; either version 2 of the License, or
6  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  GNU General Public License for more details.
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 ******************************************************************************/
19 #include "common.h"
20 #include "utils.h"
22 const char *progname = "check_dummy";
23 const char *revision = "$Revision$";
24 const char *copyright = "1999-2003";
25 const char *email = "nagiosplug-devel@lists.sourceforge.net";
27 void print_help (void);
28 void print_usage (void);
32 int
33 main (int argc, char **argv)
34 {
35         int result;
37         setlocale (LC_ALL, "");
38         bindtextdomain (PACKAGE, LOCALEDIR);
39         textdomain (PACKAGE);
41         if (argc < 2)
42                 usage (_("Incorrect number of arguments supplied\n"));
43         else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
44                 print_revision (progname, revision);
45                 exit (STATE_OK);
46         }
47         else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
48                 print_help ();
49                 exit (STATE_OK);
50         }
51         else if (!is_integer (argv[1]))
52                 usage (_("Arguments to check_dummy must be an integer\n"));
53         else
54                 result = atoi (argv[1]);
56         switch (result) {
57         case STATE_OK:
58                 printf (_("OK"));
59                 break;
60         case STATE_WARNING:
61                 printf (_("WARNING"));
62                 break;
63         case STATE_CRITICAL:
64                 printf (_("CRITICAL"));
65                 break;
66         case STATE_UNKNOWN:
67                 printf (_("UNKNOWN"));
68                 break;
69         default:
70                 printf (_("Status %d is not a supported error state\n"), result);
71                 break;
72         }
74         if (argc >= 3) 
75                 printf (": %s", argv[2]);
77         printf("\n");
79         return result;
80 }
84 void
85 print_help (void)
86 {
87         print_revision (progname, revision);
89         printf (_("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"));
90         printf (_(COPYRIGHT), copyright, email);
92         print_usage ();
94         printf (_(UT_HELP_VRSN));
96         printf (_("\n\
97 This plugin will simply return the state corresponding to the numeric value\n\
98 of the <state> argument with optional text.\n"));
100         printf (_(UT_SUPPORT));
105 void
106 print_usage (void)
108         printf (_("Usage: %s <integer state> [optional text]\n"), progname);