

Terminal Perf Graphs in one Command
source link: https://zwischenzugs.com/2018/03/27/terminal-perf-graphs-in-one-command/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Sysstat and Graphs
If you have the sysstat
package set up on your server, then you likely already know you can get historical CPU performance information with sar
like this:
$ sar | head Linux 4.15.0-10-generic (cage) 27/03/18 _x86_64_ (4 CPU) 00:00:01 CPU %user %nice %system %iowait %steal %idle 00:01:01 all 1.79 0.00 21.70 0.03 0.00 76.47 00:02:01 all 1.28 0.01 10.09 0.01 0.00 88.62 00:03:01 all 1.39 0.00 6.09 0.01 0.00 92.51 00:04:01 all 1.20 0.00 5.23 0.02 0.00 93.55 00:05:01 all 1.26 0.00 5.74 0.01 0.00 92.98 00:06:01 all 1.30 0.00 20.46 0.83 0.00 77.40 00:07:01 all 0.82 0.01 9.28 0.02 0.00 89.87
and you also probably know you can get the history of various metrics, not just CPU, eg disk IO, run queue size, and so on.
This info is great, but sometimes you just want a quick view of what’s going on.
You can faff around with some platform to try and get the information graphed in a sophisticated way if you have the time, skills and inclination. But mostly I just want a quick view with the least fuss.
So I used this script and bundled it into a container image to produce ascii graphs with one command. They look like this (click here to enlarge):
At first they’re hard to parse, but you quickly get used to them.
They’re great for quickly seeing when things went south, and what else went on at the time.
Running
To run this on your host, do:
$ docker run \ -e SAR_REPORT_DAY="${SAR_REPORT_DAY:-$(date +%d)}" \ -e LINES=${LINES:-$(stty size | awk '{print $1}')} \ -e COLUMNS=${COLUMNS:-$(stty size | awk '{print $NF}')} \ -e TERM=${TERM:-xterm} \ -v /var/log/sysstat:/var/log/sysstat:ro \ imiell/sar_report
The -e
arguments set the ‘day’ to report on (defaults to today’s day), and pass the terminal settings to
The -v
flag mounts the /var/log/systat
folder into the container (it is mounted read-only, to reduce any risk/fear of the Docker container messing up your host’s filesystem).
To change the day, set (eg) SAR_REPORT_DAY=01
in the terminal before running the command.
You’ll need Docker (and sysstat
, of course) installed and running on your host for this to work out of the box.
Or you can run the command:
$ ./sar_report
from the repo‘s folder.
Suggestions? Problems?
The code is here and is a work in progress – please suggest changes/raise bugs etc. on Github.
If you like this post, you might like Learn Git the Hard Way, Learn Bash the Hard Way or Docker in Practice
Get 39% off Docker in Practice with the code: 39miell2
Recommend
-
32
前言 今天早晨QA来报,我们自己的集群环境里,124~128集群里面,128节点ceph-osd cpu load重,CPU使用率是200%~400% 之间。
-
10
BPF binaries: BTF, CO-RE, and the future of BPF perf tools 04 Nov 2020 Two new technologies, BTF and CO-RE, are paving the way for BPF to become a billion-dollar industry. Right now there are many BPF (eBPF) startups buildin...
-
7
Disallowing perf_event_open() Did you know...?LWN.net is a subscriber-supported publication; we rely on subscribers to keep the entire operation going. Please help out by
-
17
Oct 1, 2017 C2c False Sharing Detection In Linux Perf https://joemario.github.io/blog/2016/09/01/c2c-blog/ C2C - Linux Perf里的“伪共享”检测 你是否在NUMA环境中运行你的应用呢,或者你的应用是多线程,又或者是有共享内...
-
11
Alpha release of CashDB, high-perf backend for UTXO storage The alpha version of CashDB has been released. CashDB is a fork and the successor of Terab which has unfortunat...
-
10
High-perf SelectInParallel in 120 lines of C# A few months ago at Lokad, we started working on 8-core machines. Multi-core machines need
-
6
Perf mattered at the Fronteers Spring Conference 01 April 2016 ・ category: write-ups ...
-
9
diskgraph Monitor for disk IO Introduction The diskgraph tool will graph disk IO under linux, in a terminal. Examples: $ ./diskgraph /dev/nvme0n1 $ ./diskgraph /dev/sda
-
11
Chia Harvest Graph Monitor for Chia Harvesting Introduction The chiaharvestgraph tool will graph Chia Harvesting activity in a linux terminal. Use a 24-bit colour terminal, like xterm or gnome-terminal. Buildi...
-
16
How To Draw basic graphs on Linux terminalHello folks, in this tutorial, we are going to learn how to draw basic graphs on the Linux terminal using a python based tool called Termgraph. Termgraph can be used to draw a number of graphs on the...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK