A simple script that collects CPU and memory usage from the leading processes listed by the top command and stores on a local sqlite database. Values are stores in a 'round-robin' fashion so older data gets removed when the storage hits its limits.
The collected can be later plotted using vega-lite, like this:
The number of processes as well as the maximum number of records stores can be adjusted in mon.sh.
For collecting:
- top, awk
- sqlite3
For plotting:
- node, vega-lite
Start a store with:
./mon.sh data.db initAnd record data with:
./mon.sh data.db recordPreferably, you may setup a cron like:
* * * * * cd <path-to-this-folder> && ./mon.sh data.db record
which fetches data every minute.
To plot, simply do:
./plot.sh data.db # output to out.png
# or
/plot.sh data.db top-usage.png- Special thanks to this post which explains how to use a sqlite3 table as a circular buffer.
