0
私は次のpythonスクリプトを使用しているという奇妙な問題を抱えています.1つのホストでそれを実行すると別のマシンで正常に動作します。その後、それはフリーズします。私もstraceを含んだ。両方のマシンはCentos、同じネットワークです。ここでxenserverからデータを収集するときのPythonの奇妙な問題
#!/usr/bin/python
import XenAPI
import string, time, os, ConfigParser, sys, re
def errorAndExit(message):
print "ERROR: Something went wrong! -", message
exit(1)
def grabXenData(session, config):
try:
vms = session.xenapi.VM.get_all()
except:
errorAndExit("Couldn't retrieve all VM's")
for vm in vms:
record = session.xenapi.VM.get_record(vm)
if (record["power_state"] == "Running") and not (record["is_control_domain"]):
if (record["actions_after_crash"] != "destroy"):
print record["name_label"]
if __name__ == '__main__':
CONFIG_FILE = (os.getcwd() + "/config.txt")
config = ConfigParser.ConfigParser()
config.read([CONFIG_FILE])
wait = config.get('XENAPI', 'WAIT')
# time.sleep expects a float, convert the var here.
wait = float(wait)
url = "http://" + config.get('XENAPI', 'HOSTNAME')
print url
username = config.get('XENAPI', 'USERNAME')
password = config.get('XENAPI', 'PASSWORD')
while True:
session = XenAPI.Session(url)
print session
try:
session.xenapi.login_with_password(username, password)
except:
errorAndExit("Could not connect to host, CHECK: URL, username, password")
grabXenData(session, config)
session.xenapi.session.logout()
exit()
は、スタックトレースは次のとおりです。事前に
open("/usr/lib64/python2.7/httplib.py", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=48234, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa108b7e000
read(4, "r\"\"\"HTTP/1.1 client library\n\n<in"..., 4096) = 4096
read(4, "THENTICATION_REQUIRED = 407\nREQU"..., 4096) = 4096
read(4, "nread'):\n unread = se"..., 4096) = 4096
write(2, " ", 4) = 4
write(2, "line = self.fp.readline(_MAXLINE"..., 38) = 38
close(4) = 0
munmap(0x7fa108b7e000, 4096) = 0
write(2, " File \"/usr/lib64/python2.7/soc"..., 63) = 63
open("/usr/lib64/python2.7/socket.py", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=20512, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa108b7e000
read(4, "# Wrapper module for _socket, pr"..., 4096) = 4096
read(4, "oo long.\"\n errorTab[10064] = "..., 4096) = 4096
read(4, "sed\" is a property, see below\n "..., 4096) = 4096
read(4, " try:\n "..., 4096) = 4096
read(4, " nl = data.find('\\n')"..., 4096) = 4096
write(2, " ", 4) = 4
write(2, "data = self._sock.recv(self._rbu"..., 39) = 39
close(4) = 0
munmap(0x7fa108b7e000, 4096) = 0
write(2, "KeyboardInterrupt", 17) = 17
write(2, "\n", 1) = 1
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fa10838d130}, {0x7fa1086ab6a0, [], SA_RESTORER, 0x7fa10838d130}, 8) = 0
close(3) = 0
close(8) = 0
exit_group(1) = ?
+++ exited with 1 +++
感謝。これ以上の情報があれば教えてください。