[Nagiosplug-checkins] nagiosplug/plugins check_nwstat.c,1.30,1.31

Ton Voon tonvoon at users.sourceforge.net
Wed Sep 21 06:06:41 CEST 2005


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

Modified Files:
	check_nwstat.c 
Log Message:
Reopen connections for each query (1296296 - David Sullivan)


Index: check_nwstat.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nwstat.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- check_nwstat.c	11 Jul 2005 22:15:58 -0000	1.30
+++ check_nwstat.c	21 Sep 2005 13:04:54 -0000	1.31
@@ -164,6 +164,9 @@
 			break;
 		}
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"UTIL%s\r\n",temp_buffer);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -195,6 +198,9 @@
 		/* check number of user connections */
 	} else if (vars_to_check==CONNS) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("CONNECT\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -214,6 +220,9 @@
 		/* check % long term cache hits */
 	} else if (vars_to_check==LTCH) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S1\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -233,6 +242,9 @@
 		/* check cache buffers */
 	} else if (vars_to_check==CBUFF) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S2\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -252,6 +264,9 @@
 		/* check dirty cache buffers */
 	} else if (vars_to_check==CDBUFF) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S3\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -271,6 +286,9 @@
 		/* check LRU sitting time in minutes */
 	} else if (vars_to_check==LRUM) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S5\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -291,6 +309,9 @@
 		/* check KB free space on volume */
 	} else if (vars_to_check==VKF) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"VKF%s\r\n",volume_name);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -315,6 +336,9 @@
 		/* check % free space on volume */
 	} else if (vars_to_check==VPF) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"VKF%s\r\n",volume_name);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -352,6 +376,9 @@
 		/* check to see if DS Database is open or closed */
 	} else if (vars_to_check==DSDB) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S11\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -373,6 +400,9 @@
 		/* check to see if logins are enabled */
 	} else if (vars_to_check==LOGINS) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S12\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -386,7 +416,10 @@
 
 		/* check packet receive buffers */
 	} else if (vars_to_check==UPRB || vars_to_check==PUPRB) {
- 
+
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S15\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -394,6 +427,9 @@
 
 		used_packet_receive_buffers=atoi(recv_buffer);
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S16\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -420,6 +456,9 @@
 		/* check SAP table entries */
 	} else if (vars_to_check==SAPENTRIES) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		if (sap_number==-1)
 			asprintf (&send_buffer,"S9\r\n");
 		else
@@ -443,6 +482,9 @@
 		/* check KB purgeable space on volume */
 	} else if (vars_to_check==VKP) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"VKP%s\r\n",volume_name);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -463,6 +505,9 @@
 		/* check % purgeable space on volume */
 	} else if (vars_to_check==VPP) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"VKP%s\r\n",volume_name);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -477,6 +522,9 @@
 
 			purgeable_disk_space=strtoul(recv_buffer,NULL,10);
 
+			close(sd);
+			my_tcp_connect (server_address, server_port, &sd);
+
 			asprintf (&send_buffer,"VKS%s\r\n",volume_name);
 			result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 			if (result!=STATE_OK)
@@ -496,6 +544,9 @@
 		/* check KB not yet purgeable space on volume */
 	} else if (vars_to_check==VKNP) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"VKNP%s\r\n",volume_name);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -516,6 +567,9 @@
 		/* check % not yet purgeable space on volume */
 	} else if (vars_to_check==VPNP) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"VKNP%s\r\n",volume_name);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -530,6 +584,9 @@
 
 			non_purgeable_disk_space=strtoul(recv_buffer,NULL,10);
 
+			close(sd);
+			my_tcp_connect (server_address, server_port, &sd);
+
 			asprintf (&send_buffer,"VKS%s\r\n",volume_name);
 			result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 			if (result!=STATE_OK)
@@ -549,6 +606,9 @@
 		/* check # of open files */
 	} else if (vars_to_check==OFILES) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S18\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -566,6 +626,9 @@
 		/* check # of abended threads (Netware 5.x only) */
 	} else if (vars_to_check==ABENDS) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S17\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -583,6 +646,9 @@
 		/* check # of current service processes (Netware 5.x only) */
 	} else if (vars_to_check==CSPROCS) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S20\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -613,6 +679,9 @@
 		/* check # Timesync Status */
 	} else if (vars_to_check==TSYNC) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S22\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -631,6 +700,9 @@
 		/* check LRU sitting time in secondss */
 	} else if (vars_to_check==LRUS) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S4\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -647,6 +719,9 @@
 		/* check % dirty cacheobuffers as a percentage of the total*/
 	} else if (vars_to_check==DCB) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S6\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -662,6 +737,9 @@
 		/* check % total cache buffers as a percentage of the original*/
 	} else if (vars_to_check==TCB) {
 
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S7\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -675,6 +753,10 @@
 		asprintf (&output_message,_("Total cache buffers = %lu%% of the original"),total_cache_buffers);
 		
 	} else if (vars_to_check==DSVER) {
+
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S13\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -685,6 +767,10 @@
 		asprintf (&output_message,_("NDS Version %s"),recv_buffer);
 
 	} else if (vars_to_check==UPTIME) {
+
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"UPTIME\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -697,6 +783,10 @@
 		asprintf (&output_message,_("Up %s"),recv_buffer);
 
 	} else if (vars_to_check==NLM) {
+
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S24:%s\r\n",nlm_name);
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)





More information about the Commits mailing list