hhxsv5 / go-redis-memory-analysis Goto Github PK
View Code? Open in Web Editor NEW🔎 Analyzing memory of redis is to find the keys(prefix) which used a lot of memory, export the analysis result into csv file.
License: MIT License
🔎 Analyzing memory of redis is to find the keys(prefix) which used a lot of memory, export the analysis result into csv file.
License: MIT License
redis-memory-analysis-linux-amd64 version v2.0.6
./redis-memory-analysis-linux-amd64 -rdb="./dump.rdb" -prefixes="#//:"
error info:
Starting analysis
panic: invalid RDB version number
goroutine 1 [running]:
github.com/hhxsv5/go-redis-memory-analysis.AnalysisRDB.Start(0xc42009a028, 0xc4200907e0, 0xc4200ae220, 0x2, 0x2)
/Users/dave/go/src/github.com/hhxsv5/go-redis-memory-analysis/analysis_rdb.go:183 +0x580
main.main()
/Users/dave/go/src/github.com/hhxsv5/go-redis-memory-analysis/examples/build.go:34 +0x332
my redis version is 4.0.10
解压后发现是个无后缀名的文件,windows 不认识,得自己手动修改后缀名为 .exe。然后在 cmd 命令行中可以正常使用:
redis-memory-analysis-windows-amd64.exe -h
……
i can not use the tool in production environment, but i can get .rdb file, can the tool support .rdb file ?
1.统计的字段区分keyType,以string类型为例
AnalysisConnection的Reports 类型需要修改
type AnalysisConnection struct {
redis *storages.RedisClient
Reports map[string][]Report
}
var(
stringSortBySizeReports SortBySizeReports //String类型SortBySizeReports
)
reportMap := make(map[string]SortBySizeReports)
//循环代码
//赋值
reportMap["strType"] = stringSortBySizeReports
//赋值
analysis.Reports["strType"] = reportMap["strType"]
2.所有db文件输出到一个文件
template := fmt.Sprintf("%s%s%s%s", folder, string(os.PathSeparator), “demo”, ".json")
filename = template
fp, err := storages.NewFile(filename, os.O_WRONLY|os.O_CREATE|os.O_APPEND, os.ModePerm)
以上。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.