-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The creation of the json_exporter configuration has been extended. (#10)
It is now possible to add any number of configuration elements. Thanks to @sleepy-nols for the inspiration.
- Loading branch information
Showing
11 changed files
with
322 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# python 3 headers, required if submitting to Ansible | ||
|
||
from __future__ import (absolute_import, print_function) | ||
__metaclass__ = type | ||
|
||
from ansible.utils.display import Display | ||
|
||
display = Display() | ||
|
||
|
||
class FilterModule(object): | ||
""" | ||
""" | ||
|
||
def filters(self): | ||
return { | ||
'convert_to_modules': self.convert_to_modules, | ||
} | ||
|
||
def convert_to_modules(self, data, modules={}): | ||
""" | ||
""" | ||
result = None | ||
# display.v(f"convert_to_modules({data}, {modules})") | ||
|
||
if isinstance(modules, dict): | ||
|
||
keys = modules.keys() | ||
|
||
if "default" in keys: | ||
""" | ||
default already exists | ||
""" | ||
# display.v("use 'defaut' entry") | ||
|
||
for metric_b in data: | ||
found = False | ||
for metric_a in modules["default"]["metrics"]: | ||
if metric_a.get("name") == metric_b.get("name"): | ||
metric_a.update(metric_b) | ||
found = True | ||
break | ||
|
||
if not found: | ||
modules["default"]["metrics"].append(metric_b) | ||
|
||
else: | ||
""" | ||
create 'defaut' entry | ||
""" | ||
# display.v("create 'defaut' entry") | ||
|
||
modules['default'] = dict() | ||
modules['default']['metrics'] = [] | ||
modules['default']['metrics'] = data | ||
|
||
result = modules | ||
|
||
# display.v(f"= result: {result}") | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.