summaryrefslogtreecommitdiffstats
path: root/web/attachments/141582-diff
blob: f956a504c954e51dcd425ea20fea97873d8f289a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
--- check_nwstat.c	2005-07-11 08:08:39.000000000 +0000
+++ check_nwstat_patched.c	2005-07-11 08:07:02.000000000 +0000
@@ -169,6 +169,10 @@
 		if (result!=STATE_OK)
 			return result;
 		utilization=strtoul(recv_buffer,NULL,10);
+
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("UPTIME\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -325,20 +329,24 @@
 
 			free_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)
 				return result;
 			total_disk_space=strtoul(recv_buffer,NULL,10);
 
-			percent_free_space=(int)(((double)free_disk_space/(double)total_disk_space)*100.0);
+			percent_free_space=(unsigned long)(((double)free_disk_space/(double)total_disk_space)*100.0);
 
 			if (check_critical_value==TRUE && percent_free_space <= critical_value)
 				result=STATE_CRITICAL;
 			else if (check_warning_value==TRUE && percent_free_space <= warning_value)
 				result=STATE_WARNING;
 			free_disk_space/=1024;
-			asprintf (&output_message,_("%lu MB (%lu%%) free on volume %s"),free_disk_space,percent_free_space,volume_name);
+			total_disk_space/=1024;
+			asprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB"),free_disk_space,percent_free_space,volume_name,total_disk_space);
 		}
 
 		/* check to see if DS Database is open or closed */
@@ -353,6 +361,9 @@
 		else
 			result=STATE_WARNING;
  
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		send_buffer = strdup ("S13\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		temp_buffer=strtok(recv_buffer,"\r\n");
@@ -472,7 +483,7 @@
 				return result;
 			total_disk_space=strtoul(recv_buffer,NULL,10);
 
-			percent_purgeable_space=(int)(((double)purgeable_disk_space/(double)total_disk_space)*100.0);
+			percent_purgeable_space=(unsigned long)(((double)purgeable_disk_space/(double)total_disk_space)*100.0);
 
 			if (check_critical_value==TRUE && percent_purgeable_space >= critical_value)
 				result=STATE_CRITICAL;
@@ -525,7 +536,7 @@
 				return result;
 			total_disk_space=strtoul(recv_buffer,NULL,10);
 
-			percent_non_purgeable_space=(int)(((double)non_purgeable_disk_space/(double)total_disk_space)*100.0);
+			percent_non_purgeable_space=(unsigned long)(((double)non_purgeable_disk_space/(double)total_disk_space)*100.0);
 
 			if (check_critical_value==TRUE && percent_non_purgeable_space >= critical_value)
 				result=STATE_CRITICAL;
@@ -579,6 +590,9 @@
  
 		max_service_processes=atoi(recv_buffer);
  
+		close(sd);
+		my_tcp_connect (server_address, server_port, &sd);
+
 		asprintf (&send_buffer,"S21\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
@@ -671,12 +685,15 @@
 		asprintf (&output_message,_("NDS Version %s"),recv_buffer);
 
 	} else if (vars_to_check==UPTIME) {
+		asprintf (&send_buffer,"UPTIME\r\n");
 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
 		if (result!=STATE_OK)
 	 		return result;
 
-		recv_buffer[strlen(recv_buffer)-1]=0;
 
+		recv_buffer[sizeof(recv_buffer)-1]=0;
+		recv_buffer[strlen(recv_buffer)-1]=0;
+	
 		asprintf (&output_message,_("Up %s"),recv_buffer);
 
 	} else if (vars_to_check==NLM) {
@@ -865,8 +882,9 @@
 					vars_to_check=TSYNC;
 				else if (!strcmp(optarg,"DSVER"))
 					vars_to_check=DSVER;
-				else if (!strcmp(optarg,"UPTIME"))
+				else if (!strcmp(optarg,"UPTIME")) {
 					vars_to_check=UPTIME;
+				}
 				else if (strncmp(optarg,"NLM:",4)==0) {
 					vars_to_check=NLM;
 					nlm_name=strdup (optarg+4);