mysql_info: add support for global status (#63189)

Signed-off-by: Yap Sok Ann <sokann@gmail.com>
pull/63328/head
Yap Sok Ann 5 years ago committed by René Moser
parent f2e5e6de23
commit eca33b80f0

@ -25,8 +25,8 @@ options:
filter:
description:
- Limit the collected information by comma separated string or YAML list.
- Allowable values are C(version), C(databases), C(settings), C(users),
C(slave_status), C(slave_hosts), C(master_status), C(engines).
- Allowable values are C(version), C(databases), C(settings), C(global_status),
C(users), C(engines), C(master_status), C(slave_status), C(slave_hosts).
- By default, collects all subsets.
- You can use '!' before value (for example, C(!settings)) to exclude it from the information.
- If you pass including and excluding values to the filter, for example, I(filter=!settings,version),
@ -129,6 +129,12 @@ settings:
type: dict
sample:
- { "innodb_open_files": 300, innodb_page_size": 16384 }
global_status:
description: Global status information.
returned: if not excluded by filter
type: dict
sample:
- { "Innodb_buffer_pool_read_requests": 123, "Innodb_buffer_pool_reads": 32 }
users:
description: Users information.
returned: if not excluded by filter
@ -203,6 +209,7 @@ class MySQL_Info(object):
'version': {},
'databases': {},
'settings': {},
'global_status': {},
'engines': {},
'users': {},
'master_status': {},
@ -255,6 +262,7 @@ class MySQL_Info(object):
"""Collect all possible subsets."""
self.__get_databases()
self.__get_global_variables()
self.__get_global_status()
self.__get_engines()
self.__get_users()
self.__get_master_status()
@ -307,6 +315,14 @@ class MySQL_Info(object):
release=int(release),
)
def __get_global_status(self):
"""Get global status."""
res = self.__exec_sql('SHOW GLOBAL STATUS')
if res:
for var in res:
self.info['global_status'][var['Variable_name']] = self.__convert(var['Value'])
def __get_master_status(self):
"""Get master status if the instance is a master."""
res = self.__exec_sql('SHOW MASTER STATUS')

@ -43,6 +43,7 @@
- result.changed == false
- result.version != {}
- result.settings != {}
- result.global_status != {}
- result.databases != {}
- result.engines != {}
- result.users != {}
@ -92,6 +93,7 @@
that:
- result.changed == false
- result.version != {}
- result.global_status != {}
- result.databases != {}
- result.engines != {}
- result.settings is not defined
@ -114,4 +116,5 @@
- result.databases != {}
- result.engines is not defined
- result.settings is not defined
- result.global_status is not defined
- result.users is not defined

Loading…
Cancel
Save