Commit bbb1600a authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

gtools: Small fixes to collectd net stats

parent 45620667
......@@ -6,26 +6,23 @@ import collectd
from glob import glob
def read_int(file):
f = open(file, "r")
try:
val = int(f.read())
except ValueError:
val = None
finally:
f.close()
def read_int(filename):
with open(filename, "r") as f:
try:
val = int(f.read())
except ValueError:
val = None
return val
def netstats(data=None):
for dir in glob("/var/run/ganeti/kvm-hypervisor/nic/*"):
if not os.path.isdir(dir):
for dirname in glob("/var/run/ganeti/kvm-hypervisor/nic/*"):
if not os.path.isdir(dirname):
continue
hostname = os.path.basename(dir)
hostname = os.path.basename(dirname)
for nic in glob(os.path.join(dir, "*")):
for nic in glob(os.path.join(dirname, "*")):
try:
idx = int(os.path.basename(nic))
except ValueError:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment