监控建设06telegraf建设

解压telegraf

tar xvf telegraf-1.11.1_linux_amd64.tar.gz

修改配置文件

[root@bigdata3 telegraf]# pwd

/opt/apps/telegraf/etc/telegraf

[root@bigdata3 telegraf]# cp telegraf.conf telegraf.conf.bak

可清空原配置,拷贝下方配置

vi /opt/telegraf/etc/telegraf/telegraf.conf

[global_tags]

dc = "host-test" #切记此dc

[agent]

interval = "60s"

round_interval = true

metric_batch_size = 1000

metric_buffer_limit = 10000

collection_jitter = "0s"

flush_interval = "10s"

flush_jitter = "0s"

precision = ""

debug = false

quiet = false

logfile = "/opt/apps/telegraf/logs/telegraf.log" #日志目录

hostname = ""

omit_hostname = false

[[outputs.influxdb]]

urls = ["http://192.168.1.5:8086"] #influxdb端口

database = "telegraf"

retention_policy = ""

username = "telegraf"

password = "telegraf"

[[outputs.prometheus_client]]

listen = ":9275"

[[aggregators.histogram]]

period = "60s"

drop_original = false

[[aggregators.histogram.config]]

buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]

measurement_name = "cpu"

fields = ["usage_user","usage_idle"]

[[aggregators.histogram.config]]

buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0]

measurement_name = "mem"

fields = ["used_percent","available_percent"]

[[aggregators.histogram.config]]

buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 150.0, 200.0, 300.0]

measurement_name = "system"

fields = ["load5"]

[[aggregators.histogram.config]]

buckets = [0.0, 100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0, 1200.0, 1500.0, 2000.0, 3000.0]

measurement_name = "processes"

fields = ["total_threads","total"]

[[inputs.cpu]]

percpu = true

totalcpu = true

collect_cpu_time = false

report_active = false

[[inputs.disk]]

ignore_fs = ["/","/home/*","/home","/mnt/data*","/data*","/mnt/sata*","/mnt/sd*"]

[[inputs.diskio]]

[[inputs.kernel]]

[[inputs.mem]]

[[inputs.net]]

[[inputs.netstat]]

[[inputs.processes]]

[[inputs.swap]]

[[inputs.system]]

创建启动脚本

vi /usr/lib/systemd/system/telegraf.service

[Unit]

Description=The plugin-driven server agent for reporting metrics into InfluxDB

Documentation=https://github.com/influxdata/telegraf

After=network.target

 

[Service]

EnvironmentFile=-/opt/telegraf/etc/telegraf

User=telegraf

ExecStart=/opt/apps/telegraf/usr/bin/telegraf -config=/opt/apps/telegraf/etc/telegraf/telegraf.conf $TELEGRAF_OPTS

ExecReload=/bin/kill -HUP $MAINPID

Restart=on-failure

RestartForceExitStatus=SIGPIPE

KillMode=control-group

 

[Install]

WantedBy=multi-user.target

添加进程账号

useradd telegraf

echo "telegraf" | passwd --stdin telegraf

更改目录权限

chown -R telegraf:telegraf /opt/telegraf

启动telegraf

systemctl start telegraf

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值