Merge pull request #82 from FirmlyReality/diskbug
Fix a bug in monitor.py, which may stop the thread.
This commit is contained in:
commit
b22a34882c
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue