Merge pull request #2045 from RincewindsHat/fix/calloc_argument_order
[monitoring-plugins.git] / plugins / check_dummy.c
blob19f6c0468d839b1350f6e5ecde96391e8a8e25fb
1 /*****************************************************************************
3 * Monitoring check_dummy plugin
5 * License: GPL
6 * Copyright (c) 1999-2024 Monitoring Plugins Development Team
8 * Description:
10 * This file contains the check_dummy plugin
12 * This plugin will simply return the state corresponding to the numeric value
15 * This program is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *****************************************************************************/
31 const char *progname = "check_dummy";
32 const char *copyright = "1999-2024";
33 const char *email = "devel@monitoring-plugins.org";
35 #include "common.h"
36 #include "utils.h"
38 static void print_help(void);
39 void print_usage(void);
41 int main(int argc, char **argv) {
42 int result = STATE_UNKNOWN;
44 setlocale(LC_ALL, "");
45 bindtextdomain(PACKAGE, LOCALEDIR);
46 textdomain(PACKAGE);
48 if (argc < 2)
49 usage4(_("Could not parse arguments"));
50 else if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) {
51 print_revision(progname, NP_VERSION);
52 exit(STATE_UNKNOWN);
53 } else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
54 print_help();
55 exit(STATE_UNKNOWN);
56 } else if (!is_integer(argv[1]))
57 usage4(_("Arguments to check_dummy must be an integer"));
58 else
59 result = atoi(argv[1]);
61 switch (result) {
62 case STATE_OK:
63 printf(_("OK"));
64 break;
65 case STATE_WARNING:
66 printf(_("WARNING"));
67 break;
68 case STATE_CRITICAL:
69 printf(_("CRITICAL"));
70 break;
71 case STATE_UNKNOWN:
72 printf(_("UNKNOWN"));
73 break;
74 default:
75 printf(_("UNKNOWN"));
76 printf(": ");
77 printf(_("Status %d is not a supported error state\n"), result);
78 return STATE_UNKNOWN;
81 if (argc >= 3)
82 printf(": %s", argv[2]);
84 printf("\n");
86 return result;
89 void print_help(void) {
90 print_revision(progname, NP_VERSION);
92 printf("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
93 printf(COPYRIGHT, copyright, email);
95 printf("%s\n", _("This plugin will simply return the state corresponding to the numeric value"));
97 printf("%s\n", _("of the <state> argument with optional text"));
99 printf("\n\n");
101 print_usage();
103 printf(UT_HELP_VRSN);
105 printf(UT_SUPPORT);
108 void print_usage(void) {
109 printf("%s\n", _("Usage:"));
110 printf(" %s <integer state> [optional text]\n", progname);