'SQL_Remaining_Delay',
'Slave_SQL_Running_State',
'Master_Retry_Count',
'Master_Bind',
'Last_IO_Error_Timestamp',
'Last_SQL_Error_Timestamp',
'Master_SSL_Crl',
'Master_SSL_Crlpath',
'Retrieved_Gtid_Set',
'Executed_Gtid_Set',
'Auto_Position',
'Replicate_Rewrite_DB',
'Channel_Name',
'Master_TLS_Version',
'Master_public_key_path',
'Get_master_public_key',
'Network_Namespace']
)
class Checks(object):
def readonly(self):
"""检查 mysql 是否只读"""
sql = "show global variables like 'read_only'"
self.cur.execute(sql)
res = self.cur.fetchone()[1]
return_val = 1 if res == 'ON' else 0
print(return_val)
def uptime(self):
"""检查 mysql 服务运行的时间"""
sql = "show global status where variable_name in ('Uptime')"
self.cur.execute(sql)
res = self.cur.fetchone()[1]
print(res)
def queries(self):
"""检查 queries,值为累加的,在模板中选择简单更改"""
sql = "show global status where variable_name in ('Queries')"
self.cur.execute(sql)
res = self.cur.fetchone()[1]
print(res)
def select(self):
"""检查 select,值为累加的,在模板中选择简单更改"""
sql = "show global status where variable_name in ('Com_select')"
self.cur.execute(sql)
res = self.cur.fetchone()[1]
print(res)
def insert(self):
"""检查 insert,值为累加的,在模板中选择简单更改"""
sql = "show global status where variable_name in ('Com_insert')"
self.cur.execute(sql)
评论