aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2012-06-07 10:43:15 +0200
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2012-06-07 10:43:15 +0200
commit094a6fa2f3b9283c46428a7e38900b98294fc6d4 (patch)
tree688b0d05b2c79d64d03f44f4979e36aaaccbca3e /plugins
parente4d9abc4e2ac62c790039232a21109e49529657c (diff)
downloadmonitoring-plugins-094a6fa2f3b9283c46428a7e38900b98294fc6d4.tar.gz
check_users: Whitespace fixes, etc.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_users.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/plugins/check_users.c b/plugins/check_users.c
index fb8bcca3..37662928 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -3,7 +3,7 @@
* Nagios check_users plugin
*
* License: GPL
-* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* Copyright (c) 2000-2012 Nagios Plugins Development Team
*
* Description:
*
@@ -52,7 +52,6 @@ main (int argc, char **argv)
{
int users = -1;
int result = STATE_UNKNOWN;
- char input_buffer[MAX_INPUT_BUFFER];
char *perf;
struct utmpx *putmpx;
@@ -60,10 +59,10 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- perf = strdup("");
+ perf = strdup ("");
/* Parse extra opts if any */
- argv=np_extra_opts (&argc, argv, progname);
+ argv = np_extra_opts (&argc, argv, progname);
if (process_arguments (argc, argv) == ERROR)
usage4 (_("Could not parse arguments"));
@@ -71,15 +70,13 @@ main (int argc, char **argv)
users = 0;
/* get currently logged users from utmpx */
- setutxent();
+ setutxent ();
- while( (putmpx=getutxent()) ) {
- if( (putmpx->ut_type==USER_PROCESS) ) {
+ while ((putmpx = getutxent ()) != NULL)
+ if (putmpx->ut_type == USER_PROCESS)
users++;
- }
- }
- endutxent();
+ endutxent ();
/* check the user count against warning and critical thresholds */
if (users > cusers)
@@ -92,7 +89,7 @@ main (int argc, char **argv)
if (result == STATE_UNKNOWN)
printf ("%s\n", _("Unable to read output"));
else {
- asprintf(&perf, "%s", perfdata ("users", users, "",
+ asprintf (&perf, "%s", perfdata ("users", users, "",
TRUE, wusers,
TRUE, cusers,
TRUE, 0,
@@ -104,14 +101,11 @@ main (int argc, char **argv)
return result;
}
-
-
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
{
int c;
-
int option = 0;
static struct option longopts[] = {
{"critical", required_argument, 0, 'c'},
@@ -161,7 +155,6 @@ process_arguments (int argc, char **argv)
else
wusers = atoi (argv[c++]);
}
-
if (cusers == -1 && argc > c) {
if (is_intnonneg (argv[c]) == FALSE)
usage4 (_("Warning threshold must be a positive integer"));
@@ -172,8 +165,6 @@ process_arguments (int argc, char **argv)
return OK;
}
-
-
void
print_help (void)
{
@@ -183,9 +174,9 @@ print_help (void)
printf (COPYRIGHT, copyright, email);
printf ("%s\n", _("This plugin checks the number of users currently logged in on the local"));
- printf ("%s\n", _("system and generates an error if the number exceeds the thresholds specified."));
+ printf ("%s\n", _("system and generates an error if the number exceeds the thresholds specified."));
- printf ("\n\n");
+ printf ("\n\n");
print_usage ();
@@ -193,17 +184,16 @@ print_help (void)
printf (UT_EXTRA_OPTS);
printf (" %s\n", "-w, --warning=INTEGER");
- printf (" %s\n", _("Set WARNING status if more than INTEGER users are logged in"));
- printf (" %s\n", "-c, --critical=INTEGER");
- printf (" %s\n", _("Set CRITICAL status if more than INTEGER users are logged in"));
+ printf (" %s\n", _("Set WARNING status if more than INTEGER users are logged in"));
+ printf (" %s\n", "-c, --critical=INTEGER");
+ printf (" %s\n", _("Set CRITICAL status if more than INTEGER users are logged in"));
printf (UT_SUPPORT);
}
-
void
print_usage (void)
{
- printf ("%s\n", _("Usage:"));
+ printf ("%s\n", _("Usage:"));
printf ("%s -w <users> -c <users>\n", progname);
}