nagios 0.0.1 → 0.0.2
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.
- data/README.md +9 -1
- data/lib/nagios/plugin.rb +13 -4
- data/lib/nagios/version.rb +1 -1
- metadata +6 -8
data/README.md
CHANGED
@@ -17,17 +17,25 @@ Subclass `Nagios::Plugin`, and define three methods:
|
|
17
17
|
Example Plugin
|
18
18
|
==============
|
19
19
|
|
20
|
-
In this trivial example, the plugin always measures 2, which is below both the warning and critical thresholds.
|
20
|
+
In this trivial example, the plugin always measures 2, which is below both the warning and critical thresholds. If critical status is reached, the custom `critical_msg` method is called; otherwise, the fallback message is just the measured value.
|
21
21
|
|
22
|
+
require 'rubygems'
|
22
23
|
require 'nagios'
|
23
24
|
|
24
25
|
class FooPlugin < Nagios::Plugin
|
26
|
+
|
25
27
|
def critical(n)
|
26
28
|
n > 5
|
27
29
|
end
|
30
|
+
|
31
|
+
def critical_msg(n)
|
32
|
+
"OH NOES!!! THE VALUE IS #{n}"
|
33
|
+
end
|
34
|
+
|
28
35
|
def warning(n)
|
29
36
|
n > 3
|
30
37
|
end
|
38
|
+
|
31
39
|
def measure
|
32
40
|
2
|
33
41
|
end
|
data/lib/nagios/plugin.rb
CHANGED
@@ -11,11 +11,11 @@ module Nagios
|
|
11
11
|
begin
|
12
12
|
@value = measure
|
13
13
|
if critical(@value)
|
14
|
-
exit_with :critical, @value
|
14
|
+
exit_with :critical, get_msg(:critical, @value)
|
15
15
|
elsif warning(@value)
|
16
|
-
exit_with :warning, @value
|
16
|
+
exit_with :warning, get_msg(:warning, @value)
|
17
17
|
else
|
18
|
-
exit_with :ok, @value
|
18
|
+
exit_with :ok, get_msg(:ok, @value)
|
19
19
|
end
|
20
20
|
rescue => e
|
21
21
|
exit_unknown e
|
@@ -42,9 +42,18 @@ module Nagios
|
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
45
|
+
def get_msg(level, value)
|
46
|
+
msg_method = "#{level}_msg".to_sym
|
47
|
+
if self.respond_to?(msg_method)
|
48
|
+
self.send(msg_method, value)
|
49
|
+
else
|
50
|
+
value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
45
54
|
def exit_with(level, value)
|
46
55
|
@status = level.to_s.upcase
|
47
|
-
msg = to_s(
|
56
|
+
msg = to_s(value)
|
48
57
|
if @status_used
|
49
58
|
puts msg
|
50
59
|
else
|
data/lib/nagios/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nagios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jerry Chen
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2011-05-24 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: " Nagios-rb is a compact framework for writing Nagios plugins.\n"
|
@@ -36,7 +35,6 @@ files:
|
|
36
35
|
- lib/nagios/version.rb
|
37
36
|
- lib/nagios.rb
|
38
37
|
- LICENSE
|
39
|
-
has_rdoc: true
|
40
38
|
homepage: http://github.com/jcsalterego/nagios-rb
|
41
39
|
licenses: []
|
42
40
|
|
@@ -66,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
64
|
requirements: []
|
67
65
|
|
68
66
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.
|
67
|
+
rubygems_version: 1.7.2
|
70
68
|
signing_key:
|
71
69
|
specification_version: 3
|
72
70
|
summary: nagios-rb is a compact framework for writing Nagios plugins.
|