您的位置:首页 > 其它

Execbeat

2016-05-12 20:37 357 查看
官网位置:https://github.com/christiangalsterer/execbeat

概览

Execbeat是用于执行命令的beat。可以配置多个命令,定期的执行提供标准的输入和输出。可以输出数据到Logstash和Elasticsearch。

配置

基本的配置文件用yaml作为语法。文件中包含基本的对应于公共的beats的配置。

特殊的配置是设置一系列的执行命令。每一个执行的execs,开始于一个“-”和指定特定的配置选项。

官网的基本例子

execbeat:

execs:
# Each - Commands to execute.
-
# Optional cron expression, defines when to execute the command.
# Default is every 1 minute.
cron: "@every 5s"

# The command to execute by Execbeat
command: echo

# Optional arguments to be passed to the command to execute
args: "Hello Execbeat"

# Type to be published in the 'type' field. For Elasticsearch output,
# the type defines the document type these entries should be stored
# in. Default: execbeat
document_type: echo

# Optional additional fields. These field can be freely picked
# to add additional information
fields:
host: myhost


编译好后,应用Elasticsearch模板,执行以下命令

curl -XPUT 'http://localhost:9200/_template/execbeat' -d@etc/execbeat.template.json


构建,测试,运行的命令

# Build
GOPATH=<your go path> make execbeat

# Test
GOPATH=<your go path> make test

# Run
./execbeat -c /etc/execbeat/execbeat.yml


原先用jmxproxybeat,监控tomcat运行改为Execbeat方式,并放入docker容器中测试,

需要

1、 java写的监控tomcat中jmx指标的代码,(原有项目中存在), 打好linux中可执行的脚本

2、execbeat build成linux可执行的二进制命令,模板文件execbeat.template.json和配置文件execbeat.yml

3、配置jmx的tomcat

以数据卷的方式挂载在docker容器下,以下命令打开一个容器,挂载在/test下

docker run -it  -v /usr/local/dockertomcat/:/test/:rw  tomcatsensuvi  /bin/bash


配置

查看docker的ip(cat /etc/hosts),修改tomcat配置jmx中的ip信息;

把1中的执行脚本路径放入PATH;

修改 execbeat.yml文件,注意 添写命令时,前面也留有一个空格(重要, 不然会报错!), output配置好要发送数据到的Elasticsearch的地址。

Now, 执行上面说的命令

# Run
./execbeat -c /etc/execbeat/execbeat.yml


可以在 Elasticsearch看到发送的数据,时刻监控tomcat运行状态。(注意docker容器必须能够ping通Elasticsearch的主机)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  elastic