continuent-tools-monitoring 0.0.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d71395f0383278a6255969953a2db37388bad2b9
4
- data.tar.gz: 68fbc2b3feffde9bc12352cea009a7b58099c373
3
+ metadata.gz: a0d7ae5dc75775de5dbc42321bc86e4cfab797d8
4
+ data.tar.gz: 5cb09af3c3b49ef215a869fe2b0fc047a7ed9bf6
5
5
  SHA512:
6
- metadata.gz: fff2d7df48ef1722f51dde5098273dc1a9e528f7d20555e316eec7ec8ab6c6e87be6f71bc33a18f21dbd8d5b2fbd72c458cb82f3b0a8dedc791268c161078ce3
7
- data.tar.gz: 1c1efed1e996cddfeff95b6c1ac58059bc0743360e18fbbbd4c61765d5ad35c94cb697a6f511b6dca376900fff2e95cbf7080ae344e546f9e64ad0f9acc77b14
6
+ metadata.gz: 6790fcd1b480b21184d1cf00c4d741433565b44e35c95674027dce7c216b441304ec7893cb8b9878cf814692b15c2f4e2020853c61a9c1e83a8fd34de264a16d
7
+ data.tar.gz: c8a54e4b852d08216cb1b58b9b23b6552931ef4bfcbd842f9e29c5b1427acc65036e3cc34c2ed1bd099acd112686d3b102bc2b117604ccd8b8d9726d1e97ed47
@@ -16,5 +16,83 @@
16
16
  # Initial developer(s): Jeff Mace
17
17
  # Contributor(s):
18
18
 
19
- require 'continuent-tools-monitoring-java-pid'
19
+ begin
20
+ require 'rubygems'
21
+ gem 'continuent-tools-core'
22
+ rescue LoadError
23
+ end
24
+
25
+ require 'continuent-tools-core'
26
+
27
+ class ContinuentToolsMonitoringJavaPID
28
+ include TungstenScript
29
+
30
+ def main
31
+ opt(:wrapper_pid_path, "#{TI.root()}/#{CURRENT_RELEASE_DIRECTORY}/#{opt(:wrapper_pid_path)}")
32
+
33
+ # Make sure the given process is still running
34
+ TU.debug("Look for a PID at #{opt(:wrapper_pid_path)}")
35
+ unless File.exists?(opt(:wrapper_pid_path))
36
+ raise "The requested process is not running"
37
+ end
38
+
39
+ # Extract the PID for the Tanuki Wrapper process
40
+ wrapper_pid = TU.cmd_result("cat #{opt(:wrapper_pid_path)}")
41
+
42
+ # Find the JVM PID by inspecting based on parent PID
43
+ jvm_pid = TU.cmd_result("ps -opid= --ppid=#{wrapper_pid}")
44
+ TU.output(jvm_pid)
45
+ end
46
+
47
+ def configure
48
+ super()
49
+
50
+ add_option(:component, {
51
+ :on => "--component String",
52
+ :help => "The Tungsten component to return a Java PID for"
53
+ })
54
+ end
55
+
56
+ def validate
57
+ super()
58
+
59
+ unless TU.is_valid?()
60
+ return TU.is_valid?()
61
+ end
62
+
63
+ # Make sure that --component is a known value and the component
64
+ # is enabled for the current directory
65
+ case opt(:component).to_s()
66
+ when "tungsten-manager", "manager"
67
+ if TI.is_manager?()
68
+ opt(:wrapper_pid_path, "tungsten-manager/var/tmanager.pid")
69
+ else
70
+ TU.error("Unable to find a manager java PID because the manager is not enabled")
71
+ end
72
+ when "tungsten-replicator", "replicator"
73
+ if TI.is_replicator?()
74
+ opt(:wrapper_pid_path, "tungsten-replicator/var/treplicator.pid")
75
+ else
76
+ TU.error("Unable to find a replicator java PID because the replicator is not enabled")
77
+ end
78
+ when "tungsten-connector", "connector"
79
+ if TI.is_connector?()
80
+ opt(:wrapper_pid_path, "tungsten-connector/var/tconnector.pid")
81
+ else
82
+ TU.error("Unable to find a connector java PID because the connector is not enabled")
83
+ end
84
+ else
85
+ if opt(:component).to_s() == ""
86
+ TU.error("The --component argument is required and must be 'replicator', 'manager', or 'connector'")
87
+ else
88
+ TU.error("Unable to find a java pid for #{opt(:component)}")
89
+ end
90
+ end
91
+ end
92
+
93
+ def script_name
94
+ "tungsten_java_pid"
95
+ end
96
+ end
97
+
20
98
  ContinuentToolsMonitoringJavaPID.new().run()
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2014 Continuent, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+ # not use this file except in compliance with the License. You may obtain
6
+ # a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+ #
16
+ # Initial developer(s): Jeff Mace
17
+ # Contributor(s):
18
+
19
+ begin
20
+ require 'rubygems'
21
+ gem 'continuent-tools-core'
22
+ rescue LoadError
23
+ end
24
+
25
+ require 'continuent-tools-core'
26
+
27
+ class ContinuentToolsMonitoringJavaThreadCount
28
+ include TungstenScript
29
+
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)
34
+
35
+ commands = []
36
+ commands << "egrep prio"
37
+ commands << "egrep tid"
38
+ commands << "egrep nid"
39
+
40
+ if opt(:match).to_s() != ""
41
+ commands << "egrep #{opt(:match)}"
42
+ end
43
+
44
+ count = TU.cmd_result("jstack #{pid} | #{commands.join("|")} | wc -l")
45
+ TU.output(count)
46
+ end
47
+
48
+ def configure
49
+ super()
50
+
51
+ add_option(:component, {
52
+ :on => "--component String",
53
+ :help => "The Tungsten component to return a Java PID for"
54
+ })
55
+
56
+ add_option(:match, {
57
+ :on => "--match String",
58
+ :help => "String to match on to limit the thread count"
59
+ })
60
+ end
61
+
62
+ def validate
63
+ super()
64
+
65
+ unless TU.is_valid?()
66
+ return TU.is_valid?()
67
+ end
68
+ end
69
+
70
+ def script_name
71
+ "tungsten_java_thread_count"
72
+ end
73
+
74
+ self.new().run()
75
+ 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.0
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Continuent
@@ -28,11 +28,12 @@ description:
28
28
  email: info@continuent.com
