summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-05-05 16:12:23 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-05-09 08:46:16 +0000
commit749c69b1c8fce968ea9bbf9dec5e2a18ab4a2c6d (patch)
treed3526f99a128b6c5749e98174a57fb085bd93fbd /src/conf_mode
parent2c29a3b3b46c7570f4a509f413b208348c0ce647 (diff)
downloadvyos-1x-749c69b1c8fce968ea9bbf9dec5e2a18ab4a2c6d.tar.gz
vyos-1x-749c69b1c8fce968ea9bbf9dec5e2a18ab4a2c6d.zip
monitoring: T4315: Add telegraf output plugin prometheus-client
Add output Plugin "prometheus-client" for telegraf set service monitoring telegraf prometheus-client xxx
Diffstat (limited to 'src/conf_mode')
-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 8a972b9fe..a71565df4 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