sensu-plugins-memory-checks 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +26 -1
- data/README.md +9 -3
- data/bin/check-memory-percent.sh +6 -3
- data/bin/check-memory.sh +3 -0
- data/bin/check-ram.rb +2 -4
- data/bin/check-swap-percent.rb +77 -4
- data/bin/check-swap.sh +3 -0
- data/bin/metrics-memory-percent.rb +1 -1
- data/lib/sensu-plugins-memory-checks/version.rb +2 -2
- metadata +36 -36
- data/bin/check-swap-percent.sh +0 -47
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MjVkNjVjMTQ0M2YyNzQwYjcyYTZhYjkyNjEzZWU2NmQxMDkwNmNjNw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae11ba95c542661b22a46cd0065c83ba9703c091
|
4
|
+
data.tar.gz: 0ff145a2c2bca6383ce10f9fefd27f84fb4321b4
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Y2M1MmY3MTk2NjNhY2RlNDQzN2U1M2ZlNGM1ZjFmZDE2ZDIyZTFkNjdjYTJk
|
11
|
-
NDRmNGI2MzczYzhhOGEzZjkxMGExYjA5ZmFhNDA2YWNlYjI4YWM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MDljNjVhMmNlNTZjMGY2MGVhZDVhZTdjMDc5ZTc5YWRmMjIzNTlkM2ZhNTQ0
|
14
|
-
ZGMzNzFkNzAzNTEyZWM0NjhkYzdiMGMxYjkwM2U3ZWE5YjRjNWViMTBmYzBh
|
15
|
-
NTJhNWY4YmZjNTk4ZGIzNjUzZjZjMGIxN2IzNzcxYmNlYzVkNTI=
|
6
|
+
metadata.gz: 604a6521102ba15ff88aec2ca8e77d1657d5aadf5ec9390b113dac2dcb053a58fa77411824935935bd64fbf9f325cb5c5cd010fbcafe4bf5e9d5c5ca067e7b4e
|
7
|
+
data.tar.gz: 1c987c2a801cd22a038a9b48250a8b84ad873fe56b7564847215568b4f0a662d2f4932f4f29405d5c0aaaea978f754c42f949c8ca2890635b8b33a67bc40dd33
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,30 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [2.0.0] - 2017-01-17
|
9
|
+
### Breaking Changes
|
10
|
+
- The hardcoded default thresholds of 90% warn 95% critical in `check-ram.rb` when using the `--used` option
|
11
|
+
have been removed so custom thresholds can be passed. To obtain identical behavior configure the check
|
12
|
+
like `check-ram.rb --used -w 90 -c 95`.
|
13
|
+
- Ruby < 2.1 is no longer supported
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- `check-swap-percent.rb`: Add option `--required` to alert if swap is missing (@losisin)
|
17
|
+
- Support for Ruby 2.3.0 (@eheydrick)
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- `check-memory-percent.sh`: Corrected units (from MB to %) in performance data output (@ttarczynski)
|
21
|
+
- `check-ram.rb`: fixed overwriting of cli args for warning and critical when using `--used` (@majormoses)
|
22
|
+
- `check-ram.rb`: Only require vmstat on `#run` (@PChambino)
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
- `check-swap-percent.rb`: Rewrite the check for swap percentage in pure ruby while maintaining backwards compatibility. (@losisin)
|
26
|
+
- set environment varable LANG=C for reliable output parsing (@corro)
|
27
|
+
|
28
|
+
### Removed
|
29
|
+
- Support for Ruby < 2.1 (@eheydrick)
|
30
|
+
- `check-swap-percent.sh`: Remove obsolete shell script. (@losisin)
|
31
|
+
|
8
32
|
## [1.0.2] - 2016-04-12
|
9
33
|
### Fixed
|
10
34
|
- `check-memory.sh`: Update for Ubuntu 16.04 `free` output
|
@@ -68,7 +92,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
68
92
|
### Added
|
69
93
|
- initial release
|
70
94
|
|
71
|
-
[unreleased]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/
|
95
|
+
[unreleased]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/2.0.0...HEAD
|
96
|
+
[2.0.0]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/1.0.2...2.0.0
|
72
97
|
[1.0.2]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/1.0.1...1.0.2
|
73
98
|
[1.0.1]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/1.0.0...1.0.1
|
74
99
|
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-memory-checks/compare/0.0.9...1.0.0
|
data/README.md
CHANGED
@@ -15,13 +15,18 @@
|
|
15
15
|
* bin/check-memory-percent.sh
|
16
16
|
* bin/check-ram.rb
|
17
17
|
* bin/check-swap-percent.rb
|
18
|
-
* bin/check-swap-percent.sh
|
19
18
|
* bin/check-swap.sh
|
20
19
|
* bin/check-swap.rb
|
21
20
|
* bin/metrics-memory-percent.rb
|
22
21
|
* bin/metrics-memory.rb
|
23
22
|
|
24
23
|
## Usage
|
24
|
+
Use `-h` flag on any command to see available usages, `-w` to set warning threshold `-c` to set critical threshold and `-p` to print out performance data.
|
25
|
+
* `/opt/sensu/embedded/bin/check-memory.rb -w 2500 -c 3000` - Values in Megabytes
|
26
|
+
* `/opt/sensu/embedded/bin/check-memory-percent.rb -w 70 -c 80` - Values in Percentages
|
27
|
+
* `/opt/sensu/embedded/bin/check-swap.rb -w 2500 -c 3000` - Values in Megabytes
|
28
|
+
* `/opt/sensu/embedded/bin/check-swap-percent.rb -w 70 -c 80` - Values in Percentages
|
29
|
+
* `/opt/sensu/embedded/bin/metrics-memory.rb -s FooBar` - So metrics are now prepended with foobar, default is machine hostname.
|
25
30
|
|
26
31
|
## Installation
|
27
32
|
|
@@ -30,7 +35,8 @@
|
|
30
35
|
### `bin/check-ram.rb`
|
31
36
|
|
32
37
|
Ruby does not have a good native way without the use of C extensions to grab information on memory usage (outside of running shell commands and parsing out). Because of this `check-ram.rb` uses a gem called `vmstat` which has a somewhat annoying dependency on a gcc to compile the C extensions. In order to not force people to install gcc if they are not using `check-ram.rb` we do not install it by default, and is up to the user to make sure that they install it. This requires two steps and can vary based on your distribution and ruby set up:
|
33
|
-
|
34
|
-
|
38
|
+
* Install `gcc`. If you are on a debian based system it is located in the `build-essential` package.
|
39
|
+
* Install `vmstat` gem into the path that sensu gems are expected to run from:
|
40
|
+
* `sudo /opt/sensu/embedded/bin/gem install vmstat --no-rdoc --no-ri` or the equivalent for installing sensu gems in your configuration management system
|
35
41
|
|
36
42
|
## Notes
|
data/bin/check-memory-percent.sh
CHANGED
@@ -14,6 +14,9 @@
|
|
14
14
|
# Date: 2016-02-15
|
15
15
|
# Modified: J. Brandt Buckley <brandt.buckley@sendgrid.com>
|
16
16
|
|
17
|
+
# set lang
|
18
|
+
LANG=C
|
19
|
+
|
17
20
|
# get arguments
|
18
21
|
|
19
22
|
# #RED
|
@@ -42,8 +45,8 @@ if [ "$hlp" = "yes" ]; then
|
|
42
45
|
exit 0
|
43
46
|
fi
|
44
47
|
|
45
|
-
WARN=${WARN:=
|
46
|
-
CRIT=${CRIT:=
|
48
|
+
WARN=${WARN:=80}
|
49
|
+
CRIT=${CRIT:=90}
|
47
50
|
|
48
51
|
#Get total memory available on machine
|
49
52
|
TotalMem=$(free -m | grep Mem | awk '{ print $2 }')
|
@@ -66,7 +69,7 @@ if [ "$UsedPer" = "" ]; then
|
|
66
69
|
fi
|
67
70
|
|
68
71
|
if [ "$perform" = "yes" ]; then
|
69
|
-
output="system memory usage: $UsedPer% | free memory="$UsedPer"
|
72
|
+
output="system memory usage: $UsedPer% | free memory="$UsedPer"%;$WARN;$CRIT;0"
|
70
73
|
else
|
71
74
|
output="system memory usage: $UsedPer%"
|
72
75
|
fi
|
data/bin/check-memory.sh
CHANGED
data/bin/check-ram.rb
CHANGED
@@ -21,7 +21,8 @@
|
|
21
21
|
#
|
22
22
|
# EXTRA INSTALL INSTRUCTIONS:
|
23
23
|
# You must install gcc. This is needed to compile the vmstat gem
|
24
|
-
# which you must put in a path that sensu can reach.
|
24
|
+
# which you must put in a path that sensu can reach. See the README for
|
25
|
+
# more details.
|
25
26
|
# NOTES:
|
26
27
|
# The default behavior is to check % of RAM free. This can easily
|
27
28
|
# be overwritten via args please see `check-ram.rb --help` for details
|
@@ -33,7 +34,6 @@
|
|
33
34
|
# for details.
|
34
35
|
#
|
35
36
|
require 'sensu-plugin/check/cli'
|
36
|
-
require 'vmstat'
|
37
37
|
|
38
38
|
class CheckRAM < Sensu::Plugin::Check::CLI
|
39
39
|
option :megabytes,
|
@@ -84,8 +84,6 @@ class CheckRAM < Sensu::Plugin::Check::CLI
|
|
84
84
|
# only free or used should be defined, change defaults to mirror free
|
85
85
|
if config[:used]
|
86
86
|
config[:free] = false
|
87
|
-
config[:warn] = 90
|
88
|
-
config[:crit] = 95
|
89
87
|
end
|
90
88
|
|
91
89
|
if config[:megabytes]
|
data/bin/check-swap-percent.rb
CHANGED
@@ -1,6 +1,79 @@
|
|
1
|
-
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# Checks SWAP usage as a % of the total swap
|
5
|
+
#
|
6
|
+
# Date: 2016-11-21
|
7
|
+
# Author: Aleksandar Stojanov <aleksandar.stojanov@polarcape.com>
|
8
|
+
#
|
9
|
+
# PLATFORMS:
|
10
|
+
# Linux
|
11
|
+
#
|
12
|
+
# DEPENDENCIES:
|
13
|
+
# gem: sensu-plugin
|
14
|
+
# commands: free, grep
|
15
|
+
#
|
16
|
+
# USAGE:
|
17
|
+
# check-swap-percent.rb -w warn_percent -c critical_percent
|
18
|
+
#
|
19
|
+
# LICENSE:
|
20
|
+
# Copyright 2016 Aleksandar Stojanov <aleksandar.stojanov@polarcape.com>
|
21
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
22
|
+
# for details.
|
2
23
|
|
3
|
-
|
4
|
-
shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.sh')
|
24
|
+
require 'sensu-plugin/check/cli'
|
5
25
|
|
6
|
-
|
26
|
+
class CheckSWAP < Sensu::Plugin::Check::CLI
|
27
|
+
option :warn,
|
28
|
+
short: '-w WARNING',
|
29
|
+
long: '--warning',
|
30
|
+
proc: proc(&:to_i),
|
31
|
+
default: 70
|
32
|
+
|
33
|
+
option :critical,
|
34
|
+
short: '-c CRITICAL',
|
35
|
+
long: '--critical',
|
36
|
+
proc: proc(&:to_i),
|
37
|
+
default: 80
|
38
|
+
|
39
|
+
option :required,
|
40
|
+
short: '-r',
|
41
|
+
long: '--required',
|
42
|
+
description: 'checks if swap is missing from the machine',
|
43
|
+
boolean: true,
|
44
|
+
default: false
|
45
|
+
|
46
|
+
def run
|
47
|
+
# Get output from free command
|
48
|
+
output_swap = `free -m | grep "Swap"`
|
49
|
+
|
50
|
+
# Prepare total and used swap
|
51
|
+
total_swap = output_swap.split(' ')[1].to_i
|
52
|
+
used_swap = output_swap.split(' ')[2].to_i
|
53
|
+
|
54
|
+
# Check if swap exists
|
55
|
+
if total_swap.zero?
|
56
|
+
if config[:required]
|
57
|
+
critical 'ERROR: SWAP is missing on this machine'
|
58
|
+
else
|
59
|
+
print 'There is no SWAP configured'
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Prepare output message
|
65
|
+
output = "#{used_swap}/#{total_swap}"
|
66
|
+
|
67
|
+
# Calculate round percent from used and total
|
68
|
+
swapp = (100.0 * (used_swap.nonzero? || 1) / total_swap).round(0)
|
69
|
+
|
70
|
+
# Check conditions from config
|
71
|
+
if swapp >= config[:critical]
|
72
|
+
critical "#{swapp}% ; #{output}\n"
|
73
|
+
elsif swapp >= config[:warn]
|
74
|
+
warning "#{swapp}% ; #{output}\n"
|
75
|
+
else
|
76
|
+
ok "#{swapp}% ; #{output}\n"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/bin/check-swap.sh
CHANGED
@@ -67,7 +67,7 @@ class MemoryGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
67
67
|
mem['freeWOBuffersCaches'] = mem['free'] + (mem['buffers'] + mem['cached'])
|
68
68
|
|
69
69
|
# to prevent division by zero
|
70
|
-
swptot = if mem['swapTotal']
|
70
|
+
swptot = if mem['swapTotal'].zero?
|
71
71
|
1
|
72
72
|
else
|
73
73
|
mem['swapTotal']
|
metadata
CHANGED
@@ -1,174 +1,175 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-memory-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.7'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: codeclimate-test-reporter
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: github-markup
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.10'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.10'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '10.5'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '10.5'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: redcarpet
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '3.2'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.2'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.40.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.40.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '3.4'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '3.4'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: vmstat
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - ~>
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 2.1.0
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - ~>
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 2.1.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: yard
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - ~>
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0.8'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - ~>
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.8'
|
167
|
-
description:
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
167
|
+
description: |-
|
168
|
+
This plugin provides native memory instrumentation
|
169
|
+
for monitoring and metrics collection, including:
|
170
|
+
memory usage via `free` and `vmstat`, including metrics.
|
171
|
+
Note that this plugin may have cross-platform issues.
|
172
|
+
email: "<sensu-users@googlegroups.com>"
|
172
173
|
executables:
|
173
174
|
- check-memory-percent.rb
|
174
175
|
- check-memory.rb
|
@@ -189,7 +190,6 @@ files:
|
|
189
190
|
- bin/check-memory.sh
|
190
191
|
- bin/check-ram.rb
|
191
192
|
- bin/check-swap-percent.rb
|
192
|
-
- bin/check-swap-percent.sh
|
193
193
|
- bin/check-swap.rb
|
194
194
|
- bin/check-swap.sh
|
195
195
|
- bin/metrics-memory-percent.rb
|
@@ -200,7 +200,7 @@ homepage: https://github.com/sensu-plugins/sensu-plugins-memory-checks
|
|
200
200
|
licenses:
|
201
201
|
- MIT
|
202
202
|
metadata:
|
203
|
-
maintainer:
|
203
|
+
maintainer: sensu-plugin
|
204
204
|
development_status: active
|
205
205
|
production_status: unstable - testing recommended
|
206
206
|
release_draft: 'false'
|
@@ -212,12 +212,12 @@ require_paths:
|
|
212
212
|
- lib
|
213
213
|
required_ruby_version: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
|
-
- -
|
215
|
+
- - ">="
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
version: 1.
|
217
|
+
version: 2.1.0
|
218
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- -
|
220
|
+
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
data/bin/check-swap-percent.sh
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
#
|
3
|
-
# Checks SWAP usage as a % of the total swap
|
4
|
-
#
|
5
|
-
# Date: 05/12/13
|
6
|
-
# Author: Nick Barrett - EDITD
|
7
|
-
# License: MIT
|
8
|
-
#
|
9
|
-
# Usage: check-swap-percentage.sh -w warn_percent -c critical_percent
|
10
|
-
# Uses free (Linux-only) & bc
|
11
|
-
|
12
|
-
# #RED
|
13
|
-
# input options
|
14
|
-
while getopts ':w:c:' OPT; do
|
15
|
-
case $OPT in
|
16
|
-
w) WARN=$OPTARG;;
|
17
|
-
c) CRIT=$OPTARG;;
|
18
|
-
esac
|
19
|
-
done
|
20
|
-
|
21
|
-
WARN=${WARN:=100}
|
22
|
-
CRIT=${CRIT:=100}
|
23
|
-
|
24
|
-
|
25
|
-
# get swap details
|
26
|
-
USED=`free -m | grep 'Swap:' | awk '{ print $3 }'`
|
27
|
-
TOTAL=`free -m | grep 'Swap:' | awk '{ print $2 }'`
|
28
|
-
|
29
|
-
if [[ $TOTAL -eq 0 ]] ; then
|
30
|
-
echo "There is no SWAP on this machine"
|
31
|
-
exit 0
|
32
|
-
else
|
33
|
-
PERCENT=`echo "scale=3;$USED/$TOTAL*100" | bc -l | awk '{printf "%f", $0}'`
|
34
|
-
|
35
|
-
OUTPUT="Swap usage: $PERCENT%, $USED/$TOTAL"
|
36
|
-
|
37
|
-
if [ "$(echo "$PERCENT >= $CRIT" | bc)" -eq 1 ] ; then
|
38
|
-
echo "SWAP CRITICAL - $OUTPUT"
|
39
|
-
exit 2
|
40
|
-
elif [ "$(echo "$PERCENT >= $WARN" | bc)" -eq 1 ] ; then
|
41
|
-
echo "SWAP WARNING - $OUTPUT"
|
42
|
-
exit 1
|
43
|
-
else
|
44
|
-
echo "SWAP OK - $OUTPUT"
|
45
|
-
exit 0
|
46
|
-
fi
|
47
|
-
fi
|