sensu-plugins-loadavg 0.0.1
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 +7 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE +23 -0
- data/README.md +32 -0
- data/bin/check-loadavg.rb +70 -0
- data/lib/sensu-plugins-loadavg/version.rb +9 -0
- data/lib/sensu-plugins-loadavg.rb +1 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df3b05686bbdb18d0ece35e3a2c53d22969583c8
|
4
|
+
data.tar.gz: 2fd942022a53b09dcde491d10dc4c183d86713a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b42bff1e8dc33ecaa51395e579b83bb397f581eb3b38d0dd0782478c7296b48e1337b73a1bb8e53548b98216d04e64345967a1820897d425ce53b5c473505469
|
7
|
+
data.tar.gz: c914ea4bf29d2505f1ca02f4a8036f6424d5281d248ed17b37b449bcddb43eed445140a333561ea88d905356698917082895ba4693356ca995aea24cb053435f
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2015 Matteo Cerutti
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Sensu plugin for monitoring the system's load average
|
2
|
+
|
3
|
+
A sensu plugin to monitor the system's load average
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
The plugin accepts the following command line options:
|
8
|
+
|
9
|
+
```
|
10
|
+
Usage: check-loadavg.rb (options)
|
11
|
+
-c, --critical <avg1,avg5,avg15> Critical if avg1/5/15 exceeds the current system load average (default: 16.0,12.0,8.0)
|
12
|
+
-w, --warn <avg1,avg5,avg15> Warn if avg1/5/15 exceeds the current system load average (default: 12.0,8.0,4.0)
|
13
|
+
```
|
14
|
+
|
15
|
+
The default warning thresholds are calculated as follows:
|
16
|
+
|
17
|
+
```
|
18
|
+
avg15 = processorcount * 2
|
19
|
+
avg5 = avg15 + 4
|
20
|
+
avg1 = avg5 + 4
|
21
|
+
```
|
22
|
+
|
23
|
+
The default critical thresholds are calculated as follows:
|
24
|
+
|
25
|
+
```
|
26
|
+
avg15 = processorcount * 4
|
27
|
+
avg5 = avg15 + 4
|
28
|
+
avg1 = avg5 + 4
|
29
|
+
```
|
30
|
+
|
31
|
+
## Author
|
32
|
+
Matteo Cerutti - <matteo.cerutti@hotmail.co.uk>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-loadavg.rb
|
4
|
+
#
|
5
|
+
# Author: Matteo Cerutti <matteo.cerutti@hotmail.co.uk>
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'sensu-plugin/check/cli'
|
9
|
+
|
10
|
+
class CheckLoadAvg < Sensu::Plugin::Check::CLI
|
11
|
+
def self.processor_count()
|
12
|
+
%x[cat /proc/cpuinfo].scan(/^processor/).count
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.default_thresholds(magic)
|
16
|
+
avg15 = (self.processor_count * magic).to_f
|
17
|
+
avg5 = (avg15 + 4).to_f
|
18
|
+
avg1 = (avg5 + 4).to_f
|
19
|
+
|
20
|
+
{'1m' => avg1, '5m' => avg5, '15m' => avg15}
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.thresholds_to_hash(str)
|
24
|
+
th = {}
|
25
|
+
th['1m'], th['5m'], th['15m'] = str.split(',').map(&:to_f)
|
26
|
+
th
|
27
|
+
end
|
28
|
+
|
29
|
+
option :warn,
|
30
|
+
:description => "Warn if avg1/5/15 exceeds the current system load average (default: #{default_thresholds(2).map { |k, v| v }.join(',')})",
|
31
|
+
:short => "-w <avg1,avg5,avg15>",
|
32
|
+
:long => "--warn <avg1,avg5,avg15>",
|
33
|
+
:default => default_thresholds(2),
|
34
|
+
:proc => proc { |s| thresholds_to_hash(s) }
|
35
|
+
|
36
|
+
option :crit,
|
37
|
+
:description => "Critical if avg1/5/15 exceeds the current system load average (default: #{default_thresholds(4).map { |k, v| v }.join(',')})",
|
38
|
+
:short => "-c <avg1,avg5,avg15>",
|
39
|
+
:long => "--critical <avg1,avg5,avg15>",
|
40
|
+
:default => default_thresholds(4),
|
41
|
+
:proc => proc { |s| thresholds_to_hash(s) }
|
42
|
+
|
43
|
+
def initialize()
|
44
|
+
super
|
45
|
+
@loadavg = get_loadavg
|
46
|
+
|
47
|
+
# sanity checks
|
48
|
+
['1m', '5m', '15m'].each do |i|
|
49
|
+
raise "Warning #{i} threshold must be lower than the #{i} critical threshold" if config[:warn][i] >= config[:crit][i]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_loadavg()
|
54
|
+
la = {}
|
55
|
+
la['1m'], la['5m'], la['15m'] = %x[cat /proc/loadavg].split(' ')[0..2].map(&:to_f)
|
56
|
+
la
|
57
|
+
end
|
58
|
+
|
59
|
+
def run
|
60
|
+
['1m', '5m', '15m'].each do |i|
|
61
|
+
critical("Load average over the last #{i} is too high (#{@loadavg[i]} >= #{config[:crit][i]})") if @loadavg[i] >= config[:crit][i]
|
62
|
+
end
|
63
|
+
|
64
|
+
['1m', '5m', '15m'].each do |i|
|
65
|
+
warning("Load average over the last #{i} is high (#{@loadavg[i]} >= #{config[:warn][i]})") if @loadavg[i] >= config[:warn][i]
|
66
|
+
end
|
67
|
+
|
68
|
+
ok("Load average is normal #{@loadavg.inspect}")
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sensu-plugins-loadavg/version'
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-loadavg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matteo Cerutti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sensu-plugin
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.0
|
27
|
+
description: This plugin provides facilities for monitoring the system load average
|
28
|
+
email: "<matteo.cerutti@hotmail.co.uk>"
|
29
|
+
executables:
|
30
|
+
- check-loadavg.rb
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- CHANGELOG.md
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- bin/check-loadavg.rb
|
38
|
+
- lib/sensu-plugins-loadavg.rb
|
39
|
+
- lib/sensu-plugins-loadavg/version.rb
|
40
|
+
homepage: https://github.com/m4ce/sensu-plugins-loadavg
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata:
|
44
|
+
maintainer: "@m4ce"
|
45
|
+
development_status: active
|
46
|
+
production_status: stable
|
47
|
+
release_draft: 'false'
|
48
|
+
release_prerelease: 'false'
|
49
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
50
|
+
in /etc/default/sensu
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.9.3
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.4.5.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Sensu plugins for monitoring the system load average
|
70
|
+
test_files: []
|