[Nagiosplug-checkins] CVS: nagiosplug/plugins check_dig.c,1.5,1.6

Karl DeBisschop kdebisschop at users.sourceforge.net
Wed Nov 20 03:29:04 CET 2002


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

Modified Files:
	check_dig.c 
Log Message:
fix solaris SEGV, still need to print meaningful error text

Index: check_dig.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** check_dig.c	20 Nov 2002 01:09:51 -0000	1.5
--- check_dig.c	20 Nov 2002 11:28:50 -0000	1.6
***************
*** 76,81 ****
  		printf ("Could not open stderr for %s\n", command_line);
  
- 	output = strscpy (output, "");
- 
  	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
  
--- 76,79 ----
***************
*** 112,116 ****
  		result = max_state (result, STATE_WARNING);
  		printf ("%s", input_buffer);
! 		if (!strcmp (output, ""))
  			strscpy (output, 1 + index (input_buffer, ':'));
  	}
--- 110,114 ----
  		result = max_state (result, STATE_WARNING);
  		printf ("%s", input_buffer);
! 		if (strlen (output) == 0)
  			strscpy (output, 1 + index (input_buffer, ':'));
  	}
***************
*** 121,145 ****
  	if (spclose (child_process)) {
  		result = max_state (result, STATE_WARNING);
! 		if (!strcmp (output, ""))
! 			strscpy (output, "nslookup returned error status");
  	}
  
  	(void) time (&end_time);
  
  	if (result == STATE_OK)
  		printf ("DNS ok - %d seconds response time (%s)\n",
  						(int) (end_time - start_time), output);
  	else if (result == STATE_WARNING)
! 		printf ("DNS WARNING - %s\n",
! 						!strcmp (output,
! 										 "") ? " Probably a non-existent host/domain" : output);
  	else if (result == STATE_CRITICAL)
! 		printf ("DNS CRITICAL - %s\n",
! 						!strcmp (output,
! 										 "") ? " Probably a non-existent host/domain" : output);
  	else
! 		printf ("DNS problem - %s\n",
! 						!strcmp (output,
! 										 "") ? " Probably a non-existent host/domain" : output);
  
  	return result;
--- 119,140 ----
  	if (spclose (child_process)) {
  		result = max_state (result, STATE_WARNING);
! 		if (strlen (output) == 0)
! 			strscpy (output, "dig returned error status");
  	}
  
  	(void) time (&end_time);
  
+ 	if (output == NULL || strcmp (output, "") == 0 || strlen (output) == 0 || strspn (output, " \t\r\n") == strlen (output))
+ 		strscpy (output, " Probably a non-existent host/domain");
+ 
  	if (result == STATE_OK)
  		printf ("DNS ok - %d seconds response time (%s)\n",
  						(int) (end_time - start_time), output);
  	else if (result == STATE_WARNING)
! 		printf ("DNS WARNING - %s\n", output);
  	else if (result == STATE_CRITICAL)
! 		printf ("DNS CRITICAL - %s\n", output);
  	else
! 		printf ("DNS problem - %s\n", output);
  
  	return result;





More information about the Commits mailing list