Merge ~hloeung/influxdb-charm:master into influxdb-charm:master

Proposed by Haw Loeung
Status: Merged
Merged at revision: 22974496fe22ed96d5df21ccde2299e75912099d
Proposed branch: ~hloeung/influxdb-charm:master
Merge into: influxdb-charm:master
Diff against target: 31 lines (+14/-1)
1 file modified
files/check_influxdb.py (+14/-1)
Reviewer Review Type Date Requested Status
Paul Gear (community) Approve
Review via email: mp+333185@code.launchpad.net

Description of the change

Update nagios check to support authenticating

To post a comment you must log in.
Revision history for this message
Paul Gear (paulgear) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/files/check_influxdb.py b/files/check_influxdb.py
index 5ab579b..7a09658 100755
--- a/files/check_influxdb.py
+++ b/files/check_influxdb.py
@@ -5,12 +5,25 @@
5# Description: Run influxdb 'show diagnostics' command to ensure influxdb is running and operational5# Description: Run influxdb 'show diagnostics' command to ensure influxdb is running and operational
66
7import json7import json
8import os
8import subprocess9import subprocess
9import sys10import sys
10import traceback11import traceback
1112
13
14cmd = ['influx', '-execute', 'show diagnostics', '-format', 'json']
15
16authf = os.path.join(os.path.expanduser('~'), '.influx-auth')
17username = None
18password = None
19if os.path.exists(authf):
20 with open(authf, 'r') as f:
21 username, password = f.readline().split()
22if username and password:
23 cmd.extend(['-username', username, '-password', password])
24
12try:25try:
13 output = subprocess.check_output(['influx', '-execute', 'show diagnostics', '-format', 'json'])26 output = subprocess.check_output(cmd)
14 j = json.loads(output.decode('utf-8'))27 j = json.loads(output.decode('utf-8'))
15 for o in j['results'][0]['series']:28 for o in j['results'][0]['series']:
16 if o['name'] == 'system' and o['columns'][-1] == 'uptime':29 if o['name'] == 'system' and o['columns'][-1] == 'uptime':

Subscribers

People subscribed via source and target branches

to all changes: