open-falcon agent plugin的使用

agent中的plugin是一种辅助的采集数据的方式。
在plugin的脚本中向stdout打印metric信息,agent会自动收集并上报给transfer。

下面介绍其使用方式。

1. 配置agent, 使能plugin

编辑agent/config/cfg.json

设置”enabled”为true,配置dir,git 等。

其中,dir 是相对于open-falcon的根目录的路径,如果根目录是/home/work/open-falcon,则此处的dir的绝对路径是/home/work/open-falcon/dir,也就是/home/work/open-falcon/git_repo

注意的一点是:此处的dir名称必须与git 拉取下来的仓库名称一致,否则,拉取时会报错。

agent配置文件如下:

{
“debug”: true,
“hostname”: “”,
“ip”: “”,
“plugin”: {
“enabled”: true,
“dir”: “./git_repo”,
“git”: “git@192.168.33.152:/home/git/git_repo”,

“logs”: “./logs”
},
“heartbeat”: {
“enabled”: true,
“addr”: “0.0.0.0:6030”,
“interval”: 60,
“timeout”: 1000
},

}

2. 从git仓库拉取plugin

在部署agent机器上,执行如下命令,拉取插件库:

$ curl http://127.0.0.1:1988/plugin/update
success

查看/home/work/open-falcon根目录,发现多了一个git_repo目录

$ ll
...

drwxr-xr-x 3 lanyang lang 4096 Sep  5 20:11 git_repo
drwxr-xr-x 6 langyang lanyang 4096 Jun 19 17:02 graph

...

查看其内容

$ cat git_repo/60_stats.py 
#!/usr/bin/python

import time
import json


output = [{"endpoint": "monitor-test-centos", "tags": "", "timestamp": int(time.time()), "metric": "agent.cpu", "value": 1.8, "counterType": "GAUGE", "step": 60}]

print  json.dumps(output)

其执行时的输出:

[{“endpoint”: “monitor-test-centos”, “tags”: “”, “timestamp”: 1504615532, “metric”: “agent.cpu”, “value”: 1.8, “counterType”: “GAUGE”, “step”: 60}]

3. portal中配置plugins

进入HostGroups界面

这里写图片描述

*创建group
如图,已经创建group”DRAGON_ARM”

配置plugin路径

配置这个group要执行的插件脚本的路径,该路径是相对路径,相对于agent的配置文件中dir 的路径, 例如本例中为git_repo,plugin dir就是相对于git_repo的路径。

配置如图,配置成了当前目录,也就是git_repo目录下的所有的插件文件:

这里写图片描述

配置hosts
对刚才创建”DRAGON_ARM”组,点击”Host”,添加host。

查看结果

完成后,稍等片刻。打开主页,针对刚才host,查看metric.

这里写图片描述

点击agent.cpu超链接,即可跳转到详情页面。

参考

https://book.open-falcon.org/zh_0_2/philosophy/plugin.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值