diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 14:27:01 (GMT) |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 14:27:01 (GMT) |
commit | fa15fdcf5dc2d40aba2f8520108e552b73b1df2b (patch) | |
tree | d51d62db024b317091f42d9ee540da7371e9d170 /plugins/check_dummy.c | |
parent | 0fd0421052fed1972ecbdfdabecba5a616eaa109 (diff) | |
parent | 87eb2bef1ee2a6a42793437b2f5d63f41b1e1806 (diff) | |
download | monitoring-plugins-fa15fdcf5dc2d40aba2f8520108e552b73b1df2b.tar.gz |
Merge branch 'master' into fix/check_ssh-variable-stuff
Diffstat (limited to 'plugins/check_dummy.c')
-rw-r--r-- | plugins/check_dummy.c | 195 |
1 files changed, 91 insertions, 104 deletions
diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c index 212a134..19f6c04 100644 --- a/plugins/check_dummy.c +++ b/plugins/check_dummy.c | |||
@@ -1,124 +1,111 @@ | |||
1 | /***************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | * |
3 | * Monitoring check_dummy plugin | 3 | * Monitoring check_dummy plugin |
4 | * | 4 | * |
5 | * License: GPL | 5 | * License: GPL |
6 | * Copyright (c) 1999-2007 Monitoring Plugins Development Team | 6 | * Copyright (c) 1999-2024 Monitoring Plugins Development Team |
7 | * | 7 | * |
8 | * Description: | 8 | * Description: |
9 | * | 9 | * |
10 | * This file contains the check_dummy plugin | 10 | * This file contains the check_dummy plugin |
11 | * | 11 | * |
12 | * This plugin will simply return the state corresponding to the numeric value | 12 | * This plugin will simply return the state corresponding to the numeric value |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * This program is free software: you can redistribute it and/or modify | 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 | 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 | 17 | * the Free Software Foundation, either version 3 of the License, or |
18 | * (at your option) any later version. | 18 | * (at your option) any later version. |
19 | * | 19 | * |
20 | * This program is distributed in the hope that it will be useful, | 20 | * This program is distributed in the hope that it will be useful, |
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | * GNU General Public License for more details. | 23 | * GNU General Public License for more details. |
24 | * | 24 | * |
25 | * You should have received a copy of the GNU General Public License | 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/>. | 26 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | * | 27 | * |
28 | * | 28 | * |
29 | *****************************************************************************/ | 29 | *****************************************************************************/ |
30 | 30 | ||
31 | const char *progname = "check_dummy"; | 31 | const char *progname = "check_dummy"; |
32 | const char *copyright = "1999-2007"; | 32 | const char *copyright = "1999-2024"; |
33 | const char *email = "devel@monitoring-plugins.org"; | 33 | const char *email = "devel@monitoring-plugins.org"; |
34 | 34 | ||
35 | #include "common.h" | 35 | #include "common.h" |
36 | #include "utils.h" | 36 | #include "utils.h" |
37 | 37 | ||
38 | void print_help (void); | 38 | static void print_help(void); |
39 | void print_usage (void); | 39 | void print_usage(void); |
40 | 40 | ||
41 | 41 | int main(int argc, char **argv) { | |
42 | int | 42 | int result = STATE_UNKNOWN; |
43 | main (int argc, char **argv) | 43 | |
44 | { | 44 | setlocale(LC_ALL, ""); |
45 | int result = STATE_UNKNOWN; | 45 | bindtextdomain(PACKAGE, LOCALEDIR); |
46 | 46 | textdomain(PACKAGE); | |
47 | setlocale (LC_ALL, ""); | 47 | |
48 | bindtextdomain (PACKAGE, LOCALEDIR); | 48 | if (argc < 2) |
49 | textdomain (PACKAGE); | 49 | usage4(_("Could not parse arguments")); |
50 | 50 | else if (strcmp(argv[1], "-V") == 0 || strcmp(argv[1], "--version") == 0) { | |
51 | if (argc < 2) | 51 | print_revision(progname, NP_VERSION); |
52 | usage4 (_("Could not parse arguments")); | 52 | exit(STATE_UNKNOWN); |
53 | else if (strcmp (argv[1], "-V") == 0 || strcmp (argv[1], "--version") == 0) { | 53 | } else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { |
54 | print_revision (progname, NP_VERSION); | 54 | print_help(); |
55 | exit (STATE_UNKNOWN); | 55 | exit(STATE_UNKNOWN); |
56 | } | 56 | } else if (!is_integer(argv[1])) |
57 | else if (strcmp (argv[1], "-h") == 0 || strcmp (argv[1], "--help") == 0) { | 57 | usage4(_("Arguments to check_dummy must be an integer")); |
58 | print_help (); | 58 | else |
59 | exit (STATE_UNKNOWN); | 59 | result = atoi(argv[1]); |
60 | } | 60 | |
61 | else if (!is_integer (argv[1])) | 61 | switch (result) { |
62 | usage4 (_("Arguments to check_dummy must be an integer")); | 62 | case STATE_OK: |
63 | else | 63 | printf(_("OK")); |
64 | result = atoi (argv[1]); | 64 | break; |
65 | 65 | case STATE_WARNING: | |
66 | switch (result) { | 66 | printf(_("WARNING")); |
67 | case STATE_OK: | 67 | break; |
68 | printf (_("OK")); | 68 | case STATE_CRITICAL: |
69 | break; | 69 | printf(_("CRITICAL")); |
70 | case STATE_WARNING: | 70 | break; |
71 | printf (_("WARNING")); | 71 | case STATE_UNKNOWN: |
72 | break; | 72 | printf(_("UNKNOWN")); |
73 | case STATE_CRITICAL: | 73 | break; |
74 | printf (_("CRITICAL")); | 74 | default: |
75 | break; | 75 | printf(_("UNKNOWN")); |
76 | case STATE_UNKNOWN: | 76 | printf(": "); |
77 | printf (_("UNKNOWN")); | 77 | printf(_("Status %d is not a supported error state\n"), result); |
78 | break; | 78 | return STATE_UNKNOWN; |
79 | default: | 79 | } |
80 | printf (_("UNKNOWN")); | 80 | |
81 | printf (": "); | 81 | if (argc >= 3) |
82 | printf (_("Status %d is not a supported error state\n"), result); | 82 | printf(": %s", argv[2]); |
83 | return STATE_UNKNOWN; | 83 | |
84 | } | 84 | printf("\n"); |
85 | 85 | ||
86 | if (argc >= 3) | 86 | return result; |
87 | printf (": %s", argv[2]); | ||
88 | |||
89 | printf("\n"); | ||
90 | |||
91 | return result; | ||
92 | } | 87 | } |
93 | 88 | ||
89 | void print_help(void) { | ||
90 | print_revision(progname, NP_VERSION); | ||
94 | 91 | ||
92 | printf("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"); | ||
93 | printf(COPYRIGHT, copyright, email); | ||
95 | 94 | ||
96 | void | 95 | printf("%s\n", _("This plugin will simply return the state corresponding to the numeric value")); |
97 | print_help (void) | ||
98 | { | ||
99 | print_revision (progname, NP_VERSION); | ||
100 | 96 | ||
101 | printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"); | 97 | printf("%s\n", _("of the <state> argument with optional text")); |
102 | printf (COPYRIGHT, copyright, email); | ||
103 | 98 | ||
104 | printf ("%s\n", _("This plugin will simply return the state corresponding to the numeric value")); | 99 | printf("\n\n"); |
105 | 100 | ||
106 | printf ("%s\n", _("of the <state> argument with optional text")); | 101 | print_usage(); |
107 | 102 | ||
108 | printf ("\n\n"); | 103 | printf(UT_HELP_VRSN); |
109 | 104 | ||
110 | print_usage (); | 105 | printf(UT_SUPPORT); |
111 | |||
112 | printf (UT_HELP_VRSN); | ||
113 | |||
114 | printf (UT_SUPPORT); | ||
115 | } | 106 | } |
116 | 107 | ||
117 | 108 | void print_usage(void) { | |
118 | 109 | printf("%s\n", _("Usage:")); | |
119 | void | 110 | printf(" %s <integer state> [optional text]\n", progname); |
120 | print_usage (void) | ||
121 | { | ||
122 | printf ("%s\n", _("Usage:")); | ||
123 | printf (" %s <integer state> [optional text]\n", progname); | ||
124 | } | 111 | } |