sensu-plugins-memory-checks 0.0.5 → 0.0.7
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 +21 -2
- data/bin/check-memory.sh +12 -1
- data/bin/check-ram.rb +60 -17
- data/lib/sensu-plugins-memory-checks/version.rb +1 -1
- metadata +24 -6
- metadata.gz.sig +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a1d5d0e1938f571decbc1ce64c880e8df3c9dd8
|
4
|
+
data.tar.gz: 80aa1e740198b518102d025d3a567fdee778e3d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74df367aa33f827d401f82442560ef15788dee873a12a54623f8bdcc5ca90a9a1934196c868997630b98201da7932f0a4ee1a977396ceaa21a0aaf94485f5a4
|
7
|
+
data.tar.gz: 4303b07011fa7bbf82862c02617b4ad13342f37c63383801f464c8f7841a70e17cb88a374d1d986bc4da29f0854f740e0362346a0d319b0529dcd8714d164a43
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -3,9 +3,21 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
3
3
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
|
-
## Unreleased
|
6
|
+
## [Unreleased][unreleased]
|
7
7
|
|
8
|
-
## [0.0.
|
8
|
+
## [0.0.7] - 2015-08-11
|
9
|
+
### Fixed
|
10
|
+
- check-memory.sh, system may not have /etc/redhat-version
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- bump rubocop
|
14
|
+
|
15
|
+
## [0.0.6] - 2015-07-30
|
16
|
+
- replaced `free` with vmstat gem to add more nix compatibility
|
17
|
+
- added option free (default to keep old default behavior)
|
18
|
+
- added option used to change check to checked used instead of memory free
|
19
|
+
|
20
|
+
## [0.0.5] - 2015-07-14
|
9
21
|
### Fixed
|
10
22
|
- fixed bad script filenames that prevented the checks for executing
|
11
23
|
|
@@ -33,3 +45,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
33
45
|
### Added
|
34
46
|
- initial release
|
35
47
|
|
48
|
+
[unreleased]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.7...HEAD
|
49
|
+
[0.0.7]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.6...0.0.7
|
50
|
+
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.5...0.0.6
|
51
|
+
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.4...0.0.5
|
52
|
+
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.3...0.0.4
|
53
|
+
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.2...0.0.3
|
54
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.1...0.0.2
|
data/bin/check-memory.sh
CHANGED
@@ -41,7 +41,18 @@ fi
|
|
41
41
|
WARN=${WARN:=0}
|
42
42
|
CRIT=${CRIT:=0}
|
43
43
|
|
44
|
-
|
44
|
+
# validate fedora > 20 and rhel > 7.0 and centos > 7.0
|
45
|
+
if [[ -f /etc/redhat-version && `awk '{print $3}' /etc/redhat-release` =~ ^2[0-9]{1} ]]; then
|
46
|
+
redhat_version=1
|
47
|
+
elif [[ -f /etc/redhat-version && `awk '{print $7}' /etc/redhat-version` =~ ^7\.[0-9]{1} ]]; then
|
48
|
+
redhat_version=1
|
49
|
+
elif [[ -f /etc/redhat-release && `awk '{print $4}' /etc/redhat-release` =~ ^7\.[0-9]{1} ]]; then
|
50
|
+
redhat_version=1
|
51
|
+
else
|
52
|
+
redhat_version=0
|
53
|
+
fi
|
54
|
+
|
55
|
+
if [ -f /etc/redhat-release ] && [ $redhat_version = '1' ] ; then
|
45
56
|
FREE_MEMORY=`free -m | grep Mem | awk '{ print $7 }'`
|
46
57
|
else
|
47
58
|
FREE_MEMORY=`free -m | grep buffers/cache | awk '{ print $4 }'`
|
data/bin/check-ram.rb
CHANGED
@@ -13,10 +13,15 @@
|
|
13
13
|
#
|
14
14
|
# DEPENDENCIES:
|
15
15
|
# gem: sensu-plugin
|
16
|
+
# gem: vmstat
|
16
17
|
#
|
17
18
|
# USAGE:
|
19
|
+
# check-ram.rb --help
|
18
20
|
#
|
19
21
|
# NOTES:
|
22
|
+
# The default behavior is to check % of RAM free. This can easily
|
23
|
+
# be overwritten via args please see `check-ram.rb --help` for details
|
24
|
+
# on each option.
|
20
25
|
#
|
21
26
|
# LICENSE:
|
22
27
|
# Copyright 2012 Sonian, Inc <chefs@sonian.net>
|
@@ -24,12 +29,27 @@
|
|
24
29
|
# for details.
|
25
30
|
#
|
26
31
|
require 'sensu-plugin/check/cli'
|
32
|
+
require 'vmstat'
|
27
33
|
|
28
34
|
class CheckRAM < Sensu::Plugin::Check::CLI
|
29
35
|
option :megabytes,
|
30
36
|
short: '-m',
|
31
37
|
long: '--megabytes',
|
32
|
-
description: 'Unless --megabytes is specified the thresholds are in
|
38
|
+
description: 'Unless --megabytes is specified the thresholds are in percentage of memory used as opposed to MB of ram left',
|
39
|
+
boolean: true,
|
40
|
+
default: false
|
41
|
+
|
42
|
+
option :free,
|
43
|
+
short: '-f',
|
44
|
+
long: '--free',
|
45
|
+
description: 'checks free threshold, defaults to true',
|
46
|
+
boolean: true,
|
47
|
+
default: true
|
48
|
+
|
49
|
+
option :used,
|
50
|
+
short: '-u',
|
51
|
+
long: '--used',
|
52
|
+
description: 'checks used threshold, defaults to false',
|
33
53
|
boolean: true,
|
34
54
|
default: false
|
35
55
|
|
@@ -44,29 +64,52 @@ class CheckRAM < Sensu::Plugin::Check::CLI
|
|
44
64
|
default: 5
|
45
65
|
|
46
66
|
def run
|
47
|
-
|
48
|
-
|
67
|
+
# calculating free and used ram based on: https://github.com/threez/ruby-vmstat/issues/4 to emulate free -m
|
68
|
+
mem = Vmstat.snapshot.memory
|
69
|
+
free_ram = mem.inactive_bytes + mem.free_bytes
|
70
|
+
used_ram = mem.wired_bytes + mem.active_bytes
|
71
|
+
total_ram = mem.total_bytes
|
49
72
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
73
|
+
# only free or used should be defined, change defaults to mirror free
|
74
|
+
if config[:used]
|
75
|
+
config[:free] = false
|
76
|
+
config[:warn] = 90
|
77
|
+
config[:crit] = 95
|
54
78
|
end
|
55
79
|
|
56
80
|
if config[:megabytes]
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
81
|
+
# free_ram is returned in Bytes. see: https://github.com/threez/ruby-vmstat/blob/master/lib/vmstat/memory.rb
|
82
|
+
free_ram /= 1024 / 1024
|
83
|
+
used_ram /= 1024 / 1024
|
84
|
+
total_ram /= 1024 / 1024
|
85
|
+
if config[:free]
|
86
|
+
ram = free_ram
|
87
|
+
message "#{ram} megabytes of RAM left"
|
88
|
+
# return used ram
|
89
|
+
elsif config[:used]
|
90
|
+
ram = used_ram
|
91
|
+
message "#{ram} megabytes of RAM used"
|
92
|
+
end
|
93
|
+
# use percentages
|
62
94
|
else
|
63
95
|
unknown 'invalid percentage' if config[:crit] > 100 || config[:warn] > 100
|
64
96
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
97
|
+
if config[:free]
|
98
|
+
ram = (free_ram / total_ram.to_f * 100).round(2)
|
99
|
+
message "#{ram}% RAM free"
|
100
|
+
elsif config[:used]
|
101
|
+
ram = (used_ram / total_ram.to_f * 100).round(2)
|
102
|
+
message "#{ram}% RAM used"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
# determine state
|
106
|
+
if config[:free]
|
107
|
+
critical if ram <= config[:crit]
|
108
|
+
warning if ram <= config[:warn]
|
109
|
+
ok
|
110
|
+
elsif config[:used]
|
111
|
+
critical if ram >= config[:crit]
|
112
|
+
warning if ram >= config[:warn]
|
70
113
|
ok
|
71
114
|
end
|
72
115
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-memory-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
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-08-12 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: sensu-plugin
|
@@ -46,6 +46,20 @@ dependencies:
|
|
46
46
|
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 1.2.0
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: vmstat
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.1.0
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.1.0
|
49
63
|
- !ruby/object:Gem::Dependency
|
50
64
|
name: bundler
|
51
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,14 +164,14 @@ dependencies:
|
|
150
164
|
requirements:
|
151
165
|
- - '='
|
152
166
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
167
|
+
version: 0.32.1
|
154
168
|
type: :development
|
155
169
|
prerelease: false
|
156
170
|
version_requirements: !ruby/object:Gem::Requirement
|
157
171
|
requirements:
|
158
172
|
- - '='
|
159
173
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
174
|
+
version: 0.32.1
|
161
175
|
- !ruby/object:Gem::Dependency
|
162
176
|
name: yard
|
163
177
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,7 +186,11 @@ dependencies:
|
|
172
186
|
- - "~>"
|
173
187
|
- !ruby/object:Gem::Version
|
174
188
|
version: '0.8'
|
175
|
-
description:
|
189
|
+
description: |-
|
190
|
+
This plugin provides native memory instrumentation
|
191
|
+
for monitoring and metrics collection, including:
|
192
|
+
memory usage via `free` and `vmstat`, including metrics.
|
193
|
+
Note that this plugin may have cross-platform issues.
|
176
194
|
email: "<sensu-users@googlegroups.com>"
|
177
195
|
executables:
|
178
196
|
- metrics-memory.rb
|
@@ -227,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
245
|
version: '0'
|
228
246
|
requirements: []
|
229
247
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.4.
|
248
|
+
rubygems_version: 2.4.8
|
231
249
|
signing_key:
|
232
250
|
specification_version: 4
|
233
251
|
summary: Sensu plugins for checking memory
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
���jF�@�iW!��5�v�t��b��w-5*P�M'��ێ��6��ȣ�m��`�@��ʐ6U���.����հ��;�8BNDݨ�D�
|
2
|
+
����4sU��mL^.�0C�՚�c� ���]�i���*��f��E�������bL����Zj������������gk��1��~h�X��~����n�Jy���I�ݫ�nGrSʽ��Ek��
|
3
|
+
�zr9��%�l�"N2��D��
|