summaryrefslogtreecommitdiffstats
path: root/plugins/check_users.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_users.c')
-rw-r--r--plugins/check_users.c86
1 files changed, 49 insertions, 37 deletions
diff --git a/plugins/check_users.c b/plugins/check_users.c
index d4480e70..9e182015 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -25,43 +25,11 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
25#include "popen.h" 25#include "popen.h"
26#include "utils.h" 26#include "utils.h"
27 27
28void
29print_usage (void)
30{
31 printf ("Usage: %s -w <users> -c <users>\n", progname);
32 printf (_(UT_HLP_VRS), progname, progname);
33}
34
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 (_("\
44This plugin checks the number of users currently logged in on the local\n\
45system and generates an error if the number exceeds the thresholds specified.\n"));
46
47 print_usage ();
48
49 printf (_(UT_HELP_VRSN));
50
51 printf (_("\
52 -w, --warning=INTEGER\n\
53 Set WARNING status if more than INTEGER users are logged in\n\
54 -c, --critical=INTEGER\n\
55 Set CRITICAL status if more than INTEGER users are logged in\n"));
56
57 printf (_(UT_SUPPORT));
58}
59
60#define possibly_set(a,b) ((a) == 0 ? (b) : 0) 28#define possibly_set(a,b) ((a) == 0 ? (b) : 0)
61 29
62int process_arguments (int, char **); 30int process_arguments (int, char **);
63void print_usage (void);
64void print_help (void); 31void print_help (void);
32void print_usage (void);
65 33
66int wusers = -1; 34int wusers = -1;
67int cusers = -1; 35int cusers = -1;
@@ -171,12 +139,14 @@ process_arguments (int argc, char **argv)
171 case 'c': /* critical */ 139 case 'c': /* critical */
172 if (!is_intnonneg (optarg)) 140 if (!is_intnonneg (optarg))
173 usage (_("Critical threshold must be a nonnegative integer\n")); 141 usage (_("Critical threshold must be a nonnegative integer\n"));
174 cusers = atoi (optarg); 142 else
143 cusers = atoi (optarg);
175 break; 144 break;
176 case 'w': /* warning */ 145 case 'w': /* warning */
177 if (!is_intnonneg (optarg)) 146 if (!is_intnonneg (optarg))
178 usage (_("Warning threshold must be a nonnegative integer\n")); 147 usage (_("Warning threshold must be a nonnegative integer\n"));
179 wusers = atoi (optarg); 148 else
149 wusers = atoi (optarg);
180 break; 150 break;
181 } 151 }
182 } 152 }
@@ -185,14 +155,56 @@ process_arguments (int argc, char **argv)
185 if (wusers == -1 && argc > c) { 155 if (wusers == -1 && argc > c) {
186 if (is_intnonneg (argv[c]) == FALSE) 156 if (is_intnonneg (argv[c]) == FALSE)
187 usage (_("Warning threshold must be a nonnegative integer\n")); 157 usage (_("Warning threshold must be a nonnegative integer\n"));
188 wusers = atoi (argv[c++]); 158 else
159 wusers = atoi (argv[c++]);
189 } 160 }
190 161
191 if (cusers == -1 && argc > c) { 162 if (cusers == -1 && argc > c) {
192 if (is_intnonneg (argv[c]) == FALSE) 163 if (is_intnonneg (argv[c]) == FALSE)
193 usage (_("Warning threshold must be a nonnegative integer\n")); 164 usage (_("Warning threshold must be a nonnegative integer\n"));
194 cusers = atoi (argv[c]); 165 else
166 cusers = atoi (argv[c]);
195 } 167 }
196 168
197 return OK; 169 return OK;
198} 170}
171
172
173
174
175
176
177void
178print_help (void)
179{
180 print_revision (progname, revision);
181
182 printf (_("Copyright (c) 1999 Ethan Galstad\n"));
183 printf (_(COPYRIGHT), copyright, email);
184
185 printf (_("\
186This plugin checks the number of users currently logged in on the local\n\
187system and generates an error if the number exceeds the thresholds specified.\n"));
188
189 print_usage ();
190
191 printf (_(UT_HELP_VRSN));
192
193 printf (_("\
194 -w, --warning=INTEGER\n\
195 Set WARNING status if more than INTEGER users are logged in\n\
196 -c, --critical=INTEGER\n\
197 Set CRITICAL status if more than INTEGER users are logged in\n"));
198
199 printf (_(UT_SUPPORT));
200}
201
202
203
204
205void
206print_usage (void)
207{
208 printf ("Usage: %s -w <users> -c <users>\n", progname);
209 printf (_(UT_HLP_VRS), progname, progname);
210}