29
29
  executables:
30
30
  - tungsten_java_pid
31
+ - tungsten_java_thread_count
31
32
  extensions: []
32
33
  extra_rdoc_files: []
33
34
  files:
34
35
  - bin/tungsten_java_pid
35
- - lib/continuent-tools-monitoring-java-pid.rb
36
+ - bin/tungsten_java_thread_count
36
37
  - LICENSE
37
38
  - README.md
38
39
  homepage: https://github.com/continuent/continuent-tools-monitoring
@@ -1,95 +0,0 @@
1
- # Copyright (C) 2014 Continuent, Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
4
- # not use this file except in compliance with the License. You may obtain
5
- # a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
- # License for the specific language governing permissions and limitations
13
- # under the License.
14
- #
15
- # Initial developer(s): Jeff Mace
16
- # Contributor(s):
17
-
18
- begin
19
- require 'rubygems'
20
- gem 'continuent-tools-core'
21
- rescue LoadError
22
- end
23
-
24
- require 'continuent-tools-core'
25
-
26
- class ContinuentToolsMonitoringJavaPID
27
- include TungstenScript
28
-
29
- def main
30
- opt(:wrapper_pid_path, "#{TI.root()}/#{CURRENT_RELEASE_DIRECTORY}/#{opt(:wrapper_pid_path)}")
31
-
32
- # Make sure the given process is still running
33
- TU.debug("Look for a PID at #{opt(:wrapper_pid_path)}")
34
- unless File.exists?(opt(:wrapper_pid_path))
35
- raise "The requested process is not running"
36
- end
37
-
38
- # Extract the PID for the Tanuki Wrapper process
39
- wrapper_pid = TU.cmd_result("cat #{opt(:wrapper_pid_path)}")
40
-
41
- # Find the JVM PID by inspecting based on parent PID
42
- jvm_pid = TU.cmd_result("ps -opid= --ppid=#{wrapper_pid}")
43
- TU.output(jvm_pid)
44
- end
45
-
46
- def configure
47
- super()
48
-
49
- add_option(:component, {
50
- :on => "--component String",
51
- :help => "The Tungsten component to return a Java PID for"
52
- })
53
- end
54
-
55
- def validate
56
- super()
57
-
58
- unless TU.is_valid?()
59
- return TU.is_valid?()
60
- end
61
-
62
- # Make sure that --component is a known value and the component
63
- # is enabled for the current directory
64
- case opt(:component).to_s()
65
- when "tungsten-manager", "manager"
66
- if TI.is_manager?()
67
- opt(:wrapper_pid_path, "tungsten-manager/var/tmanager.pid")
68
- else
69
- TU.error("Unable to find a manager java PID because the manager is not enabled")
70
- end
71
- when "tungsten-replicator", "replicator"
72
- if TI.is_replicator?()
73
- opt(:wrapper_pid_path, "tungsten-replicator/var/treplicator.pid")
74
- else
75
- TU.error("Unable to find a replicator java PID because the replicator is not enabled")
76
- end
77
- when "tungsten-connector", "connector"
78
- if TI.is_connector?()
79
- opt(:wrapper_pid_path, "tungsten-connector/var/tconnector.pid")
80
- else
81
- TU.error("Unable to find a connector java PID because the connector is not enabled")
82
- end
83
- else
84
- if opt(:component).to_s() == ""
85
- TU.error("The --component argument is required and must be 'replicator', 'manager', or 'connector'")
86
- else
87
- TU.error("Unable to find a java pid for #{opt(:component)}")
88
- end
89
- end
90
- end
91
-
92
- def script_name
93
- "tungsten_java_pid"
94
- end
95
- end