On Mon, 2008-03-10 at 16:52 +0100, Luca Foppiano wrote:
> thanks a lot. I will post here. Now I need to finish and clean useless
> parts.
Finally (thanks to M. DeHaan for his suggestions), I finish to write
simple script to get jboss istances information.
With this script, is possibile to get, for each systems, ports, pid,
istance name and bind address.
With this informations is also possibile to add some checks (for example
when an istance is up but doesn't listen any ports).
Here there's a sample output information:
-bash-3.2$ python testJbossIstances.py
== JBoss istances monitor ==
* host:rh5i386_local.byte-code.lan
* host:fc8-b.byte-code.lan
- (1687, 'default', '192.168.33.148', [3873, 8009, 1098, 1099, 8080,
8083, 4444, 8093, 4445, 4446])
* host:fc8-a.byte-code.lan
- (1617, 'default', '192.168.33.141', [3873, 8009, 1098, 1099, 8080,
8083, 4444, 8093, 4445, 4446])
- (1790, 'test', '127.0.0.1', [3873, 8009, 1098, 1099, 8080, 8083,
4444, 8093, 4445, 4446])
-bash-3.2$
The main goal is to integrate into funcweb (I haven't see yet)..
what do you think?
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 "java" in items and "-Dprogram.name=run.sh" in items:
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)
_______________________________________________
Func-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/func-list