信息采集软件测试,Telegraf采集CPU数据,测试派详解
一、配置文件
進入到如下的配置文件
[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 的數據
點擊設置選擇“data sources"
424 x 661
配置數據源
728 x 514 1154 x 814
728 x 230 1107 x 350
703 x 335
創建面板
694 x 271
點擊 new dashboard 按鈕
728 x 279 1411 x 541
點擊 Graph 圖標
728 x 493 732 x 496
點擊“edit”按鈕
728 x 375 780 x 402
選擇數據源
728 x 411 886 x 500
添加需要關注的指標值:
728 x 350 1068 x 514
百分比占用顯示:
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;
728 x 338 1842 x 855
選擇刷新頻率和線上的時間段
作者:mike.liu
鏈接:http://testingpai.com/article/1601096205235
來源:測試社區http://testingpai.com
總結
以上是生活随笔為你收集整理的信息采集软件测试,Telegraf采集CPU数据,测试派详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 400分理科学计算机,理科400分能上哪
- 下一篇: 阻止计算机访问注册表,电脑怎么样防止注册