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文 ...
随机推荐
- Ansible学习记录五:PlayBook学习
0.介绍 Playbooks 是 Ansible 管理配置.部署应用和编排的语言,可以使用 Playbooks 来描述你想在远程主机执行的策略或者执行的一组步骤过程等 类似于一组任务集,定义好像项目, ...
- 使用PHP中的curl发送请求
使用CURL发送请求的基本流程 使用CURL的PHP扩展完成一个HTTP请求的发送一般有以下几个步骤: 初始化连接句柄: 设置CURL选项: 执行并获取结果: 释放VURL连接句柄. 下面的程序片段是 ...
- ST和LCA和无根树连接
#include <stdio.h> #include <iostream> #include <string.h> #include <algorithm& ...
- Oracle中NVL、NVL2、DECODE函数的用法
DECODE函数的用法: DECODE(value,if1,then1,if2,then2,if3,then3,......,else),表示如果value的值等于if1时,DECODE函数的结果 ...
- spring的BeanWrapper类的原理和使用方法
转自:http://blog.sina.com.cn/s/blog_79ae79b30100t4hh.html 如果动态设置一个对象属性,可以借助Java的Reflection机制完成: Class ...
- WPF 入门《常用控件》
1.GroupBox 注意: GroupBox仍然需要布局容器来放置元素.如: StackPanel面板 <GroupBox Header="select number?"& ...
- Mysql多实例安装+主从复制+读写分离 -学习笔记
Mysql多实例安装+主从复制+读写分离 -学习笔记 .embody{ padding:10px 10px 10px; margin:0 -20px; border-bottom:solid 1px ...
- [React] Render Text Only Components in React 16
In this session we create a comment component to explore how to create components that only render t ...
- [Python] Different ways to test multiple flags at once in Python
x, y, z = 0, 1, 0 if x == 1 or y == 1 or z == 1: print('passed') if 1 in (x, y, z): print('passed') ...
- 发送 email 过程
发送 email 过程 SMTP基本命令集: 命令 描述 ---------- HELO 向服务器标识用户身份发送者能欺骗,说谎,但一般情况下服务器都能检测到. MAIL 初始化邮件传输 mail f ...