summaryrefslogtreecommitdiffstats
path: root/web/attachments/351231-check_nwstat.diff
blob: 810eb9f95a38ec6bf641832a01b00ade365f9b78 (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
48a49
> 	VPU,	    /* check % used space on volume */
148a150,151
> 	unsigned long used_disk_space=0L;
>   unsigned long percent_used_disk_space=0L;
454a458,484
> 		/* check % used space on volume */
> 	} else if (vars_to_check==VPU) {
> 		close(sd);
> 		my_tcp_connect (server_address, server_port, &sd);
> 
> 		asprintf (&send_buffer,"VMU%s\r\n",volume_name);
> 		result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
> 		if (result!=STATE_OK)
> 			return result;
> 
> 		if (!strcmp(recv_buffer,"-1\n")) {
> 
> 			asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
> 			result=STATE_CRITICAL;
> 
> 		} else {
> 			used_disk_space=strtoul(recv_buffer,NULL,10);
> 			close(sd);
> 			my_tcp_connect (server_address, server_port, &sd);
>       /* get total volume in MB */
> 			asprintf (&send_buffer,"VMS%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);
>       /* calculate percent used on volume */
> 			percent_used_disk_space=(unsigned long)(((double)used_disk_space/(double)total_disk_space)*100.0);
455a486,501
> 			if (check_critical_value==TRUE && percent_used_disk_space >= critical_value)
> 				result=STATE_CRITICAL;
> 			else if (check_warning_value==TRUE && percent_used_disk_space >= warning_value)
> 				result=STATE_WARNING;
> 			
> 			asprintf (&output_message,_("%lu MB (%lu%%) used on volume %s - total %lu MB|Used space in percent on %s=%lu;%lu;%lu;0;100"),
> 				used_disk_space,
> 				percent_used_disk_space,
> 				volume_name,
> 				total_disk_space,
> 				volume_name,
>         percent_used_disk_space,
>         warning_value,
>         critical_value
>         );
> 		}
1452a1499,1504
> 				else if (strncmp(optarg,"VPU",3)==0) {
> 					vars_to_check=VPU;
> 					volume_name = strdup (optarg+3);
> 					if (!strcmp(volume_name,""))
> 						volume_name = strdup ("SYS");
> 				}
1628a1681
>   printf ("    %s\n", _("    VPU<vol>  = percent used space on Volume <vol>"));