aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Iranzo Gómez <Pablo.Iranzo@gmail.com>2015-06-04 16:48:21 +0200
committerAdam Stokes <adam.stokes@ubuntu.com>2015-09-30 13:43:15 -0400
commit682dfe796736b23f04012dc42542ff115e09859a (patch)
tree6b25591c7cfe3d9045cef4c550fa2503ef37bfaa
parentb6e1852d7178ed254caca5ef90657ed879aca3e0 (diff)
downloadsos-682dfe796736b23f04012dc42542ff115e09859a.tar.gz
[monit] add new plugin for monit monitoring
Collect monit status, action logs and configuration files. Usernames (in addition to passwords and other secrets) are removed since they may contain information such as email addresses considered sensitive by users. Closes #573 Signed-off-by: Pablo Iranzo Gómez <Pablo.Iranzo@redhat.com> Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
-rw-r--r--sos/plugins/monit.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/sos/plugins/monit.py b/sos/plugins/monit.py
new file mode 100644
index 00000000..07d9472f
--- /dev/null
+++ b/sos/plugins/monit.py
@@ -0,0 +1,78 @@
+# Copyright (C) 2015 Red Hat, Inc.,
+# Pablo Iranzo Gomez <Pablo.Iranzo@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
+from glob import glob
+
+
+class Monit(Plugin, RedHatPlugin):
+ """Monit monitoring daemon
+ """
+ packages = ('monit',)
+ profiles = ('system')
+ plugin_name = 'monit'
+
+ # Define configuration files
+ monit_conf = glob("/etc/monit.d/*")
+ monit_conf.append("/etc/monit.conf")
+ monit_conf.append("/etc/monitrc")
+
+ # Define log files
+ monit_log = ["/var/log/monit.log"]
+
+ option_list = []
+
+ def setup(self):
+ self.add_cmd_output("monit status")
+ self.add_copy_spec([self.monit_log, self.monit_conf])
+
+ def postproc(self):
+ # Post process the files included to scrub any
+ # password or other sensitive data
+
+ # usernames and emails are cleaned to not disclose any
+ # confidential data
+
+ for file in self.monit_conf:
+ # Remove username:password from files
+ self.do_file_sub(file,
+ r"allow (.*):(.*)",
+ r"allow ********:********"
+ )
+ self.do_file_sub(file,
+ r"ALLOW (.*):(.*)",
+ r"ALLOW ********:********"
+ )
+ # Remove MAILSERVER username/password
+ self.do_file_sub(file,
+ r"username (\w)+",
+ r"username ********"
+ )
+ self.do_file_sub(file,
+ r"password (\w)+",
+ r"password ********"
+ )
+ self.do_file_sub(file,
+ r"USERNAME (\w)+",
+ r"USERNAME ********"
+ )
+ self.do_file_sub(file,
+ r"PASSWORD (\w)+",
+ r"PASSWORD ********"
+ )
+
+# vim: et ts=4 sw=4