[Nagiosplug-checkins] CVS: nagiosplug/plugins check_ping.c,1.26,1.27

Karl DeBisschop kdebisschop at users.sourceforge.net
Tue Feb 24 23:57:03 CET 2004


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18922/plugins

Modified Files:
	check_ping.c 
Log Message:
pass timeout to ping if supported with -w parameter (linux)

Index: check_ping.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ping.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** check_ping.c	9 Feb 2004 08:27:54 -0000	1.26
--- check_ping.c	25 Feb 2004 07:49:12 -0000	1.27
***************
*** 67,70 ****
--- 67,71 ----
  {
  	char *cmd = NULL;
+ 	char *rawcmd = NULL;
  	int result = STATE_UNKNOWN;
  	int this_result = STATE_UNKNOWN;
***************
*** 91,115 ****
  
  	for (i = 0 ; i < n_addresses ; i++) {
  
  		/* does the host address of number of packets argument come first? */
! #ifdef PING6_COMMAND
! # ifdef PING_PACKETS_FIRST
! 	if (is_inet6_addr(addresses[i]) && address_family != AF_INET)
! 		asprintf (&cmd, PING6_COMMAND, max_packets, addresses[i]);
! 	else
! 		asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]);
  # else
! 	if (is_inet6_addr(addresses[i]) && address_family != AF_INET) 
! 		asprintf (&cmd, PING6_COMMAND, addresses[i], max_packets);
! 	else
! 		asprintf (&cmd, PING_COMMAND, addresses[i], max_packets);
  # endif
! #else /* USE_IPV6 */
! # ifdef PING_PACKETS_FIRST
! 		asprintf (&cmd, PING_COMMAND, max_packets, addresses[i]);
! # else
! 		asprintf (&cmd, PING_COMMAND, addresses[i], max_packets);
! # endif
! #endif /* USE_IPV6 */
  
  		if (verbose)
--- 92,115 ----
  
  	for (i = 0 ; i < n_addresses ; i++) {
+ 		
+ #ifdef PING6_COMMAND
+ 		if (is_inet6_addr(addresses[i]) && address_family != AF_INET)
+ 			rawcmd = strdup(PING6_COMMAND);
+ 		else
+ 			rawcmd = strdup(PING_COMMAND);
+ #else
+ 		rawcmd = strdup(PING_COMMAND);
+ #endif
  
  		/* does the host address of number of packets argument come first? */
! #ifdef PING_PACKETS_FIRST
! # ifdef PING_HAS_TIMEOUT
! 		asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]);
  # else
! 		asprintf (&cmd, rawcmd, max_packets, addresses[i]);
  # endif
! #else
! 		asprintf (&cmd, rawcmd, addresses[i], max_packets);
! #endif
  
  		if (verbose)
***************
*** 151,155 ****
  
  		result = max_state (result, this_result);
! 
  	}
  
--- 151,156 ----
  
  		result = max_state (result, this_result);
! 		free (rawcmd);
! 		free (cmd);
  	}
  





More information about the Commits mailing list