Skip to content

Commit 5eda091

Browse files
CLOUDSTACK-4450: Possibility of /tmp/xapilog filling up the Root disk on Xenserver.
1 parent 40a9909 commit 5eda091

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

scripts/vm/hypervisor/xenserver/hostvmstats.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@
2121
import urllib
2222
import time
2323
import logging
24-
logging.basicConfig(filename='/tmp/xapilog',level=logging.DEBUG)
25-
24+
import logging.handlers
25+
26+
LOG_FILENAME = '/tmp/xapilog'
27+
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
28+
stats_logger = logging.getLogger('statsLogger')
29+
stats_logger.setLevel(logging.DEBUG)
30+
31+
#handler with maxBytes=10MiB
32+
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=10*1024*1024, backupCount=5)
33+
stats_logger.addHandler(handler)
34+
2635
def get_stats(session, collect_host_stats, consolidation_function, interval, start_time):
2736
try:
2837

@@ -41,12 +50,12 @@ def get_stats(session, collect_host_stats, consolidation_function, interval, sta
4150
url += "&interval=" + str(interval)
4251
url += "&start=" + str(int(time.time())-100)
4352

44-
logging.debug("Calling URL: %s",url)
53+
stats_logger.debug("Calling URL: %s",url)
4554
sock = urllib.URLopener().open(url)
4655
xml = sock.read()
4756
sock.close()
48-
logging.debug("Size of returned XML: %s",len(xml))
57+
stats_logger.debug("Size of returned XML: %s",len(xml))
4958
return xml
5059
except Exception,e:
51-
logging.exception("get_stats() failed")
60+
stats_logger.exception("get_stats() failed")
5261
raise

0 commit comments

Comments
 (0)