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
1diff --git a/files/check_influxdb.py b/files/check_influxdb.py
2index 5ab579b..7a09658 100755
3--- a/files/check_influxdb.py
4+++ b/files/check_influxdb.py
5@@ -5,12 +5,25 @@
6 # Description: Run influxdb 'show diagnostics' command to ensure influxdb is running and operational
7
8 import json
9+import os
10 import subprocess
11 import sys
12 import traceback
13
14+
15+cmd = ['influx', '-execute', 'show diagnostics', '-format', 'json']
16+
17+authf = os.path.join(os.path.expanduser('~'), '.influx-auth')
18+username = None
19+password = None
20+if os.path.exists(authf):
21+ with open(authf, 'r') as f:
22+ username, password = f.readline().split()
23+if username and password:
24+ cmd.extend(['-username', username, '-password', password])
25+
26 try:
27- output = subprocess.check_output(['influx', '-execute', 'show diagnostics', '-format', 'json'])
28+ output = subprocess.check_output(cmd)
29 j = json.loads(output.decode('utf-8'))
30 for o in j['results'][0]['series']:
31 if o['name'] == 'system' and o['columns'][-1] == 'uptime':

Subscribers

People subscribed via source and target branches

to all changes: