aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPratik Bandarkar <pbandark@redhat.com>2016-08-03 21:09:24 +0530
committerBryn M. Reeves <bmr@redhat.com>2017-01-17 16:25:36 +0000
commit5c2332cad833778f0816dbb004b4fdb2489f021f (patch)
tree9dd45cb0cffd299093dcbf75401ecb718dc63b92
parent7c428d118c13704753136869ed862bfac09175a2 (diff)
downloadsos-5c2332cad833778f0816dbb004b4fdb2489f021f.tar.gz
[Grafana] New plugin for visualizing metrics
Plugin to capture grafana configuration, logs, and command outputs. configuration: /etc/sysconfig/grafana-server /etc/grafana/ logs: /var/log/grafana/ command outputs: grafana-cli plugins ls grafana-cli plugins list-remote grafana-cli -v grafana-server -v Closes-Bug: #860 Signed-off-by: Pratik Bandarkar <pbandark@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/grafana.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/sos/plugins/grafana.py b/sos/plugins/grafana.py
new file mode 100644
index 00000000..308fd27d
--- /dev/null
+++ b/sos/plugins/grafana.py
@@ -0,0 +1,51 @@
+# Copyright (C) 2016 Red Hat, Inc., Pratik Bandarkar <pbandark@redhat.com>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+from sos.plugins import Plugin, RedHatPlugin
+
+
+class Grafana(Plugin, RedHatPlugin):
+ """Fetch Grafana configuration, logs and CLI output
+ """
+ plugin_name = "grafana"
+ profiles = ('services',)
+
+ def setup(self):
+ if self.get_option("all_logs"):
+ self.add_copy_spec("/var/log/grafana/*.log")
+ else:
+ self.add_copy_spec_limit("/var/log/grafana/*.log",
+ sizelimit=self.get_option("log_size"))
+ self.add_cmd_output([
+ "grafana-cli plugins ls",
+ "grafana-cli plugins list-remote",
+ "grafana-cli -v",
+ "grafana-server -v",
+ ])
+
+ self.add_copy_spec([
+ "/etc/grafana/",
+ "/etc/sysconfig/grafana-server",
+ ])
+
+ def postproc(self):
+ protect_keys = [
+ "admin_password", "secret_key"
+ ]
+
+ regexp = r"((?m)^\s*(%s)\s*=\s*)(.*)" % "|".join(protect_keys)
+ self.do_path_regex_sub("/etc/grafana/grafana.ini",
+ regexp, r"\1*********")