# Build a memory graph in linux terminal I was searching for a terminal based graph of usage of memory but I couldn't find one, so I built it using simple bash and python. First create a directory called `mem` and enter it with `cd mem` Then run the daemon part of the monitor: ``` while true; do free -m | head -2 | tail -1 | awk '{print $3}' > `date +'%Y-%m-%dT%H:%M:%S%z'`; sleep 1; done ``` To actually build the graph, use this: ``` watch -n1 'for f in `ls -r | head -30`; do num=`cat $f`; python -c "print(\"{} {}\".format(\"$f: $num\", \".\" * ($num/10)))"; done' ``` And the result is something like this: ``` 2018-07-11T11:26:36+0000: 330 ................................. 2018-07-11T11:26:35+0000: 316 ............................... 2018-07-11T11:26:34+0000: 285 ............................ 2018-07-11T11:26:33+0000: 236 ....................... 2018-07-11T11:26:32+0000: 235 ....................... 2018-07-11T11:26:31+0000: 236 ....................... 2018-07-11T11:26:30+0000: 236 ....................... 2018-07-11T11:26:29+0000: 238 ....................... 2018-07-11T11:26:28+0000: 236 ....................... 2018-07-11T11:26:27+0000: 236 ....................... 2018-07-11T11:26:26+0000: 240 ........................ 2018-07-11T11:26:25+0000: 236 ....................... 2018-07-11T11:26:24+0000: 236 ....................... 2018-07-11T11:26:23+0000: 236 ....................... 2018-07-11T11:26:22+0000: 239 ....................... 2018-07-11T11:26:21+0000: 236 ....................... 2018-07-11T11:26:20+0000: 343 .................................. 2018-07-11T11:26:19+0000: 330 ................................. 2018-07-11T11:26:18+0000: 327 ................................ 2018-07-11T11:26:17+0000: 313 ............................... 2018-07-11T11:26:16+0000: 287 ............................ 2018-07-11T11:26:15+0000: 238 ....................... 2018-07-11T11:26:14+0000: 236 ....................... 2018-07-11T11:26:13+0000: 236 ....................... 2018-07-11T11:26:12+0000: 237 ....................... 2018-07-11T11:26:11+0000: 236 ....................... 2018-07-11T11:26:10+0000: 236 ....................... 2018-07-11T11:26:09+0000: 236 ....................... 2018-07-11T11:26:08+0000: 240 ........................ 2018-07-11T11:26:07+0000: 237 ....................... ```