summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/telegraf/core.py10
-rw-r--r--modules/telegraf/telegraf_utils.py39
2 files changed, 43 insertions, 6 deletions
diff --git a/modules/telegraf/core.py b/modules/telegraf/core.py
index 3febf7b..ffef7d5 100644
--- a/modules/telegraf/core.py
+++ b/modules/telegraf/core.py
@@ -25,10 +25,12 @@ def introduction():
###########################
-def modify_template(new_pipeline_path, api_url):
- #telegraf_utils.modify_output("templates/basic_ETL.toml", "urls", "testingIfWorks")
+def modify_template(new_pipeline_path, api_url, schedulingPeriod):
- ## Api Url editing
+ ## Pipeline intervall
+ telegraf_utils.modify_agent(new_pipeline_path,"interval", schedulingPeriod)
+
+ ## API url
telegraf_utils.modify_input(new_pipeline_path,"urls", [api_url])
@@ -69,7 +71,7 @@ def build_pipeline():
shutil.copy(f"modules/telegraf/templates/{template_name}", new_pipeline_path)
- modify_template(new_pipeline_path, api_url)
+ modify_template(new_pipeline_path, api_url, schedulingPeriod)
#telegraf.modify_output("templates/basic_ETL.toml", "urls", "testingIfWorks")
diff --git a/modules/telegraf/telegraf_utils.py b/modules/telegraf/telegraf_utils.py
index d6ed376..ffaddfd 100644
--- a/modules/telegraf/telegraf_utils.py
+++ b/modules/telegraf/telegraf_utils.py
@@ -6,6 +6,43 @@ def modify_input(new_pipeline_path, key, value):
if key in pluggin:
+ #print(f"Before: {key} = {pluggin[key]}")
+ pluggin[key] = value
+ #print(f"After: {key} = {pluggin[key]}")
+
+
+ with open(new_pipeline_path, "w") as f:
+ toml.dump(data, f)
+
+
+##modify_input("templates/basic_ETL.toml", "test_pipers.toml, "urls", ["stillTesting"])
+
+
+## TODO
+def modify_agent(new_pipeline_path, key, value):
+ data = toml.load(new_pipeline_path)
+ pluggin = data["agent"]
+
+ if key in pluggin:
+
+ #print(f"Before: {key} = {pluggin[key]}")
+ pluggin[key] = value
+ #print(f"After: {key} = {pluggin[key]}")
+
+
+ with open(new_pipeline_path, "w") as f:
+ toml.dump(data, f)
+
+
+
+
+## TODO
+def modify_output(new_pipeline_path, key, value):
+ data = toml.load(new_pipeline_path)
+ pluggin = data["outputs"]["influxdb"][0]
+
+ if key in pluggin:
+
print(f"Before: {key} = {pluggin[key]}")
pluggin[key] = value
print(f"After: {key} = {pluggin[key]}")
@@ -13,5 +50,3 @@ def modify_input(new_pipeline_path, key, value):
with open(new_pipeline_path, "w") as f:
toml.dump(data, f)
-
-#modify_input("templates/basic_ETL.toml", "test_pipers.toml, "urls", ["stillTesting"])