Merge pull request #82 from FirmlyReality/diskbug

Fix a bug in monitor.py, which may stop the thread.
This commit is contained in:
leebaok 2016-05-04 09:07:23 -05:00
commit b22a34882c
1 changed files with 15 additions and 11 deletions

View File

@ -114,7 +114,7 @@ class Container_Collector(threading.Thread):
if(self.collect_containerinfo(container)):
countR += 1
except Exception as err:
#pass
logger.warning(traceback.format_exc())
logger.warning(err)
containers_num = len(containers)-1
concnt = {}
@ -195,16 +195,20 @@ class Collector(threading.Thread):
diskval = {}
diskval['device'] = part.device
diskval['mountpoint'] = part.mountpoint
usage = psutil.disk_usage(part.mountpoint)
diskval['total'] = usage.total
diskval['used'] = usage.used
diskval['free'] = usage.free
diskval['percent'] = usage.percent
if(part.mountpoint.startswith('/opt/docklet/local/volume')):
names = re.split('/',part.mountpoint)
container = names[len(names)-1]
self.vetcdser.setkey('/%s/disk_use'%(container), diskval)
setval.append(diskval)
try:
usage = psutil.disk_usage(part.mountpoint)
diskval['total'] = usage.total
diskval['used'] = usage.used
diskval['free'] = usage.free
diskval['percent'] = usage.percent
if(part.mountpoint.startswith('/opt/docklet/local/volume')):
names = re.split('/',part.mountpoint)
container = names[len(names)-1]
self.vetcdser.setkey('/%s/disk_use'%(container), diskval)
setval.append(diskval)
except Exception as err:
logger.warning(traceback.format_exc())
logger.warning(err)
self.etcdser.setkey('/diskinfo', setval)
#print(output)
#print(diskparts)