小米监控部署agent

centos6.9

工作目录:

[root@centos2 services]# /usr/local/services

安装环境

open-falcon的后端组件都是使用Go语言编写的,本节我们搭建Go语言开发环境,clone代码

我们使用64位Linux作为开发环境,与线上环境保持一致。如果你所用的环境不同,请自行解决不同平台的命令差异

首先安装Go语言开发环境:

[root@centos2 services]# wget https://storage.googleapis.com/golang/go1.6.3.linux-amd64.tar.gz

配置环境变量:

添加以下配置
[root@centos2 agent]# vim /etc/profile
export HOME=/usr/local/service
export GOROOT=$HOME/go
export GOPATH=$HOME/workspace
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
然后执行命令使其生效:
[root@centos2 agent]# source /etc/profile

解压go包。
下载小米监控安装包:

wget  https://github.com/open-falcon/of-release/releases/download/v0.1.0/open-falcon-v0.1.0.tar.gz  -O  open-falcon-latest.tar.gz

解压:

for x in `find ./tmp/ -name "*.tar.gz"`;do \
    app=`echo $x|cut -d '-' -f2`; \
    mkdir -p $app; \
    tar -zxf $x -C $app; \
done

我这里是用git 拉下来的代码:

[root@centos2 github.com]# pwd
/usr/local/services/go/src/github.com
[root@centos2 github.com]#  git clone --recursive https://github.com/open-falcon/of-release.git
然后: mv of-release open-falcon

进入agent:

[root@centos2 github.com]# ll open-falcon/
total 76
drwxr-xr-x 10 root root 4096 Aug 16 00:23 agent
drwxr-xr-x  7 root root 4096 Aug 15 23:47 aggregator
drwxr-xr-x 11 root root 4096 Aug 15 23:48 alarm
drwxr-xr-x  8 root root 4096 Aug 15 23:48 common
drwxr-xr-x  4 root root 4096 Aug 15 23:49 dashboard
drwxr-xr-x 12 root root 4096 Aug 15 23:49 fe
drwxr-xr-x  8 root root 4096 Aug 15 23:50 gateway
drwxr-xr-x 12 root root 4096 Aug 15 23:50 graph
drwxr-xr-x  8 root root 4096 Aug 15 23:50 hbs
drwxr-xr-x  8 root root 4096 Aug 15 23:50 judge
drwxr-xr-x  6 root root 4096 Aug 15 23:50 links
drwxr-xr-x 10 root root 4096 Aug 15 23:50 nodata
drwxr-xr-x  6 root root 4096 Aug 15 23:51 portal
drwxr-xr-x  9 root root 4096 Aug 15 23:51 query
-rw-r--r--  1 root root  310 Aug 15 23:46 README.md
drwxr-xr-x  4 root root 4096 Aug 15 23:51 scripts
drwxr-xr-x  9 root root 4096 Aug 15 23:51 sender
drwxr-xr-x  9 root root 4096 Aug 15 23:53 task
drwxr-xr-x  9 root root 4096 Aug 15 23:53 transfer

[root@centos2 github.com]# cd open-falcon/agent/
[root@centos2 agent]# ll

-rw-r--r-- 1 root root     1233 Aug 15 23:47 cfg.example.json
-rwxr-xr-x 1 root root     2291 Aug 15 23:47 control
drwxr-xr-x 2 root root     4096 Aug 15 23:47 cron
-rwxr-xr-x 1 root root 10933496 Aug 16 00:16 falcon-agent
-rw-r--r-- 1 root root  3900610 Aug 16 00:16 falcon-agent-5.1.0.tar.gz
drwxr-xr-x 2 root root     4096 Aug 15 23:47 funcs
drwxr-xr-x 2 root root     4096 Aug 15 23:47 g
-rw-r--r-- 1 root root        8 Aug 16 00:16 gitversion
drwxr-xr-x 2 root root     4096 Aug 15 23:47 http
-rw-r--r-- 1 root root    11358 Aug 15 23:47 LICENSE
-rw-r--r-- 1 root root      780 Aug 15 23:47 main.go
-rw-r--r-- 1 root root      462 Aug 15 23:47 NOTICE
drwxr-xr-x 2 root root     4096 Aug 15 23:47 plugins
drwxr-xr-x 5 root root     4096 Aug 15 23:47 public
-rw-r--r-- 1 root root      659 Aug 15 23:47 README.md
drwxr-xr-x 2 root root     4096 Aug 16 00:16 var
[root@centos2 agent]#  go get ./...
[root@centos2 agent]#  ./control build
[root@centos2 agent]#  ./control pack

最后一步会pack出一个tar.gz的安装包,拿着这个包去部署服务即可。
配置说明

配置文件必须叫cfg.json,可以基于cfg.example.json修改

{
    "debug": true, # 控制一些debug信息的输出,生产环境通常设置为false
    "hostname": "", # agent采集了数据发给transfer,endpoint就设置为了hostname,默认通过`hostname`获取,如果配置中配置了hostname,就用配置中的
    "ip": "", # agent与hbs心跳的时候会把自己的ip地址发给hbs,agent会自动探测本机ip,如果不想让agent自动探测,可以手工修改该配置
    "plugin": {
        "enabled": false, # 默认不开启插件机制
        "dir": "./plugin", # 把放置插件脚本的git repo clone到这个目录
        "git": "https://github.com/open-falcon/plugin.git", # 放置插件脚本的git repo地址
        "logs": "./logs" # 插件执行的log,如果插件执行有问题,可以去这个目录看log
    },
    "heartbeat": {
        "enabled": true, # 此处enabled要设置为true
        "addr": "127.0.0.1:6030", # hbs的地址,端口是hbs的rpc端口
        "interval": 60, # 心跳周期,单位是秒
        "timeout": 1000 # 连接hbs的超时时间,单位是毫秒
    },
    "transfer": {
        "enabled": true, # 此处enabled要设置为true
        "addrs": [
            "127.0.0.1:8433",
            "127.0.0.1:8433"
        ], # transfer的地址,端口是transfer的rpc端口, 可以支持写多个transfer的地址,agent会保证HA
        "interval": 60, # 采集周期,单位是秒,即agent一分钟采集一次数据发给transfer
        "timeout": 1000 # 连接transfer的超时时间,单位是毫秒
    },
    "http": {
        "enabled": true, # 是否要监听http端口
        "listen": ":1988" # 如果监听的话,监听的地址
    },
    "collector": {
        "ifacePrefix": ["eth", "em"] # 默认配置只会采集网卡名称前缀是eth、em的网卡流量,配置为空就会采集所有的,lo的也会采集。可以从/proc/net/dev看到各个网卡的流量信息
    },
    "ignore": { # 默认采集了200多个metric,可以通过ignore设置为不采集
        "cpu.busy": true,
        "mem.swapfree": true
    }
}

进程管理

我们提供了一个control脚本来完成常用操作

./control start 启动进程
./control stop 停止进程
./control restart 重启进程
./control status 查看进程状态
./control tail 用tail -f的方式查看var/app.log

ionice -c 3 nice -n 10 ./control start

参考 :https://book.open-falcon.org/zh/install_from_src/agent.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • open-falcon(v0.2)部署手册 ---注:本文中出现的账号,IP信息均...
    痞子中阅读 4,930评论 4 4
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,997评论 19 139
  • 安装步骤 一、下载并且解压 wget https://github.com/XiaoMi/open-falcon/...
    泥瓦匠软件阅读 5,611评论 0 50
  • 文中只介绍个人搭建成功的经验,不介绍配置部分,全文在 root 账户下执行 原创文章,转载请声明,不,我拒绝转载。...
    孙小白话阅读 2,735评论 0 6
  • Open-falcon是小米运维团队从互联网公司的需求出发,根据多年的运维经验,结合SRE、SA、DEVS的使用经...
    猴子精h阅读 5,195评论 1 5