summaryrefslogtreecommitdiffstats
path: root/web/attachments/116577-check_nt.c.patch
blob: 0d2daba7862346cefd8c3f30df7b1fd8271b89c5 (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
--- plugins/check_nt.c.orig	2005-01-20 17:27:47.000000000 -0500
+++ plugins/check_nt.c	2005-01-20 18:01:41.000000000 -0500
@@ -49,7 +49,8 @@
 	CHECK_PROCSTATE,
 	CHECK_MEMUSE,
 	CHECK_COUNTER,
-	CHECK_FILEAGE
+	CHECK_FILEAGE,
+	CHECK_FREEDISKSPACE
 };
 
 enum {
@@ -201,6 +202,7 @@
 		break;
 
 	case CHECK_USEDDISKSPACE:
+	case CHECK_FREEDISKSPACE:
 
 		if (value_list==NULL)
 			output_message = strdup (_("missing -l parameters"));
@@ -212,8 +214,8 @@
 			free_disk_space=atof(strtok(recv_buffer,"&"));
 			total_disk_space=atof(strtok(NULL,"&"));
 			percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
-			warning_used_space = ((float)warning_value / 100) * total_disk_space;
-			critical_used_space = ((float)critical_value / 100) * total_disk_space;
+			warning_used_space = (vars_to_check==CHECK_FREEDISKSPACE)?(float)warning_value:((float)warning_value / 100) * total_disk_space;
+			critical_used_space = (vars_to_check==CHECK_FREEDISKSPACE)?(float)critical_value:((float)critical_value / 100) * total_disk_space;
 
 			if (free_disk_space>=0) {
 				asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
@@ -223,9 +225,9 @@
 				  (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
 				  critical_used_space / 1073741824, total_disk_space / 1073741824);
 
-				if(check_critical_value==TRUE && percent_used_space >= critical_value)
+				if(check_critical_value==TRUE && free_disk_space <= critical_used_space)
 					return_code=STATE_CRITICAL;
-				else if (check_warning_value==TRUE && percent_used_space >= warning_value)
+				else if (check_warning_value==TRUE && free_disk_space <= warning_used_space)
 					return_code=STATE_WARNING;	
 				else
 					return_code=STATE_OK;	
@@ -527,6 +529,8 @@
 					vars_to_check=CHECK_COUNTER;
 				else if(!strcmp(optarg,"FILEAGE"))
 					vars_to_check=CHECK_FILEAGE;
+				else if(!strcmp(optarg,"FREEDISKSPACE"))
+					vars_to_check=CHECK_FREEDISKSPACE;
 				else
 					return ERROR;
 				break;
@@ -656,7 +660,11 @@
   printf (_("\
    USEDDISKSPACE = Size and percentage of disk use.\n\
      Request a -l parameter containing the drive letter only.\n\
-     Warning and critical thresholds can be specified with -w and -c.\n"));
+     Thresholds can be specified (in precentage used) with -w and -c.\n"));
+  printf (_("\
+   FREEDISKSPACE = Size and percentage of disk use.\n\
+     Request a -l parameter containing the drive letter only.\n\
+     Thresholds can be specified (in megabytes free) with -w and -c.\n"));
   printf (_("\
    MEMUSE = Memory use.\n\
      Warning and critical thresholds can be specified with -w and -c.\n"));