pkg-monitoring-plugins/plugins/check_dummy.c

125 lines
2.9 KiB
C
Raw Normal View History

2013-11-26 22:55:28 +00:00
/*****************************************************************************
*
2014-07-11 19:01:00 +00:00
* Monitoring check_dummy plugin
2013-11-26 22:55:28 +00:00
*
2013-11-26 22:53:19 +00:00
* License: GPL
2014-07-11 19:01:00 +00:00
* Copyright (c) 1999-2007 Monitoring Plugins Development Team
2013-11-26 22:55:28 +00:00
*
2013-11-26 22:53:19 +00:00
* Description:
2013-11-26 22:55:28 +00:00
*
2013-11-26 22:53:19 +00:00
* This file contains the check_dummy plugin
2013-11-26 22:55:28 +00: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
2013-11-26 22:53:19 +00:00
* it under the terms of the GNU General Public License as published by
2013-11-26 22:55:28 +00:00
* the Free Software Foundation, either version 3 of the License, or
2013-11-26 22:53:19 +00:00
* (at your option) any later version.
2013-11-26 22:55:28 +00:00
*
2013-11-26 22:53:19 +00: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.
2013-11-26 22:55:28 +00:00
*
2013-11-26 22:53:19 +00:00
* You should have received a copy of the GNU General Public License
2013-11-26 22:55:28 +00:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*****************************************************************************/
2013-11-26 22:53:19 +00:00
const char *progname = "check_dummy";
2013-11-26 22:55:28 +00:00
const char *copyright = "1999-2007";
2014-07-11 19:01:00 +00:00
const char *email = "devel@monitoring-plugins.org";
2013-11-26 22:53:19 +00:00
#include "common.h"
#include "utils.h"
void print_help (void);
void print_usage (void);
int
main (int argc, char **argv)
{
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) {
print_revision (progname, NP_VERSION);
2013-11-26 22:53:19 +00:00
exit (STATE_OK);
}
else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) {
print_help ();
exit (STATE_OK);
}
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:
2013-11-26 22:54:42 +00:00
printf (_("UNKNOWN"));
printf (": ");
2013-11-26 22:53:19 +00:00
printf (_("Status %d is not a supported error state\n"), result);
2013-11-26 22:54:42 +00:00
return STATE_UNKNOWN;
2013-11-26 22:53:19 +00:00
}
if (argc >= 3)
2013-11-26 22:53:19 +00:00
printf (": %s", argv[2]);
printf("\n");
return result;
}
void
print_help (void)
{
print_revision (progname, NP_VERSION);
2013-11-26 22:53:19 +00:00
printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
printf (COPYRIGHT, copyright, email);
printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
2013-11-26 22:55:28 +00:00
2013-11-26 22:53:19 +00:00
printf ("%s\n", _("of the <state> argument with optional text"));
printf ("\n\n");
2013-11-26 22:55:28 +00:00
2013-11-26 22:53:19 +00:00
print_usage ();
2013-11-26 22:57:29 +00:00
printf (UT_HELP_VRSN);
2013-11-26 22:53:19 +00:00
2013-11-26 22:57:29 +00:00
printf (UT_SUPPORT);
2013-11-26 22:53:19 +00:00
}
void
print_usage (void)
{
2013-11-26 22:57:29 +00:00
printf ("%s\n", _("Usage:"));
2013-11-26 22:53:19 +00:00
printf (" %s <integer state> [optional text]\n", progname);
}