Back to index

nagios-plugins  1.4.16
check_dummy.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002 * 
00003 * Nagios check_dummy plugin
00004 * 
00005 * License: GPL
00006 * Copyright (c) 1999-2007 Nagios Plugins Development Team
00007 * 
00008 * Description:
00009 * 
00010 * This file contains the check_dummy plugin
00011 * 
00012 * This plugin will simply return the state corresponding to the numeric value
00013 * 
00014 * 
00015 * This program is free software: you can redistribute it and/or modify
00016 * it under the terms of the GNU General Public License as published by
00017 * the Free Software Foundation, either version 3 of the License, or
00018 * (at your option) any later version.
00019 * 
00020 * This program is distributed in the hope that it will be useful,
00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 * GNU General Public License for more details.
00024 * 
00025 * You should have received a copy of the GNU General Public License
00026 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00027 * 
00028 * 
00029 *****************************************************************************/
00030 
00031 const char *progname = "check_dummy";
00032 const char *copyright = "1999-2007";
00033 const char *email = "nagiosplug-devel@lists.sourceforge.net";
00034 
00035 #include "common.h"
00036 #include "utils.h"
00037 
00038 void print_help (void);
00039 void print_usage (void);
00040 
00041 
00042 int
00043 main (int argc, char **argv)
00044 {
00045   int result = STATE_UNKNOWN;
00046 
00047   setlocale (LC_ALL, "");
00048   bindtextdomain (PACKAGE, LOCALEDIR);
00049   textdomain (PACKAGE);
00050 
00051   if (argc < 2)
00052     usage4 (_("Could not parse arguments"));
00053   else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
00054     print_revision (progname, NP_VERSION);
00055     exit (STATE_OK);
00056   }
00057   else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
00058     print_help ();
00059     exit (STATE_OK);
00060   }
00061   else if (!is_integer (argv[1]))
00062     usage4 (_("Arguments to check_dummy must be an integer"));
00063   else
00064     result = atoi (argv[1]);
00065 
00066   switch (result) {
00067   case STATE_OK:
00068     printf (_("OK"));
00069     break;
00070   case STATE_WARNING:
00071     printf (_("WARNING"));
00072     break;
00073   case STATE_CRITICAL:
00074     printf (_("CRITICAL"));
00075     break;
00076   case STATE_UNKNOWN:
00077     printf (_("UNKNOWN"));
00078     break;
00079   default:
00080     printf (_("UNKNOWN"));
00081     printf (": ");
00082     printf (_("Status %d is not a supported error state\n"), result);
00083     return STATE_UNKNOWN;
00084   }
00085 
00086   if (argc >= 3)
00087     printf (": %s", argv[2]);
00088 
00089   printf("\n");
00090 
00091   return result;
00092 }
00093 
00094 
00095 
00096 void
00097 print_help (void)
00098 {
00099   print_revision (progname, NP_VERSION);
00100 
00101   printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
00102   printf (COPYRIGHT, copyright, email);
00103 
00104   printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
00105 
00106   printf ("%s\n", _("of the <state> argument with optional text"));
00107 
00108   printf ("\n\n");
00109 
00110   print_usage ();
00111 
00112   printf (UT_HELP_VRSN);
00113 
00114   printf (UT_SUPPORT);
00115 }
00116 
00117 
00118 
00119 void
00120 print_usage (void)
00121 {
00122   printf ("%s\n", _("Usage:"));
00123   printf (" %s <integer state> [optional text]\n", progname);
00124 }