<p><a href="https://stackoverflow.com/questions/32230/tracking-down-where-disk-space-has-gone-on-linux">In this question</a> someone asked for ways to display disk usage in Linux. I'd like to take this one step further down the cli-path... how about a shell script that takes the output from something like a reasonable answer to the previous question and generates a graph/chart from it (output in a png file or something)? This may be a bit too much code to ask for in a regular question, but my guess is that someone already has a oneliner laying around somewhere...</p>

[{'answer_id': 40862, 'author': 'toolkit', 'author_id': 3295, 'author_profile': 'https://Stackoverflow.com/users/3295', 'pm_score': 1, 'selected': False, 'text': '<p>I guess there are a couple of options:</p>\n\n<ol>\n<li><p>For a pure CLI solution, use something like gnuplot. See <a href="http://t16web.lanl.gov/Kawano/gnuplot/intro/working-e.html" rel="nofollow noreferrer">here</a> for example usage. I haven\'t used gnuplot since my student days :-)</p></li>\n<li><p>Not really a pure CLI solution, but download something like <a href="http://www.jfree.org/jfreechart/" rel="nofollow noreferrer">JFreeChart</a> and write a simple Java app that reads stdin and creates your chart.</p></li>\n</ol>\n\n<p>Hope this helps.</p>\n'}, {'answer_id': 41081, 'author': 'jj33', 'author_id': 430, 'author_profile': 'https://Stackoverflow.com/users/430', 'pm_score': 2, 'selected': False, 'text': '<p>We rolled our own at work using <a href="http://oss.oetiker.ch/rrdtool/" rel="nofollow noreferrer">RRDtool</a> (the data storage back end to tools like MRTG).  We run a perl script every 5 minutes that takes a du per partition and stuffs it into an RRD database and then uses RRD\'s graph function to build graphs.  It takes a while to igure out how to set up the .rrd files (for instance, I had to re-learn RPN to do some of the calculations I wanted to do) but if you have some data you want to graph over time, RRD tool\'s a good bet.</p>\n'}, {'answer_id': 43733, 'author': 'dbr', 'author_id': 745, 'author_profile': 'https://Stackoverflow.com/users/745', 'pm_score': 4, 'selected': True, 'text': '<p>I would recommend <a href="http://munin.projects.linpro.no/" rel="nofollow noreferrer">munin</a>. It is designed for exactly this sort of thing - graphing CPU usage, memory usage, disc-usage and such. sort of like MRTG (but MRTG is primarily aimed at graphing router\'s traffic, graphing anything but bandwidth with it is very hackish)</p>\n\n<p>Writing Munin plugins is very easy (it was one of the projects goals). They can be written in almost anything (shell script, perl/python/ruby/etc, C, anything that can be execute and produce an output). The plugin output format is basically <code>disc1usage.value 1234</code>. And debugging the plugins is very easy (compared to MRTG)</p>\n\n<p>I\'ve set it up on my laptop to monitor disc-usage, bandwidth usage (by pulling data from my ISP\'s control panel, it graphs my two download "bins", uploads and newsgroup usage), load average and number of processes. Once I got it installed (currently slightly difficult on OS X, but it\'s trivial on Linux/FreeBSD), I had written a plugin in a few minutes, and it worked, first time!</p>\n\n<p>I would describe how it\'s setup, but the munin site will do that far better than I could!</p>\n\n<p>There\'s an example installation <a href="http://munin.ping.uio.no/" rel="nofollow noreferrer">here</a></p>\n\n<p>Some alternatives are nagios and cacti. You could also write something similar using rrdtool. Munin, MRTG and Cacti are basically all far-nicer-to-use systems based around this graphing tool.</p>\n\n<p>If you want something really, really simple, you could do..</p>\n\n<pre><code>import os\nimport time\nwhile True:\n    disc_usage = os.system("df -h / | awk \'{print $3}\'")\n    log = open("mylog.txt")\n    log.write(disc_usage + "\\n")\n    log.close()\n    time.sleep(60*5)\n</code></pre>\n\n<p>Then..</p>\n\n<pre><code>f = open("mylog.txt")\nlines = f.readlines()\n\n# Convert each line to a float number\nlines = [float(cur_line) for cur_line in lines]\n\n# Get the biggest and smallest\nbiggest = max(lines)\nsmallest = min(lines)\n\nfor cur_line in lines:\n    base = (cur_line - smallest) + 1 # make lowest value 1\n    normalised = base / (biggest - smallest) # normalise value between 0 and 1\n    line_length = int(round(normalised * 28)) # make a graph between 0 and 28 characters wide\n    print "#" * line_length\n</code></pre>\n\n<p>That\'ll make a simple ascii graph of the disc usage. I <em>really really</em> don\'t recommend you use something like this. Why? The log file will get bigger, and bigger, and bigger. The graph will get progressively slower to graph. RRDTool uses a rolling-database system to store it\'s data, so the file will never get bigger than about 50-100KB, and it\'s consistently quick to graph as the file is a fixed length.</p>\n\n<p>In short. If you want something to easily graph almost anything, use <a href="http://munin.projects.linpro.no/" rel="nofollow noreferrer">munin</a>. If you want something smaller and self-contained, write something with RRDTool.</p>\n'}, {'answer_id': 1313955, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>If some ASCII chars are "graphical" enough for you, I can recommend <a href="http://dev.yorhel.nl/ncdu/" rel="noreferrer">ncdu</a>. It is a very nice interactive CLI tool, which helps me a lot to step down large directories without doing cd bigdir ; du -hs over and over again.</p>\n'}]
['https://Stackoverflow.com/questions/40737', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4162/']