安装 Sampler shell命令可视化工具
郑小孩
・2 分钟阅读
在本指南中,你将学习如何在Linux上安装shell命令可视化工具, Sampler 是shell命令执行,可视化和警报的工具。
在Linux上安装 Sampler shell命令可视化工具
下载 Sampler 二进制
wget https://github.com/sqshq/sampler/releases/download/v1.0.2/sampler-1.0.2-linux-amd64
安装 Sampler
在Linux上安装 Sampler ,就像将二进制文件复制到/usr/bin目录一样简单,如下所示。
cp sampler-1.0.2-linux-amd64 /usr/bin/sampler
chmod +x/usr/bin/sampler
Sampler 用法
使用 Sampler ,你可以执行各种shell脚本,从而获得指标,并且输出可视化,Sampler配置了一个简单的YAML文件,因此你需要在YAML配置文件中定义shell命令。
创建了shell命令配置文件后,就可以将它传递给 Sampler,使用-c选项执行,例如-c config.yml 。
创建配置文件例子
首先,我们创建一个简单的配置文件来可视化几个shell命令,例如,可视化CPU使用情况,系统运行时间,用户数量,内存使用率,如下所示:
vim config.yml
sparklines:
- title: CPU usage
position: [[42, 12], [38, 16]]
rate-ms: 200
scale: 0
sample: ps -A -o %cpu | awk '{s+=$1} END {print s}'
textboxes:
- title: Memory Usage
position: [[1, 27], [79, 15]]
rate-ms: 200
sample: free -h
- title: Logged in Users
position: [[0, 12], [41, 16]]
rate-ms: 200
sample: w
asciiboxes:
- title: System Uptime
position: [[0, 0], [80, 12]]
rate-ms: 500
color: 43
sample: uptime | cut -d',' -f1
要查看可视化,只需使用配置文件运行 Sampler ;
sampler -c config.yml
这就是简单的Sampler shell可视化命令。
如果需要查看更多可视化效果例子,查看sampler的文档 ,好好享受吧。