Loading Byteman Rules dynamically
gaurav6281 Sep 30, 2016 7:26 AMHi,
One of my Java process (A) is running on box A . Another process (B) is running from box B.
Process A executes multiple steps one by one , including loading byteman agent dynamically to Process B. Second step in Process A is submitting rules dynamically to Process B
below are the steps which will be followed from Process A(from java class which I have yet to write using ProcessBuilder , currently I am just doing POC)
(1) SET BYTEMAN_HOME
C:\Users\N662245>SET BYTEMAN_HOME=C:\Users\N662245\byteman-download-3.0.6-bin\by
teman-download-3.0.6
(2) SET BYTEMAN_HOME_OPTS ( I know I can pass helper as a psrt of bmsubmit too but I have tried this way)
C:\Users\N662245>SET BYTEMAN_HOME_OPTS=-Xbootclasspath/a:"C:/Users/N662245/Bytem
apHelper.jar"
(3) Installing agent dynamically
C:\Users\N662245\byteman-download-3.0.6-bin\byteman-download-3.0.6\bin>
bminstall.bat -b -s 15656 (where 15656 is the Java PID of the Process B)
(4) Now when I am trying to load rules dynamically using bmsubmit, I am getting syntax error, but I opened the batch file and checked the usage too.
C:\Users\N662245\byteman-download-3.0.6-bin\byteman-download-3.0.6\bin>
bmsubmit.bat -l -c script:C:\Users\N662245\threadInteraction.btm
usage : Submit [-o outfile] [-p port] [-h hostname] [-l|-u] [scriptfile . . .]
Submit [-o outfile] [-p port] [-h hostname] [-b|-s] jarfile . . .
Submit [-o outfile] [-p port] [-h hostname] [-c]
Submit [-o outfile] [-p port] [-h hostname] [-y] [prop1[=[value1]]. . .]
Submit [-o outfile] [-p port] [-h hostname] [-v]
-o redirects output from System.out to outfile
-p specifies listener port
-h specifies listener host
-l (default) with scriptfile(s) means load/reload all rules in scriptfil
e(s)
with no scriptfile means list all currently loaded rules
-u with scriptfile(s) means unload all rules in scriptfile(s)
with no scriptfile means unload all currently loaded rules
-b with jarfile(s) means add jars to bootstrap classpath
-s with jarfile(s) means add jars to system classpath
-c prints the jars that have been added to the system and boot classload
ers
-y with no args list all byteman config system properties
with args modifies specified byteman config system properties
prop=value sets system property 'prop' to value
prop= sets system property 'prop' to an empty string
prop unsets system property 'prop'
-v prints the version of the byteman agent and this client
C:\Users\N662245\byteman-download-3.0.6-bin\byteman-download-3.0.6\bin>
bmsubmit.bat Submit -l -c script:C:\Users\N662245\threadInteraction.btm
Failed to process request: java.lang.Exception: Invalid rule file: Submit
-- Args were: [Submit, -l, -c, script:C:\Users\N662245\threadInteraction.btm]
java.lang.Exception: Invalid rule file: Submit
at org.jboss.byteman.agent.submit.Submit.getRulesFromRuleFiles(Submit.ja
va:829)
at org.jboss.byteman.agent.submit.Submit.addRulesFromFiles(Submit.java:5
54)
at org.jboss.byteman.agent.submit.Submit.main(Submit.java:1147)
C:\Users\N662245\byteman-download-3.0.6-bin\byteman-download-3.0.6\bin>
Whats the missing bit ???