zl程序教程

您现在的位置是:首页 >  其他

当前栏目

ddcw_tool常用功能分享(2)

2023-03-07 09:05:26 时间

目前常用的功能都写完了,做个总结. 后面新增得多再写新增的

ddcw_tool地址: https://github.com/ddcw/ddcw/blob/master/python/ddcw_tool.py

功能汇总

压测mysql, 之前已经演示了 https://cloud.tencent.com/developer/article/2213710

压测oracle

压测postgres (tps/qps显示需要自己实现)

扫描端口

ssh 执行命令, 常用命令封装

sftp 上传下载文件

mysql,oracle,postgres连接, 和一部分常用命令封装

占用CPU测试

占用内存测试

远程修改yaml

读写yaml和conf文件

返回日志对象(貌似用处不大)

加密解密,目前只是base64...

本地shell命令执行

部分功能演示

压测oracle

压测这几个数据库用法都一样...

import ddcw_tool
test_benchmark_oracle = ddcw_tool.benchmark_oracle(host='192.168.101.19',user='u1',password='123456',servicename='ddcw19pdb')
test_benchmark_oracle.prepare() #初始化数据
test_benchmark_oracle.run() #开始压测
test_benchmark_oracle.cleanup() #清理数据

压测postgres

import ddcw_tool
test_benchmark_pg = ddcw_tool.benchmark_postgres(password='123456',user='u1')
test_benchmark_pg.prepare()
test_benchmark_pg.run()
test_benchmark_pg.cleanup()
tps和qps请自己实现

占用CPU测试

import ddcw_tool
aa = ddcw_tool.costcpu(4)
aa.start() #启动
aa.stop() #停止

ssh使用测试

import ddcw_tool
aa = ddcw_tool.ssh(password='Ddcw@123.')
aa.conn() #连接之后可以使用自带的方法,  aa.get_conn() 可以返回一个ssh连接

sftp上传下载文件

import ddcw_tool
aa = ddcw_tool.sftp(password='Ddcw@123.')
aa.conn()
aa.get('/tmp/ei.yaml','/t2/ei.yaml') #get(remotefile,localfile)下载文件  put(localfile,remotefile)上传文件