Everybody gets to that moment when they need more space on the hard drive. You often just ask yourself: Where did the free space go from my disk? There are many tools that can be used for finding out the space you spend (one of my favorites is the du -sh command), but most of them are quite time consuming. These days, reading about the Linux performance system, I found a tool not only very useful but also catchy. It determines how much free disk space there is: flame graphs.
The tool was made by the famous Brendan Gregg, using flame graphs as the final view.
Installing flame graphs for Linux file systems
It can be done very easy from the git with the command:
git clone https://github.com/brendangregg/FlameGraph
To start using the tool:
cd FlameGraph
./files.pl /path_to_the_analyzed_directory | ./flamegraph.pl –hash –countname=bytes > out.svg
The out.svg file opens in the browser and results in what we’ve inserted above into the article. If you want to find out what size files you have in your entire system, replace the / path_to_the_analyzed_directory with /
Install without git:
Two files are downloaded: files.pl and flamegraph.pl either using the classic wget or in the browser.
After downloading:
chmod 755 files.pl flamegraph.pl
./files.pl/path_to_the_analyzed_directory | ./flamegraph.pl –hash –countname=bytes > out.svg
For more options:
$ ./flamegraph.pl -h
Option h is ambiguous (hash, height, help)
USAGE: ./flamegraph.pl [options] infile > outfile.svg
–title TEXT # change title text
–subtitle TEXT # second level title (optional)
–width NUM # width of image (default 1200)
–height NUM # height of each frame (default 16)
–minwidth NUM # omit smaller functions (default 0.1 pixels)
–fonttype FONT # font type (default “Verdana”)
–fontsize NUM # font size (default 12)
–countname TEXT # count type label (default “samples”)
–nametype TEXT # name type label (default “Function:”)
–colors PALETTE # set color palette. choices are: hot (default), mem,
# io, wakeup, chain, java, js, perl, red, green, blue,
# aqua, yellow, purple, orange
–bgcolors COLOR # set background colors. gradient choices are yellow
# (default), blue, green, grey; flat colors use “#rrggbb”
–hash # colors are keyed by function name hash
–cp # use consistent palette (palette.map)
–reverse # generate stack-reversed flame graph
–inverted # icicle graph
–flamechart # produce a flame chart (sort by time, do not merge stacks)
–negate # switch differential hues (blue<->red)
–notes TEXT # add notes comment in SVG (for debugging)
–help # this message
eg,
./flamegraph.pl –title = “Flame Graph:malloc()” trace.txt > graph.svg
You will see that the total width (bottom of the graph) corresponds to the total size. The view is tree-like and shows the percentage and numeric size of each folder or file of the total, and you can just have a look at the graph to see which is the space-consuming file. For details, hover over the graph; to go deep, click on what you are interested in.