diff options
Diffstat (limited to 'web/attachments/443468-nonrootthreshold.patch')
-rw-r--r-- | web/attachments/443468-nonrootthreshold.patch | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/web/attachments/443468-nonrootthreshold.patch b/web/attachments/443468-nonrootthreshold.patch new file mode 100644 index 0000000..c05cd80 --- /dev/null +++ b/web/attachments/443468-nonrootthreshold.patch | |||
@@ -0,0 +1,64 @@ | |||
1 | Author: Stephen Baynes <stephen.baynes@smoothwall.net> | ||
2 | Description: Calculate performance data thresholds with non-root | ||
3 | figures so consistent with % free and check status. | ||
4 | --- a/plugins/check_disk.c | ||
5 | +++ b/plugins/check_disk.c | ||
6 | @@ -160,9 +160,9 @@ | ||
7 | char *perf; | ||
8 | char *preamble; | ||
9 | double inode_space_pct; | ||
10 | - uintmax_t total, available, available_to_root, used; | ||
11 | + uintmax_t total, total_not_root, available, available_to_root, used; | ||
12 | double dfree_pct = -1, dused_pct = -1; | ||
13 | - double dused_units, dfree_units, dtotal_units; | ||
14 | + double dused_units, dfree_units, dtotal_units, dtotal_not_root_units; | ||
15 | double dused_inodes_percent, dfree_inodes_percent; | ||
16 | double warning_high_tide; | ||
17 | double critical_high_tide; | ||
18 | @@ -308,23 +308,25 @@ | ||
19 | available = fsp.fsu_bavail > fsp.fsu_bfree ? 0 : fsp.fsu_bavail; | ||
20 | available_to_root = fsp.fsu_bfree; | ||
21 | used = total - available_to_root; | ||
22 | + total_not_root = used + available; | ||
23 | |||
24 | if (verbose >= 3) | ||
25 | - printf ("For %s, total=%llu, available=%llu, available_to_root=%llu, used=%llu, fsp.fsu_files=%llu, fsp.fsu_ffree=%llu\n", | ||
26 | - me->me_mountdir, total, available, available_to_root, used, fsp.fsu_files, fsp.fsu_ffree); | ||
27 | + 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", | ||
28 | + me->me_mountdir, total, total_not_root, available, available_to_root, used, fsp.fsu_files, fsp.fsu_ffree); | ||
29 | |||
30 | - dused_pct = calculate_percent( used, used + available ); /* used + available can never be > uintmax */ | ||
31 | + dused_pct = calculate_percent( used, total_not_root ); /* used + available can never be > uintmax */ | ||
32 | |||
33 | dfree_pct = 100 - dused_pct; | ||
34 | dused_units = used*fsp.fsu_blocksize/mult; | ||
35 | dfree_units = available*fsp.fsu_blocksize/mult; | ||
36 | dtotal_units = total*fsp.fsu_blocksize/mult; | ||
37 | + dtotal_not_root_units = total_not_root*fsp.fsu_blocksize/mult; | ||
38 | dused_inodes_percent = calculate_percent(fsp.fsu_files - fsp.fsu_ffree, fsp.fsu_files); | ||
39 | dfree_inodes_percent = 100 - dused_inodes_percent; | ||
40 | |||
41 | if (verbose >= 3) { | ||
42 | - 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", | ||
43 | - me->me_mountdir, dused_pct, dfree_pct, dused_units, dfree_units, dtotal_units, dused_inodes_percent, dfree_inodes_percent, fsp.fsu_blocksize, mult); | ||
44 | + 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", | ||
45 | + 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); | ||
46 | } | ||
47 | |||
48 | /* Threshold comparisons */ | ||
49 | @@ -368,13 +370,13 @@ | ||
50 | warning_high_tide = dtotal_units - path->freespace_units->warning->end; | ||
51 | } | ||
52 | if (path->freespace_percent->warning != NULL) { | ||
53 | - warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_units )); | ||
54 | + warning_high_tide = abs( min( (double) warning_high_tide, (double) (1.0 - path->freespace_percent->warning->end/100)*dtotal_not_root_units )); | ||
55 | } | ||
56 | if (path->freespace_units->critical != NULL) { | ||
57 | critical_high_tide = dtotal_units - path->freespace_units->critical->end; | ||
58 | } | ||
59 | if (path->freespace_percent->critical != NULL) { | ||
60 | - critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_units )); | ||
61 | + critical_high_tide = abs( min( (double) critical_high_tide, (double) (1.0 - path->freespace_percent->critical->end/100)*dtotal_not_root_units )); | ||
62 | } | ||
63 | |||
64 | /* Nb: *_high_tide are unset when == UINT_MAX */ | ||