allow modules to emit multiple data points
This commit is contained in:
parent
d1b1b09e5e
commit
a1f4f48ebf
@ -175,9 +175,9 @@ class MonitorThread(Thread):
|
||||
"""
|
||||
Run the loaded checker function
|
||||
"""
|
||||
result = self.checker_func(**args)
|
||||
self.logger.info("result: %s" % (result,))
|
||||
self.backend.add_data(self.config["type"], result)
|
||||
for result in self.checker_func(**args):
|
||||
self.logger.info("result: %s" % (result,))
|
||||
self.backend.add_data(self.config["type"], result)
|
||||
|
||||
def shutdown(self):
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
def load():
|
||||
with open("/proc/loadavg", "r") as f:
|
||||
m1, m5, m15, procs, pid = f.read().strip().split(" ")
|
||||
return {
|
||||
yield {
|
||||
"load_1m": m1,
|
||||
"load_5m": m5,
|
||||
"load_15m":m15
|
||||
@ -24,5 +24,5 @@ mapping = {
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
avg = load()
|
||||
print(' '.join([avg["load_1m"], avg["load_5m"], avg["load_15m"]]))
|
||||
for avg in load():
|
||||
print(' '.join([avg["load_1m"], avg["load_5m"], avg["load_15m"]]))
|
||||
|
@ -38,7 +38,7 @@ def meminfo(whitelist=[]):
|
||||
for key in computed_fields:
|
||||
result[key] = computed_fields[key](result)
|
||||
|
||||
return result
|
||||
yield result
|
||||
|
||||
mapping = {
|
||||
"meminfo": {
|
||||
@ -63,5 +63,6 @@ mapping = {
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
for k,v in meminfo().items():
|
||||
print("%s: %s"%(k,v))
|
||||
for item in meminfo():
|
||||
for k,v in item.items():
|
||||
print("%s: %s"%(k,v))
|
||||
|
@ -57,7 +57,7 @@ def procs():
|
||||
print(e)
|
||||
print("Failed to open %s" % f)
|
||||
|
||||
return {"procs": num_procs, "threads":num_threads, "kthreads": num_kthreads}
|
||||
yield {"procs": num_procs, "threads":num_threads, "kthreads": num_kthreads}
|
||||
|
||||
mapping = {
|
||||
"procs": {
|
||||
@ -76,5 +76,5 @@ mapping = {
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
stats = procs()
|
||||
print("%s procs %s kthreads %s threads" % (stats["procs"], stats["kthreads"], stats["threads"]))
|
||||
for stats in procs():
|
||||
print("%s procs %s kthreads %s threads" % (stats["procs"], stats["kthreads"], stats["threads"]))
|
||||
|
@ -1,6 +1,6 @@
|
||||
def uptime():
|
||||
with open("/proc/uptime", "r") as f:
|
||||
return {"uptime":int(float(f.read().split(" ")[0]))}
|
||||
yield {"uptime":int(float(f.read().split(" ")[0]))}
|
||||
|
||||
mapping = {
|
||||
"uptime": {
|
||||
@ -13,4 +13,5 @@ mapping = {
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(uptime()["uptime"])
|
||||
for item in uptime():
|
||||
print(item["uptime"])
|
||||
|
Loading…
x
Reference in New Issue
Block a user