aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Quigley <bryan.quigley@canonical.com>2016-06-03 16:11:03 -0400
committerBryn M. Reeves <bmr@redhat.com>2016-10-25 15:08:38 +0100
commit42e3eacae5103efd032129ebfd3ff9fbdf1d722c (patch)
tree26dd5adf33148b83d953726f3575ab575dc08d5a
parent1ac836aa0582228feec594cd3b201d1dc5b5bb27 (diff)
downloadsos-42e3eacae5103efd032129ebfd3ff9fbdf1d722c.tar.gz
[juju] Get Ready for 2.0 and make it less likely to get too much
The package name juju is no longer the only way to install juju, so replace with checking /usr/bin/juju|juju-run. Juju-run is on machines deployed with juju. Logging still occurs there in same pattern - /var/log/juju/machinename.log. Juju "Local" logs were never seen in the wild and has been removed. Check that /var/log/juju/ exists before trying to access it. Check that /usr/bin/juju exists before trying to run it. Check that Juju's mongodb exists before trying to parse it. /var/lib/juju/ contains a database that can grow to many GB, let's not include that by default. Also explicitly specified juju formats tabular and json (in 2.0 tabular is the default and in 1.25 json is). And we also now explicitly capture the version. Fix up contrainsts and get-config/get so it works for both versions. Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com>
-rw-r--r--sos/plugins/juju.py46
1 files changed, 26 insertions, 20 deletions
diff --git a/sos/plugins/juju.py b/sos/plugins/juju.py
index 13f797f0..629753fc 100644
--- a/sos/plugins/juju.py
+++ b/sos/plugins/juju.py
@@ -16,7 +16,7 @@
import os
from sos.plugins import Plugin, UbuntuPlugin
-from json import loads as json_load
+from json import loads as json_loads
def ensure_service_is_running(service):
@@ -43,7 +43,7 @@ class Juju(Plugin, UbuntuPlugin):
plugin_name = 'juju'
profiles = ('virt', 'sysmgmt')
- packages = ('juju',)
+ files = ('/usr/bin/juju', '/usr/bin/juju-run')
option_list = [
('export-mongodb',
@@ -55,8 +55,9 @@ class Juju(Plugin, UbuntuPlugin):
def get_deployed_services(self):
cmd = "juju status --format json"
- return json_load(
- self.call_ext_prog(cmd)['output'])['services'].keys()
+ status_json = self.call_ext_prog(cmd)['output']
+ self.add_string_as_file(status_json, "juju_status_json")
+ return json_loads(status_json)['services'].keys()
@ensure_service_is_running("juju-db")
def export_mongodb(self):
@@ -76,37 +77,42 @@ class Juju(Plugin, UbuntuPlugin):
suggest_filename="{}.json".format(collection))
def setup(self):
- self.add_copy_spec([
- "/var/lib/juju"
- ])
limit = self.get_option("log_size")
self.add_copy_spec_limit("/var/log/upstart/juju-db.log",
sizelimit=limit)
self.add_copy_spec_limit("/var/log/upstart/juju-db.log.1",
sizelimit=limit)
if not self.get_option("all_logs"):
- # Capture the last bit of all files
- for filename in os.listdir("/var/log/juju/"):
- if filename.endswith(".log"):
- fullname = "/var/log/juju/" + filename
- self.add_copy_spec_limit(fullname, sizelimit=limit)
- # Do just the all-machines from juju local
- self.add_copy_spec_limit("/var/log/juju-*/all-machines.log",
- sizelimit=limit)
+ # We need this because we want to collect to the limit of all
+ # *.logs in the directory.
+ if(os.path.isdir("/var/log/juju/")):
+ for filename in os.listdir("/var/log/juju/"):
+ if filename.endswith(".log"):
+ fullname = os.path.join("/var/log/juju/" + filename)
+ self.add_copy_spec_limit(fullname, sizelimit=limit)
self.add_cmd_output('ls -alRh /var/log/juju*')
+ self.add_cmd_output('ls -alRh /var/lib/juju/*')
+
else:
self.add_copy_spec([
"/var/log/juju",
- "/var/log/juju-*"
+ "/var/log/juju-*",
+ "/var/lib/juju"
+ # /var/lib/juju used to be in the default capture moving here
+ # because it usually was way to big. However, in most cases
+ # you want all logs you want this too.
])
self.add_cmd_output([
- "juju -v status",
- "juju -v get-constraints"
+ "juju --version",
+ "juju -v status --format=tabular",
])
-
for service in self.get_deployed_services():
- self.add_cmd_output("juju get {}".format(service))
+ self.add_cmd_output([
+ "juju get {}".format(service),
+ "juju get-config {}".format(service),
+ "juju get-constraints {}".format(service)
+ ])
if self.get_option("export-mongodb"):
self.export_mongodb()