[Nagiosplug-checkins] CVS: nagiosplug/plugins check_fping.c,1.10,1.11

Karl DeBisschop kdebisschop at users.sourceforge.net
Tue Aug 26 07:12:55 CEST 2003


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

Modified Files:
	check_fping.c 
Log Message:
print perfdata

Index: check_fping.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_fping.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_fping.c	22 Aug 2003 06:22:37 -0000	1.10
--- check_fping.c	26 Aug 2003 10:51:03 -0000	1.11
***************
*** 1,34 ****
  /******************************************************************************
! *
! * CHECK_FPING.C
! *
! * Program: Fping plugin for Nagios
! * License: GPL
! * Copyright (c) 1999 Didi Rieder (adrieder at sbox.tu-graz.ac.at)
! * $Id$
! *
! * Modifications:
! *
! * 08-24-1999 Didi Rieder (adrieder at sbox.tu-graz.ac.at)
! *            Intial Coding
! * 09-11-1999 Karl DeBisschop (kdebiss at alum.mit.edu)
! *            Change to spopen
! *            Fix so that state unknown is returned by default
! *            (formerly would give state ok if no fping specified)
! *            Add server_name to output
! *            Reformat to 80-character standard screen
! * 11-18-1999 Karl DeBisschop (kdebiss at alum.mit.edu)
! *            set STATE_WARNING of stderr written or nonzero status returned
! *
! * Description:
! *
! * This plugin will use the /bin/fping command (from saint) to ping
! * the specified host for a fast check if the host is alive. Note that
! * it is necessary to set the suid flag on fping.
  ******************************************************************************/
  
  const char *progname = "check_fping";
  const char *revision = "$Revision$";
! const char *copyright = "1999-2003";
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
--- 1,23 ----
  /******************************************************************************
! 
!  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_fping";
  const char *revision = "$Revision$";
! const char *copyright = "2000-2003";
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
***************
*** 38,48 ****
  #include "utils.h"
  
! #define PACKET_COUNT 1
! #define PACKET_SIZE 56
! #define UNKNOWN_PACKET_LOSS 200	/* 200% */
! #define UNKNOWN_TRIP_TIME -1.0	/* -1 seconds */
! 
! #define PL 0
! #define RTA 1
  
  int textscan (char *buf);
--- 27,36 ----
  #include "utils.h"
  
! enum {
! 	PACKET_COUNT = 1,
! 	PACKET_SIZE = 56,
! 	PL = 0,
! 	RTA = 1
! };
  
  int textscan (char *buf);
***************
*** 53,63 ****
  
  char *server_name = NULL;
- int cpl = UNKNOWN_PACKET_LOSS;
- int wpl = UNKNOWN_PACKET_LOSS;
- double crta = UNKNOWN_TRIP_TIME;
- double wrta = UNKNOWN_TRIP_TIME;
  int packet_size = PACKET_SIZE;
  int packet_count = PACKET_COUNT;
  int verbose = FALSE;
  
  int
--- 41,55 ----
  
  char *server_name = NULL;
  int packet_size = PACKET_SIZE;
  int packet_count = PACKET_COUNT;
  int verbose = FALSE;
+ int cpl;
+ int wpl;
+ double crta;
+ double wrta;
+ int cpl_p = FALSE;
+ int wpl_p = FALSE;
+ int crta_p = FALSE;
+ int wrta_p = FALSE;
  
  int
***************
*** 161,176 ****
  		loss = strtod (losstr, NULL);
  		rta = strtod (rtastr, NULL);
! 		if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
  			status = STATE_CRITICAL;
! 		else if (crta <= 0 && rta > crta)
  			status = STATE_CRITICAL;
! 		else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
  			status = STATE_WARNING;
! 		else if (wrta >= 0 && rta > wrta)
  			status = STATE_WARNING;
  		else
  			status = STATE_OK;
! 		die (status, _("FPING %s - %s (loss=%f%%, rta=%f ms)\n"),
! 							 state_text (status), server_name, loss, rta);
  
  	}
--- 153,171 ----
  		loss = strtod (losstr, NULL);
  		rta = strtod (rtastr, NULL);
