Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1758806
  • 博文数量: 150
  • 博客积分: 660
  • 博客等级: 上士
  • 技术积分: 2480
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-08 11:39
文章分类

全部博文(150)

文章存档

2019年(4)

2018年(36)

2017年(53)

2016年(7)

2015年(3)

2014年(3)

2013年(27)

2012年(2)

2011年(1)

2006年(1)

2005年(13)

分类: 系统运维

2018-03-02 10:44:01


open-falcon agent部署

方便阅读

之前的关于openfalcon的学习研究合集




目录规划

[root@redis02 ]# tree -d -L 1 falcon
falcon                      ## 主目录
├── agent                   ## agent
├── mongomon                ## mongodb 监控脚本
└── redismon                ## redis监控脚本
......

agent 目录及文件

[root@redis02 goluk]# tree  -L 1 falcon/agent
falcon/agent
├── bin                 ## agent命令目录
├── cfg.json                ## 配置文件(从config目录拷贝出来
├── config              ## 配置目录
├── control             ## agent服务启动停止脚本 
├── logs                    
├── plugins
└── public

cfg.json说明

修改heartbeat 和 transfer 小节内的ip addr指向 falcon server

 "heartbeat": {
        "enabled": true,
        "addr": "192.168.1.248:6030",
        "interval": 60,
        "timeout": 1000
    },
    "transfer": {
        "enabled": true,
        "addrs": [
            "192.168.1.248:8433"
        ],
        "interval": 60,
        "timeout": 1000
    },

control脚本

来自mail-provider模块,略微修改后作为agent启停脚本

#!/bin/bash

WORKSPACE=$(cd $(dirname $0)/; pwd)
cd $WORKSPACE

#mkdir -p var

module=agent
app=falcon-$module
conf=cfg.json
localconf=cfg.local.json
pidfile=logs/$module.pid
logfile=logs/$module.log

function check_pid() {
    if [ -f $pidfile ];then
        pid=`cat $pidfile`
        if [ -n $pid ]; then
            running=`ps -p $pid|grep -v "PID TTY" |wc -l`
            return $running
        fi
    fi
    return 0
}

function start() {
    check_pid
    running=$?
    if [ $running -gt 0 ];then
        echo -n "$app now is running already, pid="
        cat $pidfile
        return 1
    fi

    c=$conf
    if [ -f $localconf ];then
        c=$localconf
    fi
    nohup ./bin/$app -c $c &> $logfile &
    echo $! > $pidfile
    echo "$app started..., pid=$!"
}

function stop() {
    pid=`cat $pidfile`
    kill $pid
    echo "$app stoped..."
}

function restart() {
    stop
    sleep 1
    start
}

function status() {
    check_pid
    running=$?
    if [ $running -gt 0 ];then
        echo "started"
    else
        echo "stoped"
    fi
}

function tailf() {
    tail -f $logfile
}

function build() {
    go build
    if [ $? -ne 0 ]; then
        exit $?
    fi
    mv $module $app
    ./$app -v
}

function pack() {
    build
    version=`./$app -v`
    tar zcvf $app-$version.tar.gz control cfg.json $app
}

function packbin() {
    build
    version=`./$app -v`
    tar zcvf $app-bin-$version.tar.gz $app
}

function help() {
    echo "$0 pid|reload|build|pack|packbin|start|stop|restart|status|tail"
}

function pid() {
    cat $pidfile
}

function reload() {
    build
    restart
    tailf
}

if [ "$1" == "" ]; then
    help
elif [ "$1" == "stop" ];then
    stop
elif [ "$1" == "start" ];then
    start
elif [ "$1" == "restart" ];then
    restart
elif [ "$1" == "status" ];then
    status
elif [ "$1" == "tail" ];then
    tailf
elif [ "$1" == "build" ];then
    build
elif [ "$1" == "pack" ];then
    pack
elif [ "$1" == "packbin" ];then
    packbin
elif [ "$1" == "pid" ];then
    pid
elif [ "$1" == "reload" ];then
    reload
else
    help
fi 

启停命令

 cd agent

./control start/stop 

阅读(3056) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~