|
|
0cd6dc |
From 3d4cf0365d520be81abfe3435fa9a8a56a933961 Mon Sep 17 00:00:00 2001
|
|
|
0cd6dc |
From: "Bryn M. Reeves" <bmr@redhat.com>
|
|
|
0cd6dc |
Date: Mon, 20 Oct 2014 09:31:32 +0100
|
|
|
0cd6dc |
Subject: [PATCH 13/93] [mysql] obtain dbpass from the environment
|
|
|
0cd6dc |
|
|
|
0cd6dc |
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
|
|
|
0cd6dc |
---
|
|
|
0cd6dc |
sos/plugins/mysql.py | 13 ++++++++++---
|
|
|
0cd6dc |
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
|
0cd6dc |
|
|
|
0cd6dc |
diff --git a/sos/plugins/mysql.py b/sos/plugins/mysql.py
|
|
|
0cd6dc |
index 8bc6e72..1203f5c 100644
|
|
|
0cd6dc |
--- a/sos/plugins/mysql.py
|
|
|
0cd6dc |
+++ b/sos/plugins/mysql.py
|
|
|
0cd6dc |
@@ -13,7 +13,7 @@
|
|
|
0cd6dc |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
0cd6dc |
|
|
|
0cd6dc |
from sos.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
|
|
|
0cd6dc |
-
|
|
|
0cd6dc |
+import os
|
|
|
0cd6dc |
|
|
|
0cd6dc |
class Mysql(Plugin):
|
|
|
0cd6dc |
"""MySQL and MariaDB RDBMS
|
|
|
0cd6dc |
@@ -25,7 +25,7 @@ class Mysql(Plugin):
|
|
|
0cd6dc |
|
|
|
0cd6dc |
option_list = [
|
|
|
0cd6dc |
("dbuser", "username for database dumps", "", "mysql"),
|
|
|
0cd6dc |
- ("dbpass", "password for database dumps", "", ""),
|
|
|
0cd6dc |
+ ("dbpass", "password for database dumps", "", False),
|
|
|
0cd6dc |
("dbdump", "collect a database dump", "", False)
|
|
|
0cd6dc |
]
|
|
|
0cd6dc |
|
|
|
0cd6dc |
@@ -44,7 +44,14 @@ class Mysql(Plugin):
|
|
|
0cd6dc |
if self.get_option("dbdump"):
|
|
|
0cd6dc |
dbuser = self.get_option("dbuser")
|
|
|
0cd6dc |
dbpass = self.get_option("dbpass")
|
|
|
0cd6dc |
- opts = "--user=%s --password=%s --all-databases" % (dbuser, dbpass)
|
|
|
0cd6dc |
+ if dbpass == False and 'MYSQL_PWD' in os.environ:
|
|
|
0cd6dc |
+ dbpass = os.environ['MYSQL_PWD']
|
|
|
0cd6dc |
+ else:
|
|
|
0cd6dc |
+ # no MySQL password
|
|
|
0cd6dc |
+ return
|
|
|
0cd6dc |
+ os.environ['MYSQL_PWD'] = dbpass
|
|
|
0cd6dc |
+
|
|
|
0cd6dc |
+ opts = "--user=%s --all-databases" % dbuser
|
|
|
0cd6dc |
name = "mysqldump_--all-databases"
|
|
|
0cd6dc |
self.add_cmd_output("mysqldump %s" % opts, suggest_filename=name)
|
|
|
0cd6dc |
|
|
|
0cd6dc |
--
|
|
|
0cd6dc |
1.9.3
|
|
|
0cd6dc |
|