summaryrefslogtreecommitdiffstats
path: root/web/attachments/443468-nonrootthreshold.patch
blob: c05cd8097bf0893df629cab2385d5ad1ab47e9c9 (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
Author: Stephen Baynes <stephen.baynes@smoothwall.net>
Description: Calculate performance data thresholds with non-root
 figures so consistent with % free and check status.
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -160,9 +160,9 @@
   char *perf;
   char *preamble;
   double inode_space_pct;
-  uintmax_t total, available, available_to_root, used;
+  uintmax_t total, total_not_root, available, available_to_root, used;
   double dfree_pct = -1, dused_pct = -1;
-  double dused_units, dfree_units, dtotal_units;
+  double dused_units, dfree_units, dtotal_units, dtotal_not_root_units;
   double dused_inodes_percent, dfree_inodes_percent;
   double warning_high_tide;
   double critical_high_tide;
@@ -308,23 +308,25 @@
       available = fsp.fsu_bavail > fsp.fsu_bfree ? 0 : fsp.fsu_bavail;
       available_to_root = fsp.fsu_bfree;
       used = total - available_to_root;
+	  total_not_root = used + available;
 
       if (verbose >= 3)
-        printf ("For %s, total=%llu, available=%llu, available_to_root=%llu, used=%llu, fsp.fsu_files=%llu, fsp.fsu_ffree=%llu\n",
-        me->me_mountdir, total, available, available_to_root, used, fsp.fsu_files, fsp.fsu_ffree);
+        printf ("For %s, total=%llu, total_not_root=%llu, available=%llu, available_to_root=%llu, used=%llu, fsp.fsu_files=%llu, fsp.fsu_ffree=%llu\n",
+        me->me_mountdir, total, total_not_root, available, available_to_root, used, fsp.fsu_files, fsp.fsu_ffree);
 
-      dused_pct = calculate_percent( used, used + available );	/* used + available can never be > uintmax */
+      dused_pct = calculate_percent( used, total_not_root );	/* used + available can never be > uintmax */
 
       dfree_pct = 100 - dused_pct;
       dused_units = used*fsp.fsu_blocksize/mult;
       dfree_units = available*fsp.fsu_blocksize/mult;
       dtotal_units = total*fsp.fsu_blocksize/mult;
+      dtotal_not_root_units = total_not_root*fsp.fsu_blocksize/mult;
       dused_inodes_percent = calculate_percent(fsp.fsu_files - fsp.fsu_ffree, fsp.fsu_files);
       dfree_inodes_percent = 100 - dused_inodes_percent;
 
       if (verbose >= 3) {
-        printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n",
-          me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dused_inodes_percent, dfree_inodes_percent, fsp.fsu_blocksize, mult);
+        printf ("For %s, used_pct=%g free_pct=%g used_units=%g free_units=%g total_units=%g total_not_root_units=%g used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n",
+          me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dtotal_not_root_units, dused_inodes_percent, dfree_inodes_percent, fsp.fsu_blocksize, mult);
       }
 
       /* Threshold comparisons */
@@ -368,13 +370,13 @@
         warning_high_tide = dtotal_units - path->freespace_units->warning->end;
       }
       if (path->freespace_percent->warning != NULL) {
-        warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_units ));
+        warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_not_root_units ));
       }
       if (path->freespace_units->critical != NULL) {
         critical_high_tide = dtotal_units - path->freespace_units->critical->end;
       }
       if (path->freespace_percent->critical != NULL) {
-        critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units ));
+        critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_not_root_units ));
       }
 
       /* Nb: *_high_tide are unset when == UINT_MAX */