[Nagiosplug-checkins] CVS: nagiosplug/plugins check_load.c,1.8,1.9

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Aug 7 05:10:05 CEST 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv28870

Modified Files:
	check_load.c 
Log Message:
reorder for consistency, restore prototypes for print_foo, nest #ifdef to avoid pedantic traditional c warn

Index: check_load.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_load.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_load.c	3 Aug 2003 06:19:51 -0000	1.8
--- check_load.c	7 Aug 2003 12:09:43 -0000	1.9
***************
*** 1,27 ****
  /******************************************************************************
!  *
!  * CHECK_LOAD.C
!  *
!  * Written by Felipe Gustavo de Almeida <galmeida at linux.ime.usp.br>
!  * License: GPL
!  * Command line: CHECK_LOAD <wload1> <cload1> <wload5> <cload5> <wload15> <cload15>
!  * First Written: 04/17/99 
!  *
!  * Modifications:
!  * 
!  * 05/18/1999 - Modified to work getloadavg where available, and use uptime
!  *		where neither proc or getloadavg are found.  Also use autoconf.
!  *                 mods by Karl DeBisschop (kdebiss at alum.mit.edu)
!  * 07/01/1999 - Added some #DEFINEs to allow compilation under NetBSD, as
!  *		suggested by Andy Doran.
!  *	           mods by Ethan Galstad (nagios at nagios.org)
!  * 07/17/1999 - Initialized la[] array to prevent NetBSD from complaining
!  *		   mods by Ethan Galstad (nagios at nagios.org)
!  * 08/18/1999 - Integrated some code with common plugin utilities
!  *		   mods by Ethan Galstad (nagios at nagios.org)
!  * $Date$
!  * Note: The load format is the same used by "uptime" and "w"
!  *
!  *****************************************************************************/
  
  const char *progname = "check_load";
--- 1,19 ----
  /******************************************************************************
! 
!  This program is free software; you can redistribute it and/or modify
!  it under the terms of the GNU General Public License as published by
!  the Free Software Foundation; either version 2 of the License, or
!  (at your option) any later version.
! 
!  This program is distributed in the hope that it will be useful,
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  GNU General Public License for more details.
! 
!  You should have received a copy of the GNU General Public License
!  along with this program; if not, write to the Free Software
!  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
! 
! ******************************************************************************/
  
  const char *progname = "check_load";
***************
*** 34,69 ****
  #include "popen.h"
  
- void
- print_usage (void)
- {
- 	printf (_("Usage: %s -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n"),
- 	        progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida at linux.ime.usp.br>\n"));
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("This plugin tests the current system load average.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\
-  -w, --warning=WLOAD1,WLOAD5,WLOAD15\n\
-    Exit with WARNING status if load average exceeds WLOADn\n\
-  -c, --critical=CLOAD1,CLOAD5,CLOAD15\n\
-    Exit with CRITICAL status if load average exceed CLOADn\n\n\
- the load average format is the same used by \"uptime\" and \"w\"\n\n"));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
  #ifdef HAVE_SYS_LOADAVG_H
  #include <sys/loadavg.h>
--- 26,29 ----
***************
*** 80,83 ****
--- 40,45 ----
  int process_arguments (int argc, char **argv);
  int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
  
  float wload1 = -1, wload5 = -1, wload15 = -1;
***************
*** 86,89 ****
--- 48,56 ----
  char *status_line = "";
  
+ 
+ 
+ 
+ 
+ 
  int
  main (int argc, char **argv)
***************
*** 92,102 ****
  	int result;
  	double la[3] = { 0.0, 0.0, 0.0 };	/* NetBSD complains about unitialized arrays */
! #elif HAVE_PROC_LOADAVG==1
  	FILE *fp;
  	char input_buffer[MAX_INPUT_BUFFER];
  	char *tmp_ptr;
! #else
  	int result;
  	char input_buffer[MAX_INPUT_BUFFER];
  #endif
  
--- 59,71 ----
  	int result;
  	double la[3] = { 0.0, 0.0, 0.0 };	/* NetBSD complains about unitialized arrays */
! #else
! # if HAVE_PROC_LOADAVG==1
  	FILE *fp;
  	char input_buffer[MAX_INPUT_BUFFER];
  	char *tmp_ptr;
! # else
  	int result;
  	char input_buffer[MAX_INPUT_BUFFER];
+ # endif
  #endif
  
***************
*** 113,117 ****
  	la5 = la[LOADAVG_5MIN];
  	la15 = la[LOADAVG_15MIN];
! #elif HAVE_PROC_LOADAVG==1
  	fp = fopen (PROC_LOADAVG, "r");
  	if (fp == NULL) {
--- 82,87 ----
  	la5 = la[LOADAVG_5MIN];
  	la15 = la[LOADAVG_15MIN];
! #else
! # if HAVE_PROC_LOADAVG==1
  	fp = fopen (PROC_LOADAVG, "r");
  	if (fp == NULL) {
***************
*** 132,136 ****
  
  	fclose (fp);
! #else
  	child_process = spopen (PATH_TO_UPTIME);
  	if (child_process == NULL) {
--- 102,106 ----
  
  	fclose (fp);
! # else
  	child_process = spopen (PATH_TO_UPTIME);
  	if (child_process == NULL) {
***************
*** 150,153 ****
--- 120,124 ----
  		return STATE_UNKNOWN;
  	}
+ # endif
  #endif
  
***************
*** 155,162 ****
  #if HAVE_GETLOADAVG==1
  		printf (_("Error in getloadavg()\n"));
- #elif HAVE_PROC_LOADAVG==1
- 		printf (_("Error processing %s\n"), PROC_LOADAVG);
  #else
  		printf (_("Error processing %s\n"), PATH_TO_UPTIME);
  #endif
  		return STATE_UNKNOWN;
--- 126,135 ----
  #if HAVE_GETLOADAVG==1
  		printf (_("Error in getloadavg()\n"));
  #else
+ # if HAVE_PROC_LOADAVG==1
+ 		printf (_("Error processing %s\n"), PROC_LOADAVG);
+ # else
  		printf (_("Error processing %s\n"), PATH_TO_UPTIME);
+ # endif
  #endif
  		return STATE_UNKNOWN;
***************
*** 179,182 ****
--- 152,156 ----
  
  
+ 
  /* process command-line arguments */
  int
***************
*** 307,309 ****
--- 281,320 ----
  		usage (_("Parameter inconsistency: 15-minute \"warning load\" greater than \"critical load\".\n"));
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida at linux.ime.usp.br>\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("This plugin tests the current system load average.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+  -w, --warning=WLOAD1,WLOAD5,WLOAD15\n\
+    Exit with WARNING status if load average exceeds WLOADn\n\
+  -c, --critical=CLOAD1,CLOAD5,CLOAD15\n\
+    Exit with CRITICAL status if load average exceed CLOADn\n\n\
+ the load average format is the same used by \"uptime\" and \"w\"\n\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("Usage: %s -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n"),
+ 	        progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }





More information about the Commits mailing list