其他分享
首页 > 其他分享> > categraf执行脚本使用方法

categraf执行脚本使用方法

作者:互联网

1. 创建脚本

cd categraf-v0.2.2-linux-amd64

[root@bogon categraf-v0.2.2-linux-amd64]# vim scripts/echo.sh 

#!/bin/bash

echo "metric_preffix,labelkey1=labelval1,labelkey2=labelval2 self_metric_name1=100,self_metric_name2=200"

2. 编辑categraf input.exec配置

vim categraf-v0.2.2-linux-amd64/conf/input.exec/exec.toml

# # collect interval
# interval = 15

[[instances]]
# # commands, support glob
commands = [
     "scripts/.sh"   # 指定脚本位置
]

# # timeout for each command to complete
 timeout = 5

# # interval = global.interval  interval_times
 interval_times = 1

# # mesurement,labelkey1=labelval1,labelkey2=labelval2 field1=1.2,field2=2.3
 data_format = "influx"

3. 执行测试

./categraf -test -inputs exec

输出:
23:26:07 metric_preffix_self_metric_name1 agent_hostname=bogon labelkey1=labelval1 labelkey2=labelval2 100
23:26:07 metric_preffix_self_metric_name2 agent_hostname=bogon labelkey1=labelval1 labelkey2=labelval2 200
23:26:12 metric_preffix_self_metric_name1 agent_hostname=bogon labelkey1=labelval1 labelkey2=labelval2 100
23:26:12 metric_preffix_self_metric_name2 agent_hostname=bogon labelkey1=labelval1 labelkey2=labelval2 200

标签:脚本,metric,labelval1,labelval2,执行,self,labelkey2,categraf
来源: https://www.cnblogs.com/wt11/p/16479762.html