Skip to content

Commit 19f1ca0

Browse files
committed
In perfmon: add a workaround for CA-97947, and fix error-logging
In CA-97947 the xapi rpc call that creates the alert message has become case-sensitive. The workaround is to use the capitalisation it recognises. Also the error-logging in perfmon could not handle Exceptions of type XenAPI.Failure; now it can and is more robust. Signed-off-by: Thomas Sanders <[email protected]>
1 parent 342a4f7 commit 19f1ca0

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

scripts/perfmon

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class HOSTMonitor(ObjectMonitor):
658658
(only has defaults for "cpu_usage", "network_usage", "memory_total_kib" and "sr_io_throughput_total_xxxxxxxx")
659659
"""
660660
def __init__(self, *args):
661-
self.monitortype = "HOST"
661+
self.monitortype = "Host"
662662
ObjectMonitor.__init__(self, *args)
663663
print_debug("Created HOSTMonitor with uuid %s" % self.uuid)
664664

@@ -951,17 +951,29 @@ if __name__ == "__main__":
951951
pass
952952

953953
except Exception, e:
954+
rc = 2
955+
log_err("FATAL ERROR: perfmon will exit")
956+
log_err("Exception is of class %s" % e.__class__)
954957
ex = sys.exc_info()
955958
err = traceback.format_exception(*ex)
956-
errmsg = "\n".join([ str(x) for x in e.args ])
957-
958-
# print the exception args nicely
959-
log_err(errmsg)
959+
960+
# Python built-in Exception has args,
961+
# but XenAPI.Failure has details instead. Sigh.
962+
try:
963+
errmsg = "\n".join([ str(x) for x in e.args ])
964+
# print the exception args nicely
965+
log_err(errmsg)
966+
except Exception, ignored:
967+
try:
968+
errmsg = "\n".join([ str(x) for x in e.details ])
969+
# print the exception args nicely
970+
log_err(errmsg)
971+
except Exception, ignored:
972+
pass
960973

961974
# now log the traceback to syslog
962975
for exline in err:
963976
log_err(exline)
964-
rc = 2
965977

966978
# remove pidfile and exit
967979
os.unlink(pidfile)

0 commit comments

Comments
 (0)