continuent-tools-monitoring 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0d7ae5dc75775de5dbc42321bc86e4cfab797d8
4
- data.tar.gz: 5cb09af3c3b49ef215a869fe2b0fc047a7ed9bf6
3
+ metadata.gz: 9288db0688c2eae9a9f4f5b2ba1a53cc90436ccb
4
+ data.tar.gz: 4168db3b513e04a05f3679b5a28c718d6c248062
5
5
  SHA512:
6
- metadata.gz: 6790fcd1b480b21184d1cf00c4d741433565b44e35c95674027dce7c216b441304ec7893cb8b9878cf814692b15c2f4e2020853c61a9c1e83a8fd34de264a16d
7
- data.tar.gz: c8a54e4b852d08216cb1b58b9b23b6552931ef4bfcbd842f9e29c5b1427acc65036e3cc34c2ed1bd099acd112686d3b102bc2b117604ccd8b8d9726d1e97ed47
6
+ metadata.gz: 2fb6bc818c63b18f57d92f5cbc5e5414d58d93119ea7e41a70abcfe449d0fd49a62d75b0374ac6861e6a4a3a15dc263a755afd858b959d70de5c66b90333b572
7
+ data.tar.gz: 8dc2d26ba9b7b9f2c6108718394729f096db2aef24b0eb25747e3d2d271745593beb68aed594cfaf49db1401c7e7c1345ba1dc0f16ec3dfb904890898d54947f
@@ -28,9 +28,12 @@ class ContinuentToolsMonitoringJavaThreadCount
28
28
  include TungstenScript
29
29
 
30
30
  def main
31
- TU.forward_cmd_results?(true)
32
- pid = TU.cmd_result("tungsten_java_pid --component=#{opt(:component)}")
33
- TU.forward_cmd_results?(false)
31
+ begin
32
+ pid = TU.tungsten_cmd_result("tungsten_java_pid --component=#{opt(:component)}")
33
+ rescue CommandError => ce
34
+ TU.debug(ce)
35
+ return
36
+ end
34
37
 
35
38
  commands = []
36
39
  commands << "egrep prio"
@@ -41,7 +44,13 @@ class ContinuentToolsMonitoringJavaThreadCount
41
44
  commands << "egrep #{opt(:match)}"
42
45
  end
43
46
 
44
- count = TU.cmd_result("jstack #{pid} | #{commands.join("|")} | wc -l")
47
+ begin
48
+ count = TU.cmd_result("jstack #{pid} | #{commands.join("|")} | wc -l")
49
+ rescue CommandError => ce
50
+ TU.debug(ce)
51
+ TU.error("Unable to run #{ce.command}")
52
+ end
53
+
45
54
  TU.output(count)
46
55
  end
47
56
 
@@ -65,6 +74,12 @@ class ContinuentToolsMonitoringJavaThreadCount
65
74
  unless TU.is_valid?()
66
75
  return TU.is_valid?()
67
76
  end
77
+
78
+ begin
79
+ TU.tungsten_cmd_result("tungsten_java_pid --component=#{opt(:component)} --validate")
80
+ rescue CommandError => ce
81
+ TU.debug(ce)
82
+ end
68
83
  end
69
84
 
70
85
  def script_name
@@ -0,0 +1,68 @@
1
+ module TungstenNagiosMonitor
2
+ NAGIOS_OK=0
3
+ NAGIOS_WARNING=1
4
+ NAGIOS_CRITICAL=2
5
+
6
+ def configure
7
+ super()
8
+
9
+ opt(:nagios_status_sent, false)
10
+ @perfdata = []
11
+
12
+ if uses_nagios_comparison_levels?()
13
+ add_option(:warning_level, {
14
+ :on => "-w String",
15
+ :help => "The warning level for this monitor"
16
+ })
17
+
18
+ add_option(:critical_level, {
19
+ :on => "-c String",
20
+ :help => "The critical level for this monitor"
21
+ })
22
+ end
23
+ end
24
+
25
+ def uses_nagios_comparison_levels?
26
+ false
27
+ end
28
+
29
+ def add_perfdata(key, value)
30
+ @perfdata << "#{key}=#{value};"
31
+ end
32
+
33
+ def perfdata
34
+ @perfdata.join(" ")
35
+ end
36
+
37
+ def nagios_ok(msg)
38
+ opt(:nagios_status_sent, true)
39
+ puts "OK: #{msg} | #{perfdata()}"
40
+ cleanup(NAGIOS_OK)
41
+ end
42
+
43
+ def nagios_warning(msg)
44
+ opt(:nagios_status_sent, true)
45
+ puts "WARNING: #{msg} | #{perfdata()}"
46
+ cleanup(NAGIOS_WARNING)
47
+ end
48
+
49
+ def nagios_critical(msg)
50
+ opt(:nagios_status_sent, true)
51
+ puts "CRITICAL: #{msg} | #{perfdata()}"
52
+ cleanup(NAGIOS_CRITICAL)
53
+ end
54
+
55
+ def cleanup(code = 0)
56
+ if opt(:nagios_status_sent) == false
57
+ if code == 0
58
+ puts "OK: No errors | #{perfdata()}"
59
+ code = NAGIOS_OK
60
+ else
61
+ puts "CRITICAL: Errors were encountered while running this script | #{perfdata()}"
62
+ code = NAGIOS_CRITICAL
63
+ end
64
+ end
65
+
66
+ super(code)
67
+ end
68
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: continuent-tools-monitoring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Continuent
@@ -34,6 +34,7 @@ extra_rdoc_files: []
34
34
  files:
35
35
  - bin/tungsten_java_pid
36
36
  - bin/tungsten_java_thread_count
37
+ - lib/continuent-tools-nagios-monitor.rb
37
38
  - LICENSE
38
39
  - README.md
39
40
  homepage: https://github.com/continuent/continuent-tools-monitoring