[Nagiosplug-checkins] CVS: nagiosplug/plugins check_pgsql.c,1.15,1.16

Karl DeBisschop kdebisschop at users.sourceforge.net
Sun Nov 16 22:39:02 CET 2003


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

Modified Files:
	check_pgsql.c 
Log Message:
add perfdata

Index: check_pgsql.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_pgsql.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** check_pgsql.c	22 Aug 2003 06:22:38 -0000	1.15
--- check_pgsql.c	17 Nov 2003 06:37:15 -0000	1.16
***************
*** 119,123 ****
  main (int argc, char **argv)
  {
! 	int elapsed_time;
  
  	/* begin, by setting the parameters for a backend connection if the
--- 119,123 ----
  main (int argc, char **argv)
  {
! 	int elapsed_time, status;
  
  	/* begin, by setting the parameters for a backend connection if the
***************
*** 152,176 ****
  	/* check to see that the backend connection was successfully made */
  	if (PQstatus (conn) == CONNECTION_BAD) {
! 		printf (_("PGSQL: CRITICAL - no connection to '%s' (%s).\n"), dbName,
! 						PQerrorMessage (conn));
  		PQfinish (conn);
  		return STATE_CRITICAL;
  	}
  	else if (elapsed_time > tcrit) {
! 		PQfinish (conn);
! 		printf (_("PGSQL: CRITICAL - database %s (%d sec.)\n"), dbName,
! 						elapsed_time);
! 		return STATE_CRITICAL;
  	}
  	else if (elapsed_time > twarn) {
! 		PQfinish (conn);
! 		printf (_("PGSQL: WARNING - database %s (%d sec.)\n"), dbName, elapsed_time);
! 		return STATE_WARNING;
  	}
  	else {
! 		PQfinish (conn);
! 		printf (_("PGSQL: ok - database %s (%d sec.)\n"), dbName, elapsed_time);
! 		return STATE_OK;
  	}
  }
  
--- 152,175 ----
  	/* check to see that the backend connection was successfully made */
  	if (PQstatus (conn) == CONNECTION_BAD) {
! 		printf (_("PGSQL: CRITICAL - no connection to '%s' (%s).\n"),
! 		        dbName,	PQerrorMessage (conn));
  		PQfinish (conn);
  		return STATE_CRITICAL;
  	}
  	else if (elapsed_time > tcrit) {
! 		status = STATE_CRITICAL;
  	}
  	else if (elapsed_time > twarn) {
! 		status = STATE_WARNING;
  	}
  	else {
! 		status = STATE_OK;
  	}
+ 	PQfinish (conn);
+ 	printf (_("PGSQL: %s - database %s (%d sec.)|%s\n"), 
+ 	        state_text(status), dbName, elapsed_time,
+ 	        perfdata("time", (long)elapsed_time, "s",
+ 	                 twarn, (long)twarn, tcrit, (long)tcrit, TRUE, 0, FALSE,0));
+ 	return status;
  }
  





More information about the Commits mailing list