From 21e7599395ea784ef892d2a61e6bdc172099ad5e Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 23 Jun 2014 14:41:00 +0100 Subject: [PATCH 04/13] [mysql] add optional database dump support --- sos/plugins/mysql.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py index 3f8dc2b..e6bb6c6 100644 --- a/sos/plugins/mysql.py +++ b/sos/plugins/mysql.py @@ -18,15 +18,24 @@ import os class mysql(sos.plugintools.PluginBase): """MySQL related information """ - def checkenabled(self): - if self.cInfo["policy"].pkgByName("mysql-server") or os.path.exists("/etc/my.cnf") or \ - self.cInfo["policy"].pkgByName("mysql"): - return True - return False + files = ('/etc/my.cnf',) + packages = ('mysql-server',) + + optionList = [ + ("dbuser", "username for database dumps", "", "mysql"), + ("dbpass", "password for database dumps", "", ""), + ("dbdump", "collect a database dump", "", False) + ] def setup(self): self.addCopySpec("/etc/my.cnf") - self.addCopySpec("/etc/sysconfig/network") self.addCopySpec("/etc/ld.so.conf.d/mysql*") self.addCopySpec("/var/log/mysql*") + if self.getOption("dbdump"): + dbuser = self.getOption("dbuser") + dbpass = self.getOption("dbpass") + opts = "--user=%s --password=%s --all-databases" % (dbuser, dbpass) + name = "mysqldump_--all-databases" + self.collectExtOutput("mysqldump %s" % opts, suggest_filename=name) return + -- 1.9.3