summaryrefslogtreecommitdiffstats
path: root/plugins/check_users.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-04 11:38:27 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-04 11:38:27 (GMT)
commit6c19f400fdb3e4a111f068d960065d99e6d99919 (patch)
tree99d72b4c0eeff3a5ff6780c3177b55c1b2dc7aec /plugins/check_users.c
parentc878b033f7f732ba37a398d13c3bbff7e08b6a7d (diff)
downloadmonitoring-plugins-6c19f400fdb3e4a111f068d960065d99e6d99919.tar.gz
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@645 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_users.c')
-rw-r--r--plugins/check_users.c126
1 files changed, 55 insertions, 71 deletions
diff --git a/plugins/check_users.c b/plugins/check_users.c
index 5085107..d4480e7 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -1,49 +1,62 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2
3* This program is free software; you can redistribute it and/or modify 3 This program is free software; you can redistribute it and/or modify
4* it under the terms of the GNU General Public License as published by 4 it under the terms of the GNU General Public License as published by
5* the Free Software Foundation; either version 2 of the License, or 5 the Free Software Foundation; either version 2 of the License, or
6* (at your option) any later version. 6 (at your option) any later version.
7* 7
8* This program is distributed in the hope that it will be useful, 8 This program is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details. 11 GNU General Public License for more details.
12* 12
13* You should have received a copy of the GNU General Public License 13 You should have received a copy of the GNU General Public License
14* along with this program; if not, write to the Free Software 14 along with this program; if not, write to the Free Software
15* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16* 16
17*****************************************************************************/ 17*****************************************************************************/
18 18
19const char *progname = "check_users";
20const char *revision = "$Revision$";
21const char *copyright = "2000-2003";
22const char *email = "nagiosplug-devel@lists.sourceforge.net";
23
19#include "common.h" 24#include "common.h"
20#include "popen.h" 25#include "popen.h"
21#include "utils.h" 26#include "utils.h"
22 27
23const char *progname = "check_users"; 28void
24const char *revision = "$Revision$"; 29print_usage (void)
25const char *copyright = "2002-2003"; 30{
26const char *authors = "Nagios Plugin Development Team"; 31 printf ("Usage: %s -w <users> -c <users>\n", progname);
27const char *email = "nagiosplug-devel@lists.sourceforge.net"; 32 printf (_(UT_HLP_VRS), progname, progname);
33}
28 34
29const char *summary = "\ 35void
36print_help (void)
37{
38 print_revision (progname, revision);
39
40 printf (_("Copyright (c) 1999 Ethan Galstad\n"));
41 printf (_(COPYRIGHT), copyright, email);
42
43 printf (_("\
30This plugin checks the number of users currently logged in on the local\n\ 44This plugin checks the number of users currently logged in on the local\n\
31system and generates an error if the number exceeds the thresholds specified.\n"; 45system and generates an error if the number exceeds the thresholds specified.\n"));
46
47 print_usage ();
32 48
33const char *option_summary = "-w <users> -c <users>"; 49 printf (_(UT_HELP_VRSN));
34 50
35const char *options = "\ 51 printf (_("\
36 -w, --warning=INTEGER\n\ 52 -w, --warning=INTEGER\n\
37 Set WARNING status if more than INTEGER users are logged in\n\ 53 Set WARNING status if more than INTEGER users are logged in\n\
38 -c, --critical=INTEGER\n\ 54 -c, --critical=INTEGER\n\
39 Set CRITICAL status if more than INTEGER users are logged in\n"; 55 Set CRITICAL status if more than INTEGER users are logged in\n"));
40
41const char *standard_options = "\
42 -h, --help\n\
43 Print detailed help screen\n\
44 -V, --version\n\
45 Print version information\n\n";
46 56
57 printf (_(UT_SUPPORT));
58}
59
47#define possibly_set(a,b) ((a) == 0 ? (b) : 0) 60#define possibly_set(a,b) ((a) == 0 ? (b) : 0)
48 61
49int process_arguments (int, char **); 62int process_arguments (int, char **);
@@ -61,18 +74,18 @@ main (int argc, char **argv)
61 char input_buffer[MAX_INPUT_BUFFER]; 74 char input_buffer[MAX_INPUT_BUFFER];
62 75
63 if (process_arguments (argc, argv) == ERROR) 76 if (process_arguments (argc, argv) == ERROR)
64 usage ("Could not parse arguments\n"); 77 usage (_("Could not parse arguments\n"));
65 78
66 /* run the command */ 79 /* run the command */
67 child_process = spopen (WHO_COMMAND); 80 child_process = spopen (WHO_COMMAND);
68 if (child_process == NULL) { 81 if (child_process == NULL) {
69 printf ("Could not open pipe: %s\n", WHO_COMMAND); 82 printf (_("Could not open pipe: %s\n"), WHO_COMMAND);
70 return STATE_UNKNOWN; 83 return STATE_UNKNOWN;
71 } 84 }
72 85
73 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); 86 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
74 if (child_stderr == NULL) 87 if (child_stderr == NULL)
75 printf ("Could not open stderr for %s\n", WHO_COMMAND); 88 printf (_("Could not open stderr for %s\n"), WHO_COMMAND);
76 89
77 users = 0; 90 users = 0;
78 91
@@ -85,7 +98,7 @@ main (int argc, char **argv)
85 } 98 }
86 99
87 /* get total logged in users */ 100 /* get total logged in users */
88 if (sscanf (input_buffer, "# users=%d", &users) == 1) 101 if (sscanf (input_buffer, _("# users=%d"), &users) == 1)
89 break; 102 break;
90 103
91 } 104 }
@@ -108,9 +121,9 @@ main (int argc, char **argv)
108 result = STATE_OK; 121 result = STATE_OK;
109 122
110 if (result == STATE_UNKNOWN) 123 if (result == STATE_UNKNOWN)
111 printf ("Unable to read output\n"); 124 printf (_("Unable to read output\n"));
112 else 125 else
113 printf ("USERS %s - %d users currently logged in\n", state_text (result), 126 printf (_("USERS %s - %d users currently logged in\n"), state_text (result),
114 users); 127 users);
115 128
116 return result; 129 return result;
@@ -146,7 +159,7 @@ process_arguments (int argc, char **argv)
146 159
147 switch (c) { 160 switch (c) {
148 case '?': /* print short usage statement if args not parsable */ 161 case '?': /* print short usage statement if args not parsable */
149 printf ("%s: Unknown argument: %s\n\n", progname, optarg); 162 printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
150 print_usage (); 163 print_usage ();
151 exit (STATE_UNKNOWN); 164 exit (STATE_UNKNOWN);
152 case 'h': /* help */ 165 case 'h': /* help */
@@ -157,12 +170,12 @@ process_arguments (int argc, char **argv)
157 exit (STATE_OK); 170 exit (STATE_OK);
158 case 'c': /* critical */ 171 case 'c': /* critical */
159 if (!is_intnonneg (optarg)) 172 if (!is_intnonneg (optarg))
160 usage ("Critical threshold must be a nonnegative integer\n"); 173 usage (_("Critical threshold must be a nonnegative integer\n"));
161 cusers = atoi (optarg); 174 cusers = atoi (optarg);
162 break; 175 break;
163 case 'w': /* warning */ 176 case 'w': /* warning */
164 if (!is_intnonneg (optarg)) 177 if (!is_intnonneg (optarg))
165 usage ("Warning threshold must be a nonnegative integer\n"); 178 usage (_("Warning threshold must be a nonnegative integer\n"));
166 wusers = atoi (optarg); 179 wusers = atoi (optarg);
167 break; 180 break;
168 } 181 }
@@ -171,44 +184,15 @@ process_arguments (int argc, char **argv)
171 c = optind; 184 c = optind;
172 if (wusers == -1 && argc > c) { 185 if (wusers == -1 && argc > c) {
173 if (is_intnonneg (argv[c]) == FALSE) 186 if (is_intnonneg (argv[c]) == FALSE)
174 usage ("Warning threshold must be a nonnegative integer\n"); 187 usage (_("Warning threshold must be a nonnegative integer\n"));
175 wusers = atoi (argv[c++]); 188 wusers = atoi (argv[c++]);
176 } 189 }
177 190
178 if (cusers == -1 && argc > c) { 191 if (cusers == -1 && argc > c) {
179 if (is_intnonneg (argv[c]) == FALSE) 192 if (is_intnonneg (argv[c]) == FALSE)
180 usage ("Warning threshold must be a nonnegative integer\n"); 193 usage (_("Warning threshold must be a nonnegative integer\n"));
181 cusers = atoi (argv[c]); 194 cusers = atoi (argv[c]);
182 } 195 }
183 196
184 return OK; 197 return OK;
185} 198}
186
187
188
189
190
191void
192print_help (void)
193{
194 print_revision (progname, revision);
195 printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email);
196 printf (summary);
197 print_usage ();
198 printf ("\nOptions:\n");
199 printf (options);
200 printf (standard_options);
201 support ();
202}
203
204
205
206
207
208void
209print_usage (void)
210{
211 printf ("Usage: %s %s\n", progname, option_summary);
212 printf (" %s (-h|--help)\n", progname);
213 printf (" %s (-V|--version)\n", progname);
214}