Introduce env.exclude
This commit is contained in:
parent
6c4db0e204
commit
cee13a9be8
2 changed files with 13 additions and 2 deletions
|
|
@ -36,6 +36,10 @@ If the attribut is itself one object, it is possible the use a hierarchical call
|
|||
Example: env.id_monitored account1@backend1 account2@backend2
|
||||
A list of object (space as separator). Only there objects are diplayed.
|
||||
|
||||
==== env.exclude ====
|
||||
Example: env.exclude 550810@sachsen
|
||||
Same as env.id_monitored, but to exclude an object of results
|
||||
|
||||
==== env.cache_expire ====
|
||||
Example: env.cache_expire 7200 (default 3600)
|
||||
|
||||
|
|
@ -129,6 +133,7 @@ env.attribvalue sensors/lastvalue/level
|
|||
env.title Niveau de l'elbe en Saxe
|
||||
env.label name
|
||||
env.vlabel Hauteur du fleuve (cm)
|
||||
env.exclude 550810@sachsen
|
||||
|
||||
# Temperature in Rennes
|
||||
[temprennes]
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ class GenericMuninPlugin(object):
|
|||
self.tomonitore = None
|
||||
if 'id_monitored' in os.environ:
|
||||
self.tomonitore = os.environ['id_monitored'].split(' ')
|
||||
self.exclude = None
|
||||
if 'exclude' in os.environ:
|
||||
self.exclude = os.environ['exclude'].split(' ')
|
||||
# Attribut of object to use as ID (default: id)
|
||||
self.attribid = "id"
|
||||
if 'attribid' in os.environ:
|
||||
|
|
@ -160,7 +163,10 @@ class GenericMuninPlugin(object):
|
|||
return result
|
||||
|
||||
def monitored(self, result):
|
||||
return not self.tomonitore or ('%s@%s' % (getattr(result, self.attribid), result.backend)) in self.tomonitore
|
||||
id = '%s@%s' % (getattr(result, self.attribid), result.backend)
|
||||
if self.exclude and id in self.exclude:
|
||||
return False
|
||||
return not self.tomonitore or id in self.tomonitore
|
||||
|
||||
def result2id(self, result):
|
||||
attribs = self.attribid.split('/')
|
||||
|
|
@ -182,7 +188,7 @@ class GenericMuninPlugin(object):
|
|||
self.write_output('graph_args -l 0')
|
||||
try:
|
||||
objects = []
|
||||
if self.tomonitore is not None:
|
||||
if self.tomonitore is not None or self.exclude is not None:
|
||||
d = {}
|
||||
for backend, result in self.build_do():
|
||||
if self.monitored(result):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue