[nagiosplug] check_users: Whitespace fixes, etc.

Nagios Plugin Development nagios-plugins at users.sourceforge.net
Thu Jun 7 10:50:18 CEST 2012


 Module: nagiosplug
 Branch: master
 Commit: 094a6fa2f3b9283c46428a7e38900b98294fc6d4
 Author: Holger Weiss <holger at zedat.fu-berlin.de>
   Date: Thu Jun  7 10:43:15 2012 +0200
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=094a6fa

check_users: Whitespace fixes, etc.

---

 plugins/check_users.c |   38 ++++++++++++++------------------------
 1 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/plugins/check_users.c b/plugins/check_users.c
index fb8bcca..3766292 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);
 }





More information about the Commits mailing list