Telegraf 采集 CPU 数据 ,测试派详解

19 篇文章 0 订阅
11 篇文章 0 订阅

一、配置文件

进入到如下的配置文件

[root@localhost ~]# VIM /etc/telegraf/telegraf.conf

[global_tags]

[agent]

# 收集数据的间隔
interval = "10s"

round_interval = true

metric_batch_size = 1000

metric_buffer_limit = 10000

collection_jitter = "0s"

# 写入 inflxdb 的时间间隔

flush_interval = "10s"

flush_jitter = "0s"

precision = ""

debug = false

quiet = false

# 日志路径

logfile = "/data/log/telegraf.log"

hostname = ""

omit_hostname = false

[[outputs.influxdb]]

urls = ["http://192.168.227.56:8086"]

database = "telegraf"

username = "admin"

password = "123456"

[[inputs.cpu]]

# 是否采集每个 CPU 的数据

percpu = false

# 是否采集总 CPU 的数据

totalcpu = true

collect_cpu_time = false

report_active = false

二、启动 Telegraf

[root@localhost data]# systemctl start telegraf.service

[root@localhost data]# service telegraf status

开机启动

[root@localhost data]# systemctl enable telegraf.service

三、在 inflxdb 验证数据(inflxdb 数据库所在的机器)

[root@localhost ~]# influx -username 'admin' -password '123456' -database telegraf

select * from CPU limit 3

name: CPU

time CPU host usage_guest usage_guest_nice usage_idle usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system usage_user


1598452090000000000 cpu-total localhost.localdomain 0 0 97.93294681121132 0.17645576002015695 0.15124779430301213 0 0.07562389715150607 0 0.8822788001008564 0.7814469372322055

1598452090000000000 cpu0 localhost.localdomain 0 0 98.58870967742497 0 0.20161290322583764 0 0 0 0.5040322580645762 0.7056451612904496

1598452090000000000 cpu1 localhost.localdomain 0 0 98.5901309164208 0 0.10070493454176956 0 0.10070493454178744 0 0.5035246727089193 0.70493454179253

 

四、在 grafana 展示监控 CPU 的数据

  1. 点击设置选择“data sources"

image.png

424 x 661

  1. 配置数据源

image.png

728 x 514 1154 x 814

image.png

728 x 230 1107 x 350

image.png

703 x 335

  1. 创建面板

image.png

694 x 271

点击 new dashboard 按钮

image.png

728 x 279 1411 x 541

点击 Graph 图标

image.png

728 x 493 732 x 496

点击“edit”按钮

image.png

728 x 375 780 x 402

选择数据源

image.png

728 x 411 886 x 500

添加需要关注的指标值:

image.png

728 x 350 1068 x 514

百分比占用显示:

image.png

728 x 586 752 x 605

五、选择保存默认项

[root@localhost telegraf]# VIM /etc/telegraf/telegraf.conf

对 CPU 只采集的监控项

fieldpass = ["usage_user","usage_idle", "usage_iowait", "usage_system"]

重启 telegraf

[root@localhost telegraf]# systemctl restart telegraf

六、在 inflxdb 上面重新采集数据

[root@localhost ~]# influx -username 'admin' -password '123456' -database telegraf

use telegraf;

drop measurement cpu;

image.png

728 x 338 1842 x 855

选择刷新频率和线上的时间段



作者:mike.liu
链接:http://testingpai.com/article/1601096205235
来源:测试论坛
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值