! 		if (cpl_p == TRUE && loss > cpl)
  			status = STATE_CRITICAL;
! 		else if (crta_p == TRUE  && rta > crta)
  			status = STATE_CRITICAL;
! 		else if (wpl_p == TRUE && loss > wpl)
  			status = STATE_WARNING;
! 		else if (wrta_p == TRUE && rta > wrta)
  			status = STATE_WARNING;
  		else
  			status = STATE_OK;
! 		die (status,
! 		      _("FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"),
! 				 state_text (status), server_name, loss, rta,
! 		     perfdata ("loss", (int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100),
! 		     perfdata ("rta", (long int)(rta*1.0e3), "us", wrta_p, (long int)(wrta*1.0e3), crta_p, (long int)(crta*1.0e3), TRUE, 0, FALSE, 0));
  
  	}
***************
*** 183,195 ****
  		if (atoi(losstr) == 100)
  			status = STATE_CRITICAL;
! 		else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
  			status = STATE_CRITICAL;
! 		else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
  			status = STATE_WARNING;
  		else
  			status = STATE_OK;
! 		
! 		die (status, _("FPING %s - %s (loss=%f%% )\n"),
! 							 state_text (status), server_name, loss );		
  	
  	}
--- 178,191 ----
  		if (atoi(losstr) == 100)
  			status = STATE_CRITICAL;
! 		else if (cpl_p == TRUE && loss > cpl)
  			status = STATE_CRITICAL;
! 		else if (wpl_p == TRUE && loss > wpl)
  			status = STATE_WARNING;
  		else
  			status = STATE_OK;
! 		/* loss=%.0f%%;%d;%d;0;100 */
! 		die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"),
! 		     state_text (status), server_name, loss ,
! 		     perfdata ("loss", (int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100));
  	
  	}
***************
*** 268,276 ****
  			get_threshold (optarg, rv);
  			if (rv[RTA]) {
! 				crta = strtod (rv[RTA], NULL);
  				rv[RTA] = NULL;
  			}
  			if (rv[PL]) {
  				cpl = atoi (rv[PL]);
  				rv[PL] = NULL;
  			}
--- 264,274 ----
  			get_threshold (optarg, rv);
  			if (rv[RTA]) {
! 				crta = 1e3 * strtod (rv[RTA], NULL);
! 				crta_p = TRUE;
  				rv[RTA] = NULL;
  			}
  			if (rv[PL]) {
  				cpl = atoi (rv[PL]);
+ 				cpl_p = TRUE;
  				rv[PL] = NULL;
  			}
***************
*** 279,287 ****
  			get_threshold (optarg, rv);
  			if (rv[RTA]) {
! 				wrta = strtod (rv[RTA], NULL);
  				rv[RTA] = NULL;
  			}
  			if (rv[PL]) {
  				wpl = atoi (rv[PL]);
  				rv[PL] = NULL;
  			}
--- 277,287 ----
  			get_threshold (optarg, rv);
  			if (rv[RTA]) {
! 				wrta = 1e3 * strtod (rv[RTA], NULL);
! 				wrta_p = TRUE;
  				rv[RTA] = NULL;
  			}
  			if (rv[PL]) {
  				wpl = atoi (rv[PL]);
+ 				wpl_p = TRUE;
  				rv[PL] = NULL;
  			}
***************
*** 356,360 ****
  
  
- 
  
  void
--- 356,359 ----
***************
*** 364,369 ****
  	print_revision (progname, "$Revision$");
  
  	printf (_("\
- Copyright (c) 1999 Didi Rieder (adrieder at sbox.tu-graz.ac.at)\n\n\
  This plugin will use the /bin/fping command (from saint) to ping the\n\
  specified host for a fast check if the host is alive. Note that it is\n\
--- 363,370 ----
  	print_revision (progname, "$Revision$");
  
+ 	printf (_("Copyright (c) 1999 Didi Rieder <adrieder at sbox.tu-graz.ac.at>\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
  	printf (_("\
  This plugin will use the /bin/fping command (from saint) to ping the\n\
  specified host for a fast check if the host is alive. Note that it is\n\





More information about the Commits mailing list