summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-05-02 19:29:38 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-05-03 07:47:34 +0000
commit5ceabd78f1cccf0a8283056be071f4fdc676f012 (patch)
tree512f39956b40ca6f89f4ec221e673aaee0964ffa /src
parent318f81cba207dc5f180b074c2a7cdb4a4217e5fc (diff)
downloadvyos-1x-5ceabd78f1cccf0a8283056be071f4fdc676f012.tar.gz
vyos-1x-5ceabd78f1cccf0a8283056be071f4fdc676f012.zip
monitoring: T4315: Add telegraf output plugin prometheus-client
Add output Plugin "prometheus-client" for telegraf: set service monitoring telegraf prometheus-client
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/service_monitoring_telegraf.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/conf_mode/service_monitoring_telegraf.py b/src/conf_mode/service_monitoring_telegraf.py
index 94bc02f10..2398b0174 100755
--- a/src/conf_mode/service_monitoring_telegraf.py
+++ b/src/conf_mode/service_monitoring_telegraf.py
@@ -99,6 +99,15 @@ def get_config(config=None):
monitoring['interfaces_ethernet'] = get_interfaces('ethernet', vlan=False)
monitoring['nft_chains'] = get_nft_filter_chains()
+ if 'authentication' in monitoring or \
+ 'url' in monitoring:
+ monitoring['influxdb_configured'] = True
+
+ # Ignore default XML values if config doesn't exists
+ # Delete key from dict
+ if not conf.exists(base + ['prometheus-client']):
+ del monitoring['prometheus_client']
+
return monitoring
def verify(monitoring):
@@ -106,13 +115,14 @@ def verify(monitoring):
if not monitoring:
return None
- if 'authentication' not in monitoring or \
- 'organization' not in monitoring['authentication'] or \
- 'token' not in monitoring['authentication']:
- raise ConfigError(f'Authentication "organization and token" are mandatory!')
+ if 'influxdb_configured' in monitoring:
+ if 'authentication' not in monitoring or \
+ 'organization' not in monitoring['authentication'] or \
+ 'token' not in monitoring['authentication']:
+ raise ConfigError(f'Authentication "organization and token" are mandatory!')
- if 'url' not in monitoring:
- raise ConfigError(f'Monitoring "url" is mandatory!')
+ if 'url' not in monitoring:
+ raise ConfigError(f'Monitoring "url" is mandatory!')
return None