CentOS下安装telegraf

安装

1. 下载并安装

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.20.4-1.x86_64.rpm
sudo yum localinstall telegraf-1.20.4-1.x86_64.rpm

2. 安装完成后配置文件的默认路径在/etc/telegraf/telegraf.conf

3. 修改配置文件将数据指向数据源,这里我用的是本地的Influxdb

sudo vi /etc/telegraf/telegraf.conf
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
  ## The full HTTP or UDP URL for your InfluxDB instance.
  ##
  ## Multiple URLs can be specified for a single cluster, only ONE of the
  ## urls will be written to each interval.
  # urls = ["unix:///var/run/influxdb.sock"]
  # urls = ["udp://127.0.0.1:8089"]
  urls = ["http://127.0.0.1:8086"]

  ## The target database for metrics; will be created as needed.
  ## For UDP url endpoint database needs to be configured on server side.
  database = "telegraf"

4. 开启telegraf服务,这时telegraf开始收集本机数据并发送到influxdb

sudo systemctl start telegraf

5.  运行Influx CLI,可以看到已经有数据

[vagrant@bin9wei001 ~]$ influx
Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> SHOW DATABASES
name: databases
name
----
_internal
test
telegraf
> USE telegraf
Using database telegraf
> SHOW MEASUREMENTS
name: measurements
name
----
cpu
disk
diskio
kernel
mem
processes
swap
system
> select * from "mem" limit 5
name: mem
time                active    available available_percent buffered cached    commit_limit committed_as dirty free      high_free high_total host       huge_page_size huge_pages_free huge_pages_total inactive  low_free low_total mapped   page_tables shared  slab     sreclaimable sunreclaim swap_cached swap_free  swap_total total      used      used_percent       vmalloc_chunk  vmalloc_total  vmalloc_used write_back write_back_tmp
----                ------    --------- ----------------- -------- ------    ------------ ------------ ----- ----      --------- ---------- ----       -------------- --------------- ---------------- --------  -------- --------- ------   ----------- ------  ----     ------------ ---------- ----------- ---------  ---------- -----      ----      ------------       -------------  -------------  ------------ ---------- --------------
1638520740000000000 262270976 714866688 68.79685910929258 2117632  478117888 2667028480   576315392    8192  389136384 0         0          bin9wei001 2097152        0               0                285675520 0        0         70258688 4722688     7036928 58060800 33251328     24809472   0           2147479552 2147479552 1039097856 169725952 16.33397191804041  35184363569152 35184372087808 6213632      0          0
1638520750000000000 264458240 711102464 68.43460025385713 2117632  481460224 2667028480   576315392    24576 383643648 0         0          bin9wei001 2097152        0               0                285749248 0        0         70750208 4759552     7036928 61444096 36478976     24965120   0           2147479552 2147479552 1039097856 171876352 16.54092066570485  35184363569152 35184372087808 6213632      0          0
1638520760000000000 264515584 711106560 68.43499444194792 2117632  481464320 2667028480   576315392    45056 383643648 0         0          bin9wei001 2097152        0               0                285736960 0        0         70791168 4759552     7036928 61444096 36478976     24965120   0           2147479552 2147479552 1039097856 171872256 16.54052647761406  35184363569152 35184372087808 6213632      0          0
1638520770000000000 294518784 708620288 68.19572227083876 2117632  481472512 2667028480   576315392    36864 381149184 0         0          bin9wei001 2097152        0               0                257871872 0        0         70799360 4763648     7036928 61444096 36478976     24965120   0           2147479552 2147479552 1039097856 174358528 16.779798648723226 35184363569152 35184372087808 6213632      0          0
1638520780000000000 294862848 708513792 68.18547338047823 2117632  481501184 2667028480   576315392    24576 381022208 0         0          bin9wei001 2097152        0               0                257548288 0        0         70815744 4763648     7036928 61464576 36499456     24965120   0           2147479552 2147479552 1039097856 174456832 16.78925916290217  35184363569152 35184372087808 6213632      0          0
>

参考

Get started with Telegraf | Telegraf 1.20 Documentation

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值