@@ -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