2021-02-13 16:05:42 +00:00
|
|
|
|
|
|
|
Ultra-light docker monitor
|
|
|
|
=========================
|
|
|
|
|
|
|
|
This light tool permits:
|
|
|
|
- to export docker container memory usage in a JSON file `stats.json`
|
|
|
|
- display curves of the memory usages using the JSON file
|
|
|
|
|
|
|
|
The export and the display are two different parts. This allow to run the display in another machine.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Setup the stats export
|
|
|
|
----------------------
|
|
|
|
|
2021-02-13 19:23:19 +00:00
|
|
|
Open the cron tab in edition mode:
|
2021-02-13 16:05:42 +00:00
|
|
|
|
|
|
|
crontab -e
|
|
|
|
|
2021-02-13 19:23:19 +00:00
|
|
|
Then add a new line (to run the check each ten minutes)
|
2021-02-13 16:05:42 +00:00
|
|
|
|
|
|
|
*/10 * * * * /path.io/docker-stats-histo/save_docker_stats.sh >>/dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
|
|
**Note:**
|
2021-02-13 19:23:19 +00:00
|
|
|
- Normaly cron send task outputs (echo) via mail. As the MTA (Mail Transfert Agent),
|
|
|
|
may not be set up, the crontab line redirect the outputs into `/dev/null`.
|
|
|
|
It can also be a path to a log file.
|
2021-02-13 16:05:42 +00:00
|
|
|
- No sudo is needed, crontab is called with current user.
|
|
|
|
|
|
|
|
|
|
|
|
Display stats
|
|
|
|
-------------
|
|
|
|
|
2021-02-13 19:23:19 +00:00
|
|
|
This step permits to generate a render from a stats file (generated by the script
|
2021-02-13 19:15:17 +00:00
|
|
|
called by the crontab, see stats export section).
|
|
|
|
|
|
|
|
### Install
|
|
|
|
|
2021-02-13 19:23:19 +00:00
|
|
|
Need python3 with `venv` module
|
2021-02-13 19:15:17 +00:00
|
|
|
|
|
|
|
sudo apt install python3 python3-venv
|
|
|
|
|
|
|
|
### Run
|
|
|
|
Go in [display](display) folder
|
|
|
|
|
|
|
|
cd display
|
|
|
|
|
|
|
|
Then to generate a png, just run (install is automatically done if needed)
|
2021-02-13 19:23:19 +00:00
|
|
|
|
2021-02-13 19:15:17 +00:00
|
|
|
./render_stats.sh stats.json
|
|
|
|
|
|
|
|
It is also possible to see a web version fo the render :
|
2021-02-13 19:23:19 +00:00
|
|
|
|
2021-02-13 19:15:17 +00:00
|
|
|
./render_stats.sh stats.json -w
|
|
|
|
|
|
|
|
**Note:** if the stats file is in a remote server, one can use `scp` to get it:
|
|
|
|
scp alban@eunuque.caracals.org:/path/to/docker-stats-histo/stats.json .
|