Method: JConsole.start
- Defined in:
- lib/jconsole.rb
.start(args = {}) ⇒ Object
Start a new instance of jconsole which is accessible on port 3000. By default, no authentication is required to connect to it.
The args hash accepts 3 keys:
- :port
-
the port which will be listens to JMX connections. if the port is 0, jmxrmi port is not published
- :pwd_file
-
the path to the file containing the authentication credentials
- :access_file
-
the path to the file containing the authorization credentials
The file path corresponding to :pwd_file must have 600 permission (chmod 600 jmxremote.password
).
Both :pwd_file
and :access_file+
must be specified to run a secure jconsole (see JMX password & access files)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jconsole.rb', line 25 def JConsole.start(args={}) port = args[:port] || 3000 pwd_file = args[:pwd_file] access_file = args[:access_file] cmd =<<-EOCMD.split("\n").join(" ") jconsole -J-Dcom.sun.management.jmxremote EOCMD if port != 0 cmd << <<-EOCMD.split("\n").join(" ") -J-Dcom.sun.management.jmxremote.port=#{port} -J-Dcom.sun.management.jmxremote.ssl=false -J-Dcom.sun.management.jmxremote.authenticate=#{!pwd_file.nil?} EOCMD if pwd_file and access_file cmd << " -J-Dcom.sun.management.jmxremote.password.file=#{pwd_file}" cmd << " -J-Dcom.sun.management.jmxremote.access.file=#{access_file}" end end Thread.start { system cmd } sleep 3 end |