Skip to content

Commit 3b63279

Browse files
author
neekyjiang
committed
feat: 1.删除归档 2.处理主键冲突的异常
1 parent 2a1f8f2 commit 3b63279

File tree

46 files changed

+90
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+90
-4
lines changed

Diff for: bin/mtls-auto-fill

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ def parser_cmd_args():
3535
args.add_argument("--table",type=str,default="t",help="表名")
3636
args.add_argument("--rows",type=int,default=100,help="要插入的行数")
3737
args.add_argument("--process",type=int,default=1,help="并发的进程数")
38+
args.add_argument("--ssl_disabled",type=bool, default=False, help="是否禁用 SSL")
3839
args.add_argument("action",choices=('review','execute'))
3940
return args.parse_args()
4041

4142

42-
def insert(host="127.0.0.1",port=3306,user="apuser",password="mtls@0352",database="tempdb",table="t",rows=100):
43+
def insert(host="127.0.0.1",port=3306,user="apuser",password="mtls@0352",ssl_disabled=False,database="tempdb",table="t",rows=100):
4344
"""
4445
4546
"""
@@ -58,7 +59,7 @@ def insert(host="127.0.0.1",port=3306,user="apuser",password="mtls@0352",databas
5859
cnx = None
5960
start_at = datetime.now()
6061
try:
61-
cnx = connector.connect(host=host,port=port,user=user,password=password)
62+
cnx = connector.connect(host=host,port=port,user=user,password=password,ssl_disabled=ssl_disabled)
6263
cursor = cnx.cursor()
6364

6465
for i in range(rows):
@@ -127,7 +128,7 @@ def main():
127128
stats.append(_)
128129
else:
129130
# 单进程压力测试
130-
tmp = insert(args.host,args.port,args.user,args.password,args.database,args.table,args.rows)
131+
tmp = insert(args.host,args.port,args.user,args.password,args.ssl_disabled,args.database,args.table,args.rows)
131132
stats.append(tmp)
132133

133134
print("\nReport:")

Diff for: bin/mtls-ps-mem

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
#-*- coding: UTF-8 -*-
3+
4+
"""
5+
每秒打印一下进程的内存使用情况
6+
"""
7+
8+
import os
9+
import datetime
10+
import argparse
11+
from mtls.ps.mem import mem_info_generator
12+
from mtls.ps.mem import global_connection_memory_generator
13+
from mtls.kits import fileformat
14+
15+
16+
name = os.path.basename(__file__)
17+
18+
def parser_cmd_args():
19+
"""
20+
处理命令行参数
21+
"""
22+
args = argparse.ArgumentParser(name)
23+
args.add_argument('--user',type=str,default='')
24+
args.add_argument('--password',type=str,default='')
25+
args.add_argument('--port',type=int,default=3306)
26+
args.add_argument("pid",type=int)
27+
return args.parse_args()
28+
29+
30+
def main():
31+
args = parser_cmd_args()
32+
pid = args.pid
33+
if args.user != '':
34+
for mem_info in mem_info_generator(pid):
35+
print(f"{datetime.datetime.now().isoformat(' ','seconds')} pid={pid} vms={fileformat(mem_info.vms)} rss={fileformat(mem_info.rss)} dirty={fileformat(mem_info.dirty)}")
36+
else:
37+
g = global_connection_memory_generator()
38+
next(g)
39+
for mem_info in mem_info_generator(pid):
40+
global_conn_mem_size = next(g)
41+
print(f"{datetime.datetime.now().isoformat(' ','seconds')} pid={pid} vms={fileformat(mem_info.vms)} rss={fileformat(mem_info.rss)} global_conn_mem={fileformat(global_conn_mem_size)}")
42+
43+
44+
if __name__ == "__main__":
45+
main()

Diff for: dist/mysqltools-python-2.18.10.11.tar.gz

-17.6 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.10.12.tar.gz

-17.6 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.05.tar.gz

-18 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.06.tar.gz

-18.4 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.07.tar.gz

-19 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.20.tar.gz

-19 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.21.tar.gz

-18.9 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.22.tar.gz

-19.2 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.23.tar.gz

-19.2 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.18.11.24.tar.gz

-19.3 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.03.11.tar.gz

-19.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.03.13.tar.gz

-19.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.03.23.tar.gz

-19.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.03.24.tar.gz

-20.4 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.03.25.tar.gz

-21.3 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.03.28.tar.gz

-21.3 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.03.29.tar.gz

-21.2 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.04.01.tar.gz

-22 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.04.02.tar.gz

-22.5 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.04.10.tar.gz

-22.6 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.07.26.tar.gz

-23.4 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.07.27.tar.gz

-24 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.07.28.tar.gz

-24.2 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.07.29.tar.gz

-26.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.07.30.tar.gz

-26.9 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.08.02.tar.gz

-27.5 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.08.1.tar.gz

-27.1 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.08.16.tar.gz

-28.9 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.08.20.tar.gz

-29.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.08.21.tar.gz

-29.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.08.22.tar.gz

-29.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.08.23.tar.gz

-29.9 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.09.01.tar.gz

-30.3 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.09.02.tar.gz

-30.5 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.19.09.03.tar.gz

-30.9 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.20.06.01.tar.gz

-32.5 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.20.09.04.tar.gz

-32.5 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.20.09.05.tar.gz

-32.5 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.20.09.06.tar.gz

-32.5 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.20.09.07.tar.gz

-33.7 KB
Binary file not shown.

Diff for: dist/mysqltools-python-2.20.09.08.tar.gz

-35.3 KB
Binary file not shown.

Diff for: mtls/ps/__init__.py

Whitespace-only changes.

Diff for: mtls/ps/mem.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding:utf8 -*-
2+
"""
3+
4+
"""
5+
import time
6+
import psutil
7+
from collections import namedtuple
8+
from mysql import connector
9+
10+
11+
def mem_info_generator(pid):
12+
"""
13+
"""
14+
process = psutil.Process(pid)
15+
while True:
16+
yield process.memory_info()
17+
time.sleep(1)
18+
19+
20+
class MySQLMemCostGather(object):
21+
"""
22+
"""
23+
def __init__(self,user,password,host="127.0.0.1",port=3306):
24+
self.cnx = connector.connect(host=host,port=port,user=user,password=password)
25+
self.cursor = self.cnx.cursor()
26+
27+
def global_connection_memory(self):
28+
self.cursor.execute("show global status like 'Global_connection_memory'")
29+
_,value = self.cursor.fetchone()
30+
return int(value)
31+
32+
def global_connection_memory_generator(port=3306,user="root",password="dbma@0352"):
33+
try:
34+
gather = MySQLMemCostGather(user,password,port=port)
35+
while True:
36+
yield gather.global_connection_memory()
37+
#time.sleep(1)
38+
except Exception as err:
39+
while True:
40+
yield 0

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
scripts = olds_scripts + news_scripts
1414

1515
setup(name='mysqltools-python',
16-
version='2.22.07.00',
16+
version='2.22.07.20',
1717
scripts=scripts,
1818
packages=['mtls', 'mtls.kits','mtls.ps'],
1919
maintainer='Neeky',

0 commit comments

Comments
 (0)