On Mon, 2008-03-17 at 09:52 -0400, Jesus M. Rodriguez wrote:
> Outstanding work. This is great!
thanks
> I will defer to others wrt funcweb.
ok :-)
I've upgrade and add some stuff (search by address, port and istance
name) and check istance without listening ports.
bye
Luca
--
Today is Sweetmorn, the 3rd day of Discord in the YOLD 3174
#!/usr/bin/python
# find jboss istances and got information
# about them
# written by Luca Foppiano <[EMAIL PROTECTED]>
# Modified starting by Michael DeHaan <[EMAIL PROTECTED]>
# driver checker script
# ===============================================
import func.overlord.client as fc
info = fc.Client("*").process.info("ax")
print " == JBoss istances monitor == "
# Retrieve information about program (ps ax)
data1 = {}
for (host,details) in info.iteritems():
temp_host_data = []
for items in details:
if "-Dprogram.name=run.sh" in items:
for item in items:
if "java" in item:
java = True
if java == True:
if items.__contains__("-c"):
istance = items[items.index("-c")+1]
else:
istance = None
if items.__contains__("-b"):
address = items[items.index("-b")+1]
else:
address = None
temp_host_data.append((int(items[0]),istance,address,[]))
data1[host] = temp_host_data
# Retrieve information about network (netstat -tupln)
info = fc.Client("*").command.run("netstat -tupln")
data2 = {}
for (host,details) in info.iteritems():
netstat_list=details[1].split("\n")
temp_host_data = []
for string in netstat_list:
address = None
port = None
pid = None
try:
address_port = string.split()[3]
pid_name = string.split()[6]
except:
address_port = None
pid_name = None
if address_port != None:
try:
address = string.split()[3].split(":")[0]
port = int(string.split()[3].split(":")[1])
except:
address = None
port = None
if pid_name != None:
try:
pid = int(pid_name.split("/")[0])
except:
pid = None
if pid != None:
for data in data1[host]:
if data[0] == pid:
#verify address
if address != None:
if data[2] == address:
data[3].append(port)
# Display
# * host: hostname
# - (pid, istance, address, ports)
for key in data1.keys():
print " * host:" +str(key)
for item in data1[key]:
print " - "+str(item)
print "\n\n == JBoss istances checker == "
for key in data1.keys():
for item in data1[key]:
if len(item[3]) == 0:
print " * problem with istance "+item[1]+"(pid: "+str(item[0])+") listening on "+item[2]+" on host "+key+": no port founded"
print "\n\n == JBoss search =="
print "\n === By istance (search word: default) ==="
search = "default"
for key in data1.keys():
for item in data1[key]:
if item[1] == search:
print " * istance found "+item[1]+"(pid: "+str(item[0])+ ") listening on "+item[2]+" on host "+key+ ". Ports: "+str(item[3])
print "\n === By address (search word: 127.0.0.1) ==="
search = "127.0.0.1"
for key in data1.keys():
for item in data1[key]:
if item[2] == search:
print " * istance found "+item[1]+"(pid: "+str(item[0])+ ") listening on "+item[2]+" on host "+key+ ". Ports: "+str(item[3])
print "\n === By port (search port: 8081) ==="
search = "8081"
for key in data1.keys():
for item in data1[key]:
for port in item[3]:
if port == search:
print " * istance found "+item[1]+"(pid: "+str(item[0])+ ") listening on "+item[2]+" on host "+key+ ". Ports: "+str(item[3])
_______________________________________________
Func-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/func-list