Code

mark for transaltion
[nagiosplug.git] / plugins / check_dummy.c
1 /*************************************************************
2  *
3  * CHECK_DUMMY.C
4  *
5  * Program: Dummy plugin for Nagios
6  * License: GPL
7  * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
8  *
9  * Last Modified: $Date$
10  *
11  * Command line: CHECK_DUMMY <state>
12  *
13  * Description:
14  *
15  * This plugin will simply return the state corresponding to the
16  * numerical value of the <state> argument.
17  *
18  * License Information:
19  *
20  * This program is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation; either version 2 of the License, or
23  * (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, write to the Free Software
32  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33  *
34  **************************************************************/
36 #include "config.h"
37 #include "common.h"
38 #include "utils.h"
40 const char *progname = "check_dummy";
41 const char *revision = "$Revision$";
42 const char *copyright = "1999-2003";
43 const char *email = "nagiosplug-devel@lists.sourceforge.net";
45 void
46 print_usage (void)
47 {
48         printf (_("Usage: %s <integer state>\n"), progname);
49 }
51 void
52 print_help (void)
53 {
54         print_revision (progname, revision);
56         printf (_(COPYRIGHT), copyright, email);
58         print_usage ();
60         printf (_(HELP_VRSN));
62         printf (_("\n\
63 This plugin will simply return the state corresponding to the numeric value\n\
64 of the <state> argument.\n"));
65 }
67 int
68 main (int argc, char **argv)
69 {
70         int result;
72         if (argc != 2) {
73                 printf (_("Incorrect number of arguments supplied\n"));
74                 exit (STATE_UNKNOWN);
75         }
76         else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
77                 print_revision (progname, revision);
78                 exit (STATE_OK);
79         }
80         else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
81                 print_help ();
82                 exit (STATE_OK);
83         }
84         else if (!is_integer (argv[1])) {
85                 print_usage ();
86                 exit (STATE_UNKNOWN);
87         }
88         result = atoi (argv[1]);
90         switch (result) {
91         case STATE_OK:
92                 printf ("Status is OK\n");
93                 break;
94         case STATE_WARNING:
95                 printf ("Status is at WARNING level\n");
96                 break;
97         case STATE_CRITICAL:
98                 printf ("Status is CRITICAL\n");
99                 break;
100         default:
101                 printf ("Status is UNKNOWN\n");
102                 result = STATE_UNKNOWN;
103         }
105         return result;