-
Notifications
You must be signed in to change notification settings - Fork 0
/
getExeInfo.py
executable file
·67 lines (59 loc) · 2.14 KB
/
getExeInfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python
import urllib
import re
import os
from bs4 import BeautifulSoup
import classify as csf
def getExePosition():
try:
url = "http://localhost:4040/environment/"
openfile = urllib.urlopen(url)
html = openfile.read().decode("utf-8")
soup = BeautifulSoup(html, "html.parser")
#con = str(html)
tables = soup.findAll('table')
content = str(tables[1])
command = "echo \"" + content + "\" | grep -o \"<td>spark.jars</td><td>[^<]*</td>\""
line = os.popen(command).read().strip()
res = line.replace("<td>spark.jars</td>", "").replace("<td>","").replace("</td>", "")
#print res
return res
except Exception, e:
print "get ExefilePosition connect error"
#getExePosition()
def getDatasetPosition():
#try:
if True:
url = "http://localhost:4040/environment/"
openfile = urllib.urlopen(url)
html = openfile.read().decode("utf-8")
soup = BeautifulSoup(html, "html.parser")
#con = str(html)
tables = soup.findAll('table')
content = str(tables[2])
command = "echo \"" + content + "\" | grep -o \"<td>sun.java.command</td><td>[^<]*</td>\""
line = os.popen(command).read().strip()
javacommand = line.replace("<td>sun.java.command</td>", "").replace("<td>","").replace("</td>", "")
#print javacommand
program = csf.classify(javacommand)
command = "echo \"" + javacommand + "\" | grep -o \"file:[^ ]*\" | sed -n 1p"
line = os.popen(command).read().strip()
print "+++++++++++++++"
#print line
res = ""
res += program
res += " " + line
return res
#except Exception, e:
#print "get DatasetPosition connect error"
#getDatasetPosition()
#getDatasetPosition()
def getExecutorInfo(appname):
try:
url = "http://localhost:4040//api/v1/applications/" + appname + "/allexecutors"
openfile = urllib.urlopen(url)
html = openfile.read()
print html
except Exception, e:
print "get DatasetPosition connect error"
#getExecutorInfo("app-20170221160622-0010")