python写的分析mysql binlog日志工具
因为数据库增删改突然暴增,需要查询是那些表的操作特别频繁,写了一个用来分析bin-log的小工具,找出增删改查的表,并按照操作次数降序排列,以下是代码:#form
因为数据库增删改突然暴增,需要查询是那些表的操作特别频繁,写了一个用来分析bin-log的小工具,,找出增删改查的表,并按照操作次数降序排列,以下是代码:
#for mysql5.5 binlog import os,sys #python binlog.py binglog-0001 '2013-07-01 00:00:00' '2013-07-02 00:00:00' def log_w(type,text): logfile = "%s.txt" % (type,text) #now = time.strftime("%Y-%m-%d %H:%M:%S") tt = str(text) + "\n" f = open(logfile,'a+') f.write(tt) f.close() logname = sys.argv[1] start_time = sys.argv[2] end_time = sys.argv[3] comn = "/usr/bin/mysqlbinlog --start-datetime='%s' --stop-datetime='%s' %s" % (start_time,end_time,logname) aa=os.popen(comn).readlines() mylist=[] for a in aa: if ('UPDATE' in a): update = ' '.join(a.split()[:2]) mylist.append(update) if ('INSERT INTO' in a): update = ' '.join(a.split()[:3]).replace("INTO ","") mylist.append(update) if ('DELETE from' in a): update = ' '.join(a.split()[:3]).replace("from ","") mylist.append(update) mylist.sort() bb = list(set(mylist)) bb.sort() cc = [] for item in bb: cc.append([mylist.count(item),(item)]) cc.sort() cc.reverse() for i in cc: print str(i[0])+'\t'+i[1]本文出自 “王伟” 博客,请务必保留此出处

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

thinkphp6...

This article recommends ten well-known virtual currency-related APP recommendation websites, including Binance Academy, OKX Learn, CoinGecko, CryptoSlate, CoinDesk, Investopedia, CoinMarketCap, Huobi University, Coinbase Learn and CryptoCompare. These websites not only provide information such as virtual currency market data, price trend analysis, etc., but also provide rich learning resources, including basic blockchain knowledge, trading strategies, and tutorials and reviews of various trading platform APPs, helping users better understand and make use of them

This article provides detailed exchange recommendations and introductory tutorials for beginners in the currency circle. Commonly used exchanges such as Coinbase, Binance, Kraken, Ouyi and Sesame Open Door are recommended, and the steps for registration, identity verification, security settings, recharge and trading are introduced. The article also emphasizes the importance of security awareness, risk control and continuous learning, aiming to help beginners enter the digital asset field safely and rationally.

There are six free market viewing software websites: 1. Binance platform, suitable for digital asset investors; 2. OKX platform, providing rich market data; 3. Sesame Open Door (Gate.io) platform, suitable for users who trade in Gate.io; 4. TradingView, providing professional charting tools; 5. CoinMarketCap, covering a wide range of digital asset data; 6. CoinGecko, providing project fundamental evaluation. When choosing a platform, you need to consider investment objects, chart function requirements, data comprehensiveness and user experience.

This article recommends several commonly used and relatively safe virtual currency exchanges for beginners entering the currency circle in 2025, including Binance, Ouyi, Coinbase and Sesame Open Door. The article provides detailed tutorials on registration, authentication, security setup and transaction process, and emphasizes the importance of risk control, security awareness and ongoing learning, aiming to help beginners securely get started with digital asset trading.

This article recommends several virtual currency exchanges commonly used in the cryptocurrency circle in 2025, including Binance, Ouyi, Coinbase, Sesame Open Door and Kraken, and emphasizes the security, liquidity, trading fees and other factors that need to be considered when choosing an exchange. At the same time, it provides beginners with suggestions, reminding them to carefully read user agreements, enable two-factor verification, start trying with small funds, etc., and emphasize cautious investment and risk control.

Python parses LaTeX multi-layer brackets: build multi-dimensional dictionary many LaTeX...

Analysis of QueryList proxy settings failure and crawler identification problems Many users will encounter even if the proxy is set up when crawling websites such as 58.com using the QueryList library...
