Add timestamp to the logs

This commit is contained in:
Girish Ramakrishnan
2019-08-21 10:16:57 -07:00
parent aa74d5cd82
commit fd6dd1ea18
+4 -4
View File
@@ -1,4 +1,4 @@
import collectd,os,subprocess,sys,re
import collectd,os,subprocess,sys,re,time
# https://www.programcreek.com/python/example/106897/collectd.register_read
@@ -13,7 +13,7 @@ def du(pathinfo):
collectd.info('computing size with command: %s' % cmd);
try:
size = subprocess.check_output(cmd, shell=True).split()[0].decode('utf-8')
collectd.info('\tsize of %s is %s' % (pathinfo['dir'], size))
collectd.info('\tsize of %s is %s (time: %i)' % (pathinfo['dir'], size, int(time.time())))
return size
except Exception as e:
collectd.info('\terror getting the size of %s: %s' % (pathinfo['dir'], str(e)))
@@ -29,10 +29,10 @@ def dockerSize():
cmd = 'timeout 1800 docker system df --format "{{.Size}}" | head -n1'
try:
size = subprocess.check_output(cmd, shell=True).strip().decode('utf-8')
collectd.info('\tsize of docker images is %s' % size)
collectd.info('size of docker images is %s (%s) (time: %i)' % (size, parseSize(size), int(time.time())))
return parseSize(size)
except Exception as e:
collectd.info('\terror getting docker images size : %s' % str(e))
collectd.info('error getting docker images size : %s' % str(e))
return 0
# configure is called for each module block. this is called before init