2013年11月7日星期四

计算mysql数据库目录中表文件大小并排序

本邮件内容由第三方提供,如果您不想继续收到该邮件,可 点此退订
计算mysql数据库目录中表文件大小并排序  阅读原文»

计算mysql数据库目录中表文件大小并排序

最近需要监控数据库每个表的增长量,其实在mysql中的information_schema.TABLES表中有记录表的大小,但是不准,要是计算每天每个表大小的话不是很准确,刚好我的mysql是独享表空间,所以只要计算出数据目录中的表文件大小即可实现这个目的。以下代码实现了计算在独享表空间下,计算数据库中所有表的物理大小,并计算整个mysql数据库目录的大小和数据库目录所在分区的剩余空间。以下是代码:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os,time,MySQLdb
'''CREATE TABLE DBA.datasize (
`id` int(11) NOT NULL AUTO_INCREMENT,
`host` varchar(20) NOT NULL COMMENT '服务器IP',
`dataname` varchar(100) NOT NULL COMMENT '数据库名字',
`tablename` varchar(100) NOT NULL COMMENT '表名字',
`datasize` double NOT NULL COMMENT '表大小,单位:M',
`uptime` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`,`host`,`dataname`,`tablename`,`datasize`,`uptime`),
KEY `index_uptime` (`uptime`),
KEY `index_tablename` (`tablename`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8''' #表结构
def log_w(text):#写日志
logfile = "datasize.txt"
f = open(logfile,'a+')
def log2db(size_log):#把结果写入数据库
log_host = '192.168.100.100'
log_user = 'wangwei'
log_pass = 'wangwei'
conn = MySQLdb.connect(host = log_host,port = 3306,user = log_user,passwd = log_pass,charset='utf8',connect_timeout=20)
cursor = conn.cursor()
cursor.executemany("insert into DBA.datasize (`host`,`dataname`,`tablename`,`datasize`,`uptime`) VALUES(%s,%s,%s,%s,%s)",tuple(size_log))
except Exception,e:
uptime = time.strftime("%Y-%m-%d %H:%M:%S")
text = "======================== %s ======================" % uptime
mysqldir = "/home/mysql/"
host = '192.168.100.10'#数据库本地IP
conm = 'du -sh %s' % mysqldir
datasize = os.popen(conm).readlines()[0].split('\t')[0]
dir_list = os.listdir(mysqldir)
for i in dir_list:
dirname = os.path.join(mysqldir,i)
if os.path.isdir(dirname):
tb_list = os.listdir(dirname)
table_list = list(set([os.path.splitext(ii)[0] for ii in tb_list]))
for t_name in table_list:
f_size = os.path.getsize(os.path.join(dirname,t))
t_size = t_size/1024/1024
tables[os.path.join(i,t_name)]=t_size
tables = sorted(tables.iteritems(),key = lambda asd:asd[1],reverse = True)
text = str(i[0]).ljust(70)+str(i[1])+'M'
aa = i[0].split("/")
res = [host,aa[0],aa[1],i[1],uptime]
size_log.append(res)
text = "All DataSize :".ljust(70)+str(datasize)
size_log.append([host,"all","all",int(datasize.split('G')[0])*1024,uptime])
IBM-P510主板故障处理方案  阅读原文»

用户名:WS小壮 文章数:109 评论数:182
访问量:54700:16912:1434:5 注册日期:2012-02-09

IBM-P510主板故障处理方案

#errpt -d H

IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION

51E537B5 0211064413 P H sysplanar0 platform_dump saved to file

291D64C3 0211064413 I H sysplanar0 Platform dump data

51E537B5 0211064313 P H sysplanar0 platform_dump saved to file

291D64C3 0211064313 I H sysplanar0 Platform dump data

BFE4C025 0211063913 P H sysplanar0 UNDETERMINED ERROR

51E537B5 0207210013 P H sysplanar0 platform_dump saved to file

291D64C3 0207210013 I H sysplanar0 Platform dump data

51E537B5 0207205913 P H sysplanar0 platform_dump saved to file

291D64C3 0207205913 I H sysplanar0 Platform dump data

BFE4C025 0207205513 P H sysplanar0 UNDETERMINED ERROR

51E537B5 0203023513 P H sysplanar0 platform_dump saved to file

291D64C3 0203023513 I H sysplanar0 Platform dump data

51E537B5 0203023413 P H sysplanar0 platform_dump saved to file

291D64C3 0203023413 I H sysplanar0 Platform dump data

BFE4C025 0203023113 P H sysplanar0 UNDETERMINED ERROR

#errpt a j BFE4C025

LABEL: SCAN_ERROR_CHRP

IDENTIFIER: BFE4C025

Date/Time:

Sequence Number: 364

Machine Id: 00C1EEE44C00

Node Id: wap-partner1

Class: H

Type: PERM

Resource Name: sysplanar0

Resource Class: planar

Resource Type: sysplanar_rspc

Location:

Description

UNDETERMINED ERROR

Failure Causes

UNDETERMINED

Recommended Actions

RUN SYSTEM DIAGNOSTICS.

Detail Data

Diagnostic Analysis

Diagnostic Log sequence number: 248

Resource tested: sysplanar0

Resource Description: System Planar

Location:

SRC: B151E40F

Description: CEC hardware Unrecovered Error, general. Refer to the

system service documentation for more information.

Additional Words: 2-030000F0 3-53B43310 4-C13920FF 5-400000FF

6-00000000 7-00000000 8-00000000 9-00000000

Possible FRUs:

Priority: H FRU: 10N6604 S/N: YL1028352020 CCIN: 53B4

Location: U788C.001.AAC4488-P1

Error/Event Logs

Platform Event Log - 501A910A

Created at :02/10/2013 22:42:16

Subsystem :I/O Bridge

Event Severity :Informational Event

Event Type : Miscellaneous, Informational Only

Action Flags :Report to Operating System

Action Status :Reported to Opr Sys

Primary System Reference Code

Reference Code :B7006992

Hex Words 2 - 5 :00000062 00010002 28510000 00000000

Hex Words 6 - 9 :000000A1 00011000 00000000 00000000

Log Hex Dump

通过HMC收集ASM的故障现象,有错误指向主板微码版本。

通过OS中的errpt显示,有以下几次报错,错误位置指向主板(U788C.001.AAC4488-P1)。

BFE4C025 0211063913 P Hsysplanar0 UNDETERMINED ERROR

BFE4C025 0207205513 P Hsysplanar0 UNDETERMINED ERROR

BFE4C025 0203023113 P Hsysplanar0 UNDETERMINED ERROR

SRC: B151E40F

Description: CEC hardware Unrecovered Error, general. Refer to the

system

阅读更多内容

没有评论:

发表评论