暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
mysqlmon
1244
5页
45次
2021-12-06
免费下载
#!/usr/local/python3/bin/python3
# coding=utf-8
# Author: Yang Bao
# Created: 2021-11-30 rev0
import argparse
import json
import pymysql
import inspect
from collections import namedtuple
SlaveStatus = namedtuple('SlaveStatus',
['Slave_IO_State',
'Master_Host',
'Master_User',
'Master_Port',
'Connect_Retry',
'Master_Log_File',
'Read_Master_Log_Pos',
'Relay_Log_File',
'Relay_Log_Pos',
'Relay_Master_Log_File',
'Slave_IO_Running',
'Slave_SQL_Running',
'Replicate_Do_DB',
'Replicate_Ignore_DB',
'Replicate_Do_Table',
'Replicate_Ignore_Table',
'Replicate_Wild_Do_Table',
'Replicate_Wild_Ignore_Table',
'Last_Errno',
'Last_Error',
'Skip_Counter',
'Exec_Master_Log_Pos',
'Relay_Log_Space',
'Until_Condition',
'Until_Log_File',
'Until_Log_Pos',
'Master_SSL_Allowed',
'Master_SSL_CA_File',
'Master_SSL_CA_Path',
'Master_SSL_Cert',
'Master_SSL_Cipher',
'Master_SSL_Key',
'Seconds_Behind_Master',
'Master_SSL_Verify_Server_Cert',
'Last_IO_Errno',
'Last_IO_Error',
'Last_SQL_Errno',
'Last_SQL_Error',
'Replicate_Ignore_Server_Ids',
'Master_Server_Id',
'Master_UUID',
'Master_Info_File',
'SQL_Delay',
'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)
of 5
免费下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