Skip to content

Instantly share code, notes, and snippets.

@rsff
Created October 16, 2014 16:32
Show Gist options
  • Save rsff/59b889d78d2666ba8923 to your computer and use it in GitHub Desktop.
Save rsff/59b889d78d2666ba8923 to your computer and use it in GitHub Desktop.
WSO2 stats parser
import subprocess
import re
USER = 'admin'
PASSWD = 'admin'
PORT = '9999'
HOST = ''
JMXSH = '/home/rsff/Theorem/jmxsh.jar'
METRICS = {}
METRICS['suckme']="org.wso2.carbon:type=StatisticsAdmin SystemResponseCount"
sh = 'jmx_connect -h ' + HOST + ' -p ' + PORT + ' -U ' + USER + ' -P ' + PASSWD + ' \n'
for name,mbean in METRICS.items():
sh += 'puts "' + name + ': [jmx_get -m ' + mbean + ']"\n'
cmd = "java -jar " + JMXSH + " -q"
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out, err = p.communicate(sh)
response = re.findall("suckme: (\d+)", out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment