summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-05-03 21:12:18 +0200
committerGitHub <noreply@github.com>2022-05-03 21:12:18 +0200
commit0400f96c003ca0472a9e1786b5af20e4207b9e59 (patch)
tree512f39956b40ca6f89f4ec221e673aaee0964ffa /src
parent318f81cba207dc5f180b074c2a7cdb4a4217e5fc (diff)
parent5ceabd78f1cccf0a8283056be071f4fdc676f012 (diff)
downloadvyos-1x-0400f96c003ca0472a9e1786b5af20e4207b9e59.tar.gz
vyos-1x-0400f96c003ca0472a9e1786b5af20e4207b9e59.zip
Merge pull request #1310 from sever-sever/T4315
monitoring: T4315: Add telegraf output plugin 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