2008-01-30 05:53:47 -05:00
|
|
|
/*****************************************************************************
|
|
|
|
|
*
|
2014-01-19 21:12:50 -05:00
|
|
|
* Monitoring check_dummy plugin
|
2008-01-30 05:53:47 -05:00
|
|
|
*
|
2006-10-18 20:25:16 -04:00
|
|
|
* License: GPL
|
2014-01-18 03:40:24 -05:00
|
|
|
* Copyright (c) 1999-2007 Monitoring Plugins Development Team
|
2008-01-30 05:53:47 -05:00
|
|
|
*
|
2006-10-18 20:25:16 -04:00
|
|
|
* Description:
|
2008-01-30 05:53:47 -05:00
|
|
|
*
|
2006-10-18 20:25:16 -04:00
|
|
|
* This file contains the check_dummy plugin
|
2008-01-30 05:53:47 -05:00
|
|
|
*
|
|
|
|
|
* This plugin will simply return the state corresponding to the numeric value
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2006-10-18 20:25:16 -04:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2008-01-30 05:53:47 -05:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2006-10-18 20:25:16 -04:00
|
|
|
* (at your option) any later version.
|
2008-01-30 05:53:47 -05:00
|
|
|
*
|
2006-10-18 20:25:16 -04:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
2008-01-30 05:53:47 -05:00
|
|
|
*
|
2006-10-18 20:25:16 -04:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2008-01-30 05:53:47 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
2003-08-08 20:41:06 -04:00
|
|
|
|
2003-01-13 07:15:16 -05:00
|
|
|
const char *progname = "check_dummy";
|
2008-01-30 05:53:47 -05:00
|
|
|
const char *copyright = "1999-2007";
|
2014-01-18 03:40:24 -05:00
|
|
|
const char *email = "devel@monitoring-plugins.org";
|
2003-01-13 07:15:16 -05:00
|
|
|
|
2004-12-02 19:55:28 -05:00
|
|
|
#include "common.h"
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
2003-08-08 20:41:06 -04:00
|
|
|
void print_help (void);
|
|
|
|
|
void print_usage (void);
|
2003-08-01 02:04:01 -04:00
|
|
|
|
|
|
|
|
|
2002-02-28 01:42:51 -05:00
|
|
|
int
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
2005-11-13 19:51:44 -05:00
|
|
|
int result = STATE_UNKNOWN;
|
|
|
|
|
|
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
|
|
|
|
textdomain (PACKAGE);
|
|
|
|
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
|
usage4 (_("Could not parse arguments"));
|
|
|
|
|
else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) {
|
2008-11-23 00:38:47 -05:00
|
|
|
print_revision (progname, NP_VERSION);
|
2015-10-04 13:02:43 -04:00
|
|
|
exit (STATE_UNKNOWN);
|
2005-11-13 19:51:44 -05:00
|
|
|
}
|
|
|
|
|
else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
|
|
|
|
|
print_help ();
|
2015-10-04 13:02:43 -04:00
|
|
|
exit (STATE_UNKNOWN);
|
2005-11-13 19:51:44 -05:00
|
|
|
}
|
|
|
|
|
else if (!is_integer (argv[1]))
|
|
|
|
|
usage4 (_("Arguments to check_dummy must be an integer"));
|
|
|
|
|
else
|
|
|
|
|
result = atoi (argv[1]);
|
|
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
|
case STATE_OK:
|
|
|
|
|
printf (_("OK"));
|
|
|
|
|
break;
|
|
|
|
|
case STATE_WARNING:
|
|
|
|
|
printf (_("WARNING"));
|
|
|
|
|
break;
|
|
|
|
|
case STATE_CRITICAL:
|
|
|
|
|
printf (_("CRITICAL"));
|
|
|
|
|
break;
|
|
|
|
|
case STATE_UNKNOWN:
|
|
|
|
|
printf (_("UNKNOWN"));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2007-05-24 04:35:53 -04:00
|
|
|
printf (_("UNKNOWN"));
|
|
|
|
|
printf (": ");
|
2005-11-13 19:51:44 -05:00
|
|
|
printf (_("Status %d is not a supported error state\n"), result);
|
2007-05-24 04:35:53 -04:00
|
|
|
return STATE_UNKNOWN;
|
2005-11-13 19:51:44 -05:00
|
|
|
}
|
|
|
|
|
|
2008-11-19 01:45:18 -05:00
|
|
|
if (argc >= 3)
|
2005-11-13 19:51:44 -05:00
|
|
|
printf (": %s", argv[2]);
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
|
|
return result;
|
2002-02-28 01:42:51 -05:00
|
|
|
}
|
2003-08-08 20:41:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
print_help (void)
|
|
|
|
|
{
|
2008-11-23 00:38:47 -05:00
|
|
|
print_revision (progname, NP_VERSION);
|
2003-08-08 20:41:06 -04:00
|
|
|
|
2005-11-13 19:51:44 -05:00
|
|
|
printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
|
|
|
|
|
printf (COPYRIGHT, copyright, email);
|
2003-08-08 20:41:06 -04:00
|
|
|
|
2006-06-14 17:27:38 -04:00
|
|
|
printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
|
2008-04-27 10:35:26 -04:00
|
|
|
|
2006-06-14 17:27:38 -04:00
|
|
|
printf ("%s\n", _("of the <state> argument with optional text"));
|
2004-12-03 18:02:04 -05:00
|
|
|
|
2005-11-13 19:51:44 -05:00
|
|
|
printf ("\n\n");
|
2008-04-27 10:35:26 -04:00
|
|
|
|
2005-11-13 19:51:44 -05:00
|
|
|
print_usage ();
|
2003-08-08 20:41:06 -04:00
|
|
|
|
2010-04-14 06:11:45 -04:00
|
|
|
printf (UT_HELP_VRSN);
|
2003-08-08 20:41:06 -04:00
|
|
|
|
2010-04-14 06:11:45 -04:00
|
|
|
printf (UT_SUPPORT);
|
2003-08-08 20:41:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
print_usage (void)
|
|
|
|
|
{
|
2010-04-22 08:57:14 -04:00
|
|
|
printf ("%s\n", _("Usage:"));
|
2005-11-13 19:51:44 -05:00
|
|
|
printf (" %s <integer state> [optional text]\n", progname);
|
2003-08-08 20:41:06 -04:00
|
|
|
}
|