兴国资源网 Design By www.nnzcdc.com
为方便维护MySQL,写了个脚本用以提供收集错误信息的接口。这些错误信息来自与MySQL错误日志,而 通过grep mysql可以获取error-log的路径。
以下是全部相关代码:
#!/usr/bin/env python2.7 #-*- encoding: utf-8 -*- """ 该模块用于提取每天mysql日志中的异常或错误信息 author: xiaomo email: moxiaomomo@gmail.com """ import os import sys import string from datetime import * # 預設字符解碼器為utf-8 reload(sys) sys.setdefaultencoding('utf-8') COMMON_FLAGS = ["error", "exception", "fail", "crash", "repair"] def _contain_flag(cur_str): for flag in COMMON_FLAGS: if flag in string.lower(cur_str): return True return False """ 获取当前mysql实例的error_log文件路径 """ def _get_mysql_error_log_path(): log_path = '' grep_infos = os.popen('ps aux | grep mysql | grep "log-error"').read() if len(grep_infos) > 1: grep_infos = grep_infos.split("log-error=") if len(grep_infos) > 1: grep_infos = grep_infos[1].split(' ') if len(grep_infos) > 1: log_path = grep_infos[0] return log_path """ 读取mysql错误日志中包含异常或错误信息的行 """ def _get_error_info(error_log, begin_date): error_infos = [] f = open(error_log, 'r') lines = f.readlines() for line in lines: data_array = line.split(' ') if len(data_array) > 0 and len(data_array[0]) == 10: dt_strs = data_array[0].split('-') cur_date = date(int(dt_strs[0]), int(dt_strs[1]), int(dt_strs[2])) if cur_date >= begin_date and _contain_flag(line): error_infos.append(line) f.close() return error_infos """ 组装并返回mysql错误日志信息 """ def get_mysql_errors(begin_date=date.today()-timedelta(1)): try: err_log_path = _get_mysql_error_log_path() if len(err_log_path) > 1: return _get_error_info(err_log_path, begin_date) except Exception,e: print "[get_mysql_errors]%s"%e return []
有兴趣的朋友们参考学习下,感谢大家对的支持。
兴国资源网 Design By www.nnzcdc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
兴国资源网 Design By www.nnzcdc.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年10月05日
2024年10月05日
- 群星《前途海量 电影原声专辑》[FLAC/分轨][227.78MB]
- 张信哲.1992-知道新曲与精丫巨石】【WAV+CUE】
- 王翠玲.1995-ANGEL【新艺宝】【WAV+CUE】
- 景冈山.1996-我的眼里只有你【大地唱片】【WAV+CUE】
- 群星《八戒 电影原声带》[320K/MP3][188.97MB]
- 群星《我的阿勒泰 影视原声带》[320K/MP3][139.47MB]
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]