I write an application with two module.
Agent : Collect information about computer resource and send to Manager.
Manager : Listen data from client and write to database.
I has finished the collecting data functions on Agent. I write function for each kind of information. Exp : OS() for Operating System information, DISK() for Disk used information
....
Each function return a list contain information. I want to send those lists to Manager. But when send data to Manager i must change data type to string.
I think i should send each list one by one for me easy to change back the data type to list. I plan to write a for loop on Agent and Manager to send/receive data.
Agent :
resource_info = [OS(), CPU(), DISK(), MEMORY(), NETWORK(), FIREWALL()]
try:
for x in resource_info:
s.sendall(str(x))
except socket.error, e:
print "Error sending data: %s" % e
sys.exit(1)
# Close Socket
s.close()
Manager :
s.listen(10)
for x in range(0,4):
if x == 0 :
conn, addr = s.accept()
OS = conn.recv(100000)
if x == 1 :
conn, addr = s.accept()
DISK = conn.recv(100000)
if x == 2 :
conn, addr = s.accept()
MEMORY = conn.recv(100000)
....
OS = OS.split(",")
DISK = DISK.split(",")
....
But i think it a silly way to do. Please give me some advices about how to send multi list on Agent to Manager. If you have exmple code, it would be great. Thanks so much, Quang