sensu-plugins-disk-checks 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +27 -0
- data/README.md +16 -0
- data/bin/check-disk-usage.rb +62 -4
- data/bin/check-smart-status.rb +2 -2
- data/bin/metrics-disk-usage.rb +1 -1
- data/lib/sensu-plugins-disk-checks/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6928e842b69da0370f869cc6bb4ad23002b04730
|
4
|
+
data.tar.gz: 11046434136bfc5fb222777795accc7ab1965987
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f19fd7cf5136f02b029069cc28e0f7c35121a4de6eeff1839d09b01b509feb6893a7d851dc69b3730514d087e42da95cc05ed211bf0a383619e8f34330f1b69c
|
7
|
+
data.tar.gz: 7c8657194de211450f0fb26555e52f19427aecb7e4d229a6120eaf835894f5d08045cc53f16ab409dbc9b8908d62a0c2bb6f5a5e7dedd5ebeaa0d17dccd2d891
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,33 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
6
6
|
## [Unreleased][unreleased]
|
7
7
|
- nothing
|
8
8
|
|
9
|
+
## [1.0.3] - 2015-10-25
|
10
|
+
### Changed
|
11
|
+
- Adds Ignore option(s) to check-disk-usage.rb
|
12
|
+
- Adaptive thresholds
|
13
|
+
|
14
|
+
### Adaptive Thresholds
|
15
|
+
|
16
|
+
This borrows from check_mk's "df" check, which has the ability to
|
17
|
+
adaptively adjust thresholds for filesystems based on their sizes.
|
18
|
+
|
19
|
+
For example, a hard threshold of "warn at 85%" is quite different
|
20
|
+
between small filesystems and very large filesystems - 85% utilization
|
21
|
+
of a 20GB filesystem is arguably more serious than 85% utilization of a
|
22
|
+
10TB filesystem.
|
23
|
+
|
24
|
+
This uses check_mk's original alorithm to optionally adjust the
|
25
|
+
percentage thresholds based on size, using a "magic factor", a
|
26
|
+
"normalized size", and a "minium size to adjust".
|
27
|
+
|
28
|
+
The magic factor defaults to '1.0', which will not adjust thresholds.
|
29
|
+
The minimum size defaults to '100' (GB). Filesystems smaller than this
|
30
|
+
will not be adapted.
|
31
|
+
|
32
|
+
check_mk's documentation has a lot more information on this, including
|
33
|
+
examples of adjustments based on the magic factor:
|
34
|
+
https://mathias-kettner.de/checkmk_filesystems.html
|
35
|
+
|
9
36
|
## [1.0.2] - 2015-08-04
|
10
37
|
### Changed
|
11
38
|
- general cleanup
|
data/README.md
CHANGED
@@ -20,6 +20,22 @@ Check disk capacity and inodes based upon the output of df.
|
|
20
20
|
|
21
21
|
Check disk capacity and inodes based upon the gem sys-filesystem.
|
22
22
|
|
23
|
+
Can adjust thresholds for larger filesystems by providing a 'magic factor'
|
24
|
+
(`-m`). The default, `1.0`, will not adapt threshold percentages for volumes.
|
25
|
+
|
26
|
+
The `-l` option can be used in combination with the 'magic factor' to specify
|
27
|
+
the minimum size volume to adjust the thresholds for.
|
28
|
+
|
29
|
+
Refer to [check_mk's](https://mathias-kettner.de/checkmk_filesystems.html)
|
30
|
+
documentation on adaptive thresholds.
|
31
|
+
|
32
|
+
You can also visualize the adjustment using
|
33
|
+
[WolframAlpha]([https://www.wolframalpha.com/input/) with the following:
|
34
|
+
|
35
|
+
y = 100 - (100-P)*(N^(1-m))/(x^(1-m)), y = P for x in 0 to 1024
|
36
|
+
|
37
|
+
Where P = base percentage, N = normalize factor, and m = magic factor
|
38
|
+
|
23
39
|
**check-fs-writeable**
|
24
40
|
|
25
41
|
Check to make sure a filesytem is writable. This will check both proc and do a smoke test of each given mountpoint. It can also auto-discover mount points in the self namespace.
|
data/bin/check-disk-usage.rb
CHANGED
@@ -48,6 +48,11 @@ class CheckDisk < Sensu::Plugin::Check::CLI
|
|
48
48
|
description: 'Ignore mount point(s)',
|
49
49
|
proc: proc { |a| a.split(',') }
|
50
50
|
|
51
|
+
option :ignoreopt,
|
52
|
+
short: '-o TYPE[.TYPE]',
|
53
|
+
description: 'Ignore option(s)',
|
54
|
+
proc: proc { |a| a.split('.') }
|
55
|
+
|
51
56
|
option :bwarn,
|
52
57
|
short: '-w PERCENT',
|
53
58
|
description: 'Warn if PERCENT or more of disk full',
|
@@ -72,6 +77,26 @@ class CheckDisk < Sensu::Plugin::Check::CLI
|
|
72
77
|
proc: proc(&:to_i),
|
73
78
|
default: 95
|
74
79
|
|
80
|
+
option :magic,
|
81
|
+
short: '-m MAGIC',
|
82
|
+
description: 'Magic factor to adjust warn/crit thresholds. Example: .9',
|
83
|
+
proc: proc(&:to_f),
|
84
|
+
default: 1.0
|
85
|
+
|
86
|
+
option :normal,
|
87
|
+
short: '-n NORMAL',
|
88
|
+
description: 'Levels are not adapted for filesystems of excatly this '\
|
89
|
+
'size, where levels are reduced for smaller filesystems and raised '\
|
90
|
+
'for larger filesystems.',
|
91
|
+
proc: proc(&:to_f),
|
92
|
+
default: 20
|
93
|
+
|
94
|
+
option :minimum,
|
95
|
+
short: '-l MINIMUM',
|
96
|
+
description: 'Minimum size to adjust (in GB)',
|
97
|
+
proc: proc(&:to_f),
|
98
|
+
default: 100
|
99
|
+
|
75
100
|
# Setup variables
|
76
101
|
#
|
77
102
|
def initialize
|
@@ -88,6 +113,7 @@ class CheckDisk < Sensu::Plugin::Check::CLI
|
|
88
113
|
next if config[:fstype] && !config[:fstype].include?(line.mount_type)
|
89
114
|
next if config[:ignoretype] && config[:ignoretype].include?(line.mount_type)
|
90
115
|
next if config[:ignoremnt] && config[:ignoremnt].include?(line.mount_point)
|
116
|
+
next if config[:ignoreopt] && config[:ignoreopt].include?(line.options)
|
91
117
|
rescue
|
92
118
|
unknown 'An error occured getting the mount info'
|
93
119
|
end
|
@@ -95,6 +121,15 @@ class CheckDisk < Sensu::Plugin::Check::CLI
|
|
95
121
|
end
|
96
122
|
end
|
97
123
|
|
124
|
+
# Adjust the percentages based on volume size
|
125
|
+
#
|
126
|
+
def adj_percent(size, percent)
|
127
|
+
hsize = (size / (1024.0 * 1024.0)) / config[:normal].to_f
|
128
|
+
felt = hsize**config[:magic]
|
129
|
+
scale = felt / hsize
|
130
|
+
100 - ((100 - percent) * scale)
|
131
|
+
end
|
132
|
+
|
98
133
|
def check_mount(line)
|
99
134
|
fs_info = Filesystem.stat(line.mount_point)
|
100
135
|
if fs_info.respond_to?(:inodes) # needed for windows
|
@@ -106,11 +141,34 @@ class CheckDisk < Sensu::Plugin::Check::CLI
|
|
106
141
|
end
|
107
142
|
end
|
108
143
|
percent_b = percent_bytes(fs_info)
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
144
|
+
|
145
|
+
if fs_info.bytes_total < (config[:minimum] * 1_000_000_000)
|
146
|
+
bcrit = config[:bcrit]
|
147
|
+
bwarn = config[:bwarn]
|
148
|
+
else
|
149
|
+
bcrit = adj_percent(fs_info.bytes_total, config[:bcrit])
|
150
|
+
bwarn = adj_percent(fs_info.bytes_total, config[:bwarn])
|
151
|
+
end
|
152
|
+
|
153
|
+
used = to_human(fs_info.bytes_used)
|
154
|
+
total = to_human(fs_info.bytes_total)
|
155
|
+
|
156
|
+
if percent_b >= bcrit
|
157
|
+
@crit_fs << "#{line.mount_point} #{percent_b}% bytes usage (#{used}/#{total})"
|
158
|
+
elsif percent_b >= bwarn
|
159
|
+
@warn_fs << "#{line.mount_point} #{percent_b}% bytes usage (#{used}/#{total})"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def to_human(s)
|
164
|
+
prefix = %w(TiB GiB MiB KiB B)
|
165
|
+
s.to_f
|
166
|
+
i = prefix.length - 1
|
167
|
+
while s > 512 && i > 0
|
168
|
+
s /= 1024
|
169
|
+
i -= 1
|
113
170
|
end
|
171
|
+
((s > 9 || s.modulo(1) < 0.1 ? '%d' : '%.1f') % s) + ' ' + prefix[i]
|
114
172
|
end
|
115
173
|
|
116
174
|
# Determine the percent inode usage
|
data/bin/check-smart-status.rb
CHANGED
@@ -119,7 +119,7 @@ class SmartCheckStatus < Sensu::Plugin::Check::CLI
|
|
119
119
|
|
120
120
|
# Main function
|
121
121
|
#
|
122
|
-
def run
|
122
|
+
def run
|
123
123
|
@smart_attributes = JSON.parse(IO.read(File.dirname(__FILE__) + '/smart.json'), symbolize_names: true)[:smart][:attributes]
|
124
124
|
@smart_debug = config[:debug] == 'on'
|
125
125
|
|
@@ -183,7 +183,7 @@ class SmartCheckStatus < Sensu::Plugin::Check::CLI
|
|
183
183
|
end
|
184
184
|
|
185
185
|
# #YELLOW
|
186
|
-
output[dev].split("\n").each do |line|
|
186
|
+
output[dev].split("\n").each do |line|
|
187
187
|
fields = line.split
|
188
188
|
if fields.size == 10 && fields[0].to_i != 0 && att_check_list.include?(fields[0].to_i)
|
189
189
|
smart_att = @smart_attributes.find { |att| att[:id] == fields[0].to_i }
|
data/bin/metrics-disk-usage.rb
CHANGED
@@ -96,7 +96,7 @@ class DiskUsageMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
96
96
|
delim = config[:flatten] == true ? '_' : '.'
|
97
97
|
# Get disk usage from df with used and avail in megabytes
|
98
98
|
# #YELLOW
|
99
|
-
`df -PB#{config[:block_size]} #{config[:local] ? '-l' : ''}`.split("\n").drop(1).each do |line|
|
99
|
+
`df -PB#{config[:block_size]} #{config[:local] ? '-l' : ''}`.split("\n").drop(1).each do |line|
|
100
100
|
_, _, used, avail, used_p, mnt = line.split
|
101
101
|
|
102
102
|
unless %r{/sys|/dev|/run}.match(mnt)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-disk-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
31
|
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: filesystem
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
���
|
2
|
-
�~��7
|
1
|
+
WG��x:I��+�Rb���t}���+>�C���E>� ��\C/0����es�T"U��&ά�^v��)��ku$_ABeA�Kk9Ҧ�w����pZf�<�V{C0��>����N�(�Mߋ����iE�`���:D~�L&����|���:]xrNؠ6�k����=�*=?K.�a,5~#]c|��'Ś����X��4��Q�寢�ݛ�ս-���,l��B��r}')�1M������(E�Q��������6µ
|