continuent-tools-monitoring 0.0.5 → 0.1.0
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
- data/lib/continuent-tools-nagios-monitor.rb +81 -26
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0cdf9cdd109262fd654369f613ade4ebacb4076
|
4
|
+
data.tar.gz: cd9c9d3bf3d44937c54ffb85fb0c0c20135d706b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6f96cb930f082eda33f06446f47dff461cf77c8874474648850521b6c4a939c80bc780cc6262df3ed3367f34b63259b5e19fcc1b39d9074b696639b214aa090
|
7
|
+
data.tar.gz: bef6cbbd17ef496cb5408cce15c27d448d5a92fa3d2e7d0cc6815995dee48618cc5a435caeef1cee9ed46b6da4306b910f5f1ac737b228f4230dca78c96123d5
|
@@ -2,64 +2,119 @@ module TungstenNagiosMonitor
|
|
2
2
|
NAGIOS_OK=0
|
3
3
|
NAGIOS_WARNING=1
|
4
4
|
NAGIOS_CRITICAL=2
|
5
|
+
NAGIOS_UNKNOWN=3
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
})
|
7
|
+
# This script supports the warning (-w) and critical (-c) arguments.
|
8
|
+
# Override this function to return true if you would like to use
|
9
|
+
# those arguments.
|
10
|
+
def uses_thresholds?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
# Compare the value to the collected threshold values as floats
|
15
|
+
def check_threshold(value)
|
16
|
+
unless value.to_s() =~ /^[0-9\.]+$/
|
17
|
+
unknown("Unable to compare a non-numeric value : #{value}")
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
check = value.to_s().to_f()
|
21
|
+
if check >= opt(:critical_level).to_f()
|
22
|
+
critical(build_critical_message(value))
|
23
|
+
elsif check >= opt(:warning_level).to_f()
|
24
|
+
warning(build_warning_message(value))
|
25
|
+
else
|
26
|
+
ok(build_ok_message(value))
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
25
|
-
|
26
|
-
|
30
|
+
# Build an output string when the value has passed
|
31
|
+
def build_ok_message(value)
|
32
|
+
"Value is OK (#{value})"
|
33
|
+
end
|
34
|
+
|
35
|
+
# Build an output string when the value is at a warning level
|
36
|
+
def build_warning_message(value)
|
37
|
+
"Value is too high (#{value})"
|
38
|
+
end
|
39
|
+
|
40
|
+
# Build an output string when the value is critical
|
41
|
+
def build_critical_message(value)
|
42
|
+
"Value is too high (#{value})"
|
27
43
|
end
|
28
44
|
|
45
|
+
# Add a key=>value pair to the performance data
|
29
46
|
def add_perfdata(key, value)
|
30
47
|
@perfdata << "#{key}=#{value};"
|
31
48
|
end
|
32
49
|
|
50
|
+
# Return a Nagios-formatted performance data string
|
33
51
|
def perfdata
|
34
52
|
@perfdata.join(" ")
|
35
53
|
end
|
36
54
|
|
37
|
-
|
55
|
+
# Output a Nagios-formatted success return message and return the
|
56
|
+
# OK code
|
57
|
+
def ok(msg)
|
38
58
|
opt(:nagios_status_sent, true)
|
39
|
-
|
59
|
+
TU.output "OK: #{msg} | #{perfdata()}"
|
40
60
|
cleanup(NAGIOS_OK)
|
41
61
|
end
|
42
62
|
|
43
|
-
|
63
|
+
# Output a Nagios-formatted warning return message and return the
|
64
|
+
# warning code
|
65
|
+
def warning(msg)
|
44
66
|
opt(:nagios_status_sent, true)
|
45
|
-
|
67
|
+
TU.output "WARNING: #{msg} | #{perfdata()}"
|
46
68
|
cleanup(NAGIOS_WARNING)
|
47
69
|
end
|
48
70
|
|
49
|
-
|
71
|
+
# Output a Nagios-formatted critical return message and return the
|
72
|
+
# critical code
|
73
|
+
def critical(msg)
|
50
74
|
opt(:nagios_status_sent, true)
|
51
|
-
|
75
|
+
TU.output "CRITICAL: #{msg} | #{perfdata()}"
|
52
76
|
cleanup(NAGIOS_CRITICAL)
|
53
77
|
end
|
54
78
|
|
79
|
+
# Output a Nagios-formatted unknown return message and return the
|
80
|
+
# unknown code
|
81
|
+
def unknown(msg)
|
82
|
+
opt(:nagios_status_sent, true)
|
83
|
+
TU.output "UNKNOWN: #{msg} | #{perfdata()}"
|
84
|
+
cleanup(NAGIOS_UNKNOWN)
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def configure
|
90
|
+
super()
|
91
|
+
|
92
|
+
opt(:nagios_status_sent, false)
|
93
|
+
@perfdata = []
|
94
|
+
|
95
|
+
if uses_thresholds?()
|
96
|
+
add_option(:warning_level, {
|
97
|
+
:on => "-w String",
|
98
|
+
:help => "The warning level for this monitor",
|
99
|
+
:required => true,
|
100
|
+
})
|
101
|
+
|
102
|
+
add_option(:critical_level, {
|
103
|
+
:on => "-c String",
|
104
|
+
:help => "The critical level for this monitor",
|
105
|
+
:required => true,
|
106
|
+
})
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
55
110
|
def cleanup(code = 0)
|
56
111
|
if opt(:nagios_status_sent) == false
|
57
112
|
if code == 0
|
58
|
-
|
113
|
+
TU.output "OK: No errors | #{perfdata()}"
|
59
114
|
code = NAGIOS_OK
|
60
115
|
else
|
61
|
-
|
62
|
-
code =
|
116
|
+
TU.output "UNKNOWN: Errors were encountered while running this script | #{perfdata()}"
|
117
|
+
code = NAGIOS_UNKNOWN
|
63
118
|
end
|
64
119
|
end
|
65
120
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: continuent-tools-monitoring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Continuent
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: continuent-tools-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.0
|
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
|
-
version:
|
26
|
+
version: 0.1.0
|
27
27
|
description:
|
28
28
|
email: info@continuent.com
|
29
29
|
executables:
|
@@ -60,5 +60,5 @@ rubyforge_project:
|
|
60
60
|
rubygems_version: 2.0.3
|
61
61
|
signing_key:
|
62
62
|
specification_version: 4
|
63
|
-
summary: Continuent
|
63
|
+
summary: Continuent Tungsten tools core monitoring tools
|
64
64
|
test_files: []
|