kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

TICK: T 数据采集工具Telegraf

wget https://repos.influxdata.com/rhel/8/x86_64/stable/telegraf-1.23.4-1.x86_64.rpm

基本概念

telegraf 属于 TICK 技术栈中的T

Telegraf 是一个用Go语言编写的代理程序,可收集系统和服务的统计数据,并写入到InfluxDB数据库。内存占用小,通过插件系统可轻松添加支持其他服务的扩展。

Telegraf metric是用于在处理期间对数据建模的内部表示,这些指标完全基于InfluxDB的数据模型,包含四个主要组件:

度量名称(Measurement)

标签(tags)

字段(Field)

时间戳

为什么要用Telegraf ?

可以采集多种组件的运行信息cpu memory,不需要手动写定时脚本采集,降低了数据的获取难度

配置简单

与InfluxDB完美结合

按照时间序列采集数据

轻量级,占用内存小

安装

rpm -ivh telegraf-1.23.4-1.x86_64.rpm

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
interval = "60s"

[root@localhost ~]# diff /etc/telegraf/telegraf.conf /etc/telegraf/telegraf.conf.orig 
106c106
<   hostname = "192.168.100.197"
---
>   hostname = ""
130,136d129
<      urls = ["http://192.168.100.178:8086"] # required 
<      database = "telegraf" # required
<      timeout = "5s"
<      username = "telegraf"
<      password = "password"
< 
< 
5849,5850c5842
< [[inputs.net]]
<       interfaces = ["eth*", "enp0s[0-1]", "lo"]
---
> 
6081,6085d6072
< [[inputs.nstat]]
<     proc_net_netstat = "/proc/net/netstat"
<     proc_net_snmp = "/proc/net/snmp"
<     proc_net_snmp6 = "/proc/net/snmp6"
<     dump_zeros       = true

add

1
2
3
4
[[inputs.procstat]]
	exe = "mariadbd"
[[inputs.procstat]]
	exe = "httpd"

add

percpu 改成 false 能减少大量数据

1
2
3
[[inputs.cpu]]
	## Whether to report per-cpu stats or not
	percpu = false

disk 选项

1
2
3
4
5
6
7
8
9
[[inputs.disk]]
	# win 指定盘符
	mount_points = ["C:", "D:"]

	# win 去除 CDFS, 一定要大写
	ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs", "CDFS"]

	# 去除 cifs
	ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs", "cifs"]

window telegraf

https://blog.csdn.net/chen_221/article/details/125664892

1.下载最新telegraf压缩包

https://github.com/influxdata/telegraf/releases

将解压出来文件复制到 C:\Program Files\telegraf 下

修改 telegraf.conf 文件

1
2
3
4
5
6
7
8
9
10
11
12
# 修改这两个配置, 新增会重复导致失败 .\telegraf.exe --debug
interval = "60s"
hostname = "192.168.100.196"


# 新增下面配置
[[outputs.influxdb]]
	urls = ["http://192.168.100.178:8086"]
	database = "telegraf"
	timeout = "5s"
	username = "telegraf"
	password = "password"

注册Windows服务

运行powershell,进入 C:\Program Files\telegraf 文件夹,执行 .\telegraf.exe -service install 后查看服务, 然后启动服务即可

.\telegraf.exe -service uninstall

system, influx

« Linux中使用Dnsmasq部署DNS服务 TICK: I 时序数据库InfluxDB »