sensu-plugins-docker-checks 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +3 -2
- data/bin/check-docker-container.rb +18 -3
- data/lib/sensu-plugins-docker-checks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 358a68a10e452abe00d29f24bbdabafc2c827878
|
4
|
+
data.tar.gz: 0b56fba66c9ccb78d3e471c33cd0642a04b7e7b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba4bbd18cb810ab6ad8039764b84e833196d24c550214ca73c70dd9d3f04925a6c2577647483f41585de44a5e7740a2e0c15d1f12785988053c919625ceafde0
|
7
|
+
data.tar.gz: 0282aa18eb0d74230c8c0606bdb100e3207ba5c97b0c241344293c067b685112d1e6e04a18a1d0d6337d7ad22868e35a69cff749401de27da2199d7d011c46d1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# Sensu plugin for monitoring Docker containers
|
2
2
|
|
3
|
-
A sensu plugin to monitor Docker containers.
|
3
|
+
A sensu plugin to monitor Docker containers. The plugin can also notify when a container restarts.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
7
|
The plugin accepts the following command line options:
|
8
8
|
|
9
9
|
```
|
10
|
-
Usage: check-docker-container.rb
|
10
|
+
Usage: check-docker-container.rb <options> <containerId>
|
11
|
+
--uptime <SECONDS> Warn if UPTIME exceeds the container uptime
|
11
12
|
--url <URL> Docker daemon URL (default: unix:///var/run/docker.sock)
|
12
13
|
```
|
13
14
|
|
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
require 'sensu-plugin/check/cli'
|
9
9
|
require 'docker'
|
10
|
+
require 'fileutils'
|
11
|
+
require 'date'
|
10
12
|
|
11
13
|
class CheckDockerContainer < Sensu::Plugin::Check::CLI
|
12
14
|
banner "Usage: #{$0} <options> <containerId>"
|
@@ -16,6 +18,11 @@ class CheckDockerContainer < Sensu::Plugin::Check::CLI
|
|
16
18
|
:long => "--url <URL>",
|
17
19
|
:default => "unix:///var/run/docker.sock"
|
18
20
|
|
21
|
+
option :uptime,
|
22
|
+
:description => "Warn if UPTIME exceeds the container uptime",
|
23
|
+
:long => "--uptime <SECONDS>",
|
24
|
+
:default => 300
|
25
|
+
|
19
26
|
def initialize()
|
20
27
|
super
|
21
28
|
|
@@ -30,15 +37,23 @@ class CheckDockerContainer < Sensu::Plugin::Check::CLI
|
|
30
37
|
begin
|
31
38
|
container = Docker::Container.get(@container_id)
|
32
39
|
|
33
|
-
|
40
|
+
started_at = DateTime.parse(container.info['State']['StartedAt']).to_time
|
41
|
+
finished_at = DateTime.parse(container.info['State']['FinishedAt']).to_time
|
42
|
+
|
43
|
+
uptime = Time.now - started_at
|
44
|
+
if uptime <= config[:uptime] and finished_at != DateTime.parse('0001-01-01T00:00:00Z').to_time
|
45
|
+
warning("Container ID '#{@container_id}' restarted #{uptime.to_i} seconds ago")
|
46
|
+
elsif container.info['State']['Restarting']
|
47
|
+
warning("Container ID '#{@container_id}' is restarting")
|
48
|
+
elsif container.info['State']['Running']
|
34
49
|
ok("Container ID '#{@container_id}' is running")
|
35
50
|
else
|
36
51
|
critical("Container ID '#{@container_id}' is not running")
|
37
52
|
end
|
38
53
|
rescue Docker::Error::NotFoundError
|
39
|
-
critical("Container ID '#{
|
54
|
+
critical("Container ID '#{@container_id}' not running on host (Reason: Not found)")
|
40
55
|
rescue
|
41
|
-
unknown("Failed to look up container ID '#{@container_id}' (#{$!})")
|
56
|
+
unknown("Failed to look up container ID '#{@container_id}' (Reason: #{$!})")
|
42
57
|
end
|
43
58
|
end
|
44
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-docker-checks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Cerutti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|