get_slave_status.py
#!/usr/bin/env python
#-*- encoding: utf8 -*-
import mysql.connector
import get_mysql_conn_info
"""
SHOW SLAVE STATUS命令输出内容
"""
class GetSlaveResult:
"""
getdbconfig 参数是一个列表,第一列是IP,第二列是账号,第三列是密码,第四列是端口号。
"""
def __init__(self,getdbconfig):
self.getdbconfig = getdbconfig
"""
获取 SHOW SLAVE STATUS 输出结果
"""
def get_slave_status(self):
dbconfig = self.getdbconfig
for i in range(int(len(dbconfig))):
show_slave_status = "SHOW slave STATUS;"
cnn = mysql.connector.connect(host=dbconfig[i][0] ,user=dbconfig[i][1] ,password=dbconfig[i][2] ,port=dbconfig[i][3])
cursor = cnn.cursor(dictionary=True)
cursor.execute(show_slave_status)
result_fet = cursor.fetchall()
result = result_fet[0]
result["checkmysql_host"] = dbconfig[i][0]
result["checkmysql_user"] = dbconfig[i][1]
result["checkmysql_port"] = int(dbconfig[i][3])
return result
"""
检查SHOW SLAVE STATUS状态
"""
def check_slave_status(self):
check_ture_false_slave_status = True
result = self.get_slave_status()
if result.get('Slave_IO_Running') == 'Yes' and result.get('Slave_SQL_Running') == 'Yes':
pass
else:
check_ture_false_slave_status = False
print "主机名: %s , 端口号: %s , Slave_IO_Running 状态 = %s , Slave_SQL_Running 状态 = %s " %(str(result.get('checkmysql_host')),str(result.get('checkmysql_port')),str(result.get('Slave_IO_Running')),str(result.get('Slave_SQL_Running')))
"""
获取Last_SQL_Error内容
"""
def get_last_sql_error(self):
check_ture_false_last_sql_error = True
result = self.get_slave_status()
if result.get('Last_SQL_Error')== '':
pass
else:
check_ture_false_last_sql_error = False
print "主机名: %s , 端口号: %s , Last_SQL_Error 内容 = %s " %(str(result.get('checkmysql_host')),str(result.get('checkmysql_port')),str(result.get('Last_SQL_Error')))
checkdbconfig = get_mysql_conn_info.GetConn('/data/lgj/dblist.xlsx').get_csv()
print_result = GetSlaveResult(checkdbconfig)
print_result.check_slave_status()
print_result.get_last_sql_error()
get_slave_status.py的更多相关文章
- python调用py中rar的路径问题。
1.python调用py,在py中的os.getcwd()获取的不是py的路径,可以通过os.path.split(os.path.realpath(__file__))[0]来获取py的路径. 2. ...
- Python导入其他文件中的.py文件 即模块
import sys sys.path.append("路径") import .py文件
- import renumber.py in pymol
cp renumber.py /usr/local/lib/python2.7/dist-packages/pymol import renumber or run /path/to/renumber ...
- python gettitle.py
#!/usr/bin/env python # coding=utf-8 import threading import requests import Queue import sys import ...
- 解决 odoo.py: error: option --addons-path: The addons-path 'local-addons/' does not seem to a be a valid Addons Directory!
情况说明 odoo源文件路径-/odoo-dev/odoo/: 我的模块插件路径 ~/odoo-dev/local-addons/my-module 在my-module中创建了__init__.py ...
- caffe机器学习自带图片分类器classify.py实现输出预测结果的概率及caffe的web_demo例子运行实例
caffe机器学习环境搭建及python接口编译参见我的上一篇博客:机器学习caffe环境搭建--redhat7.1和caffe的python接口编译 1.运行caffe图片分类器python接口 还 ...
- 【转】Windows下使用libsvm中的grid.py和easy.py进行参数调优
libsvm中有进行参数调优的工具grid.py和easy.py可以使用,这些工具可以帮助我们选择更好的参数,减少自己参数选优带来的烦扰. 所需工具:libsvm.gnuplot 本机环境:Windo ...
- MySqlNDB使用自带的ndb_setup.py安装集群
在用Mysql做集群时,使用Mysql的NDB版本更易于集群的扩展,稳定和数据的实时性. 我们可以使用Mysql自带的工具进行集群安装与管理:ndb_setup.py.位于Mysql的安装目录bin下 ...
- 将做好的py文件打包成模块,供别人安装调用
现在要将写完的3个py文件,打包. 步骤: 1.新建一个文件夹setup(名字随便取),在setup文件夹下,再新建一个文件夹financeapi. 2.将上面4个py文件拷贝至financeapi文 ...
随机推荐
- 【hdu 4696】Professor Tian
[Link]:http://acm.hdu.edu.cn/showproblem.php?pid=4649 [Description] 给你一个由位运算"与""或&quo ...
- Intellij IDEA中修改项目名称
如下图红色标识所示: 修改方法见下图:
- 联合体union用在何处?
程序设计刚開始学习的人在学习时,总想问:"这个东东有什么用?"于是,在建设有关的教学资源时,也便总从这个角度,试图给出一些案例,这是一个将刚開始学习的人作为教学目标人群的人该干的事 ...
- 【直接拿来用のandroid公共代码模块解析与分享】の Notification和NotificationManager
本文源代码托管在https://github.com/ASCE1885/asce-common,欢迎fork Android项目做得多了.会发现原来非常多基础的东西都是能够复用,这个系列介绍一些自己项 ...
- android 自己定义控件属性(TypedArray以及attrs解释)
近期在捣鼓android 自己定义控件属性,学到了TypedArray以及attrs.在这当中看了一篇大神博客Android 深入理解Android中的自己定义属性.我就更加深入学习力一番.我就沿着这 ...
- Rsync 指令的使用方法
RsyncLinux版下载:http://rsync.samba.org/download.htmlWindows版下载:https://www.itefix.no/i2/cwrsync-get 选( ...
- code blocks常用快捷键
CodeBlocks常用操作快捷键 编辑部分: Ctrl + A:全选 Ctrl + C:复制 Ctrl + X: 剪切 Ctrl + V:粘贴 Ctrl + Z:撤销(后退一步) Ctrl + S: ...
- 1.4 Ecosystem官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 1.4 Ecosystem 生态系统 There are a plethora of ...
- element-UI实现el-table-column百分比自定义分配
1.把el-table-column的属性width换位min-width就支持百分比显示了.
- Oracle实现数据不存在则插入,数据存在则更新(insert or update)
思路是写一个函数,先按条件查询数据,假设查询到数据则更新.假设没有查询到数据则插入: create or replace function fn_merge_index(statdate in dat ...