Open-Falcon監控系統安裝和使用

0. 運維監控工具選擇

1. 安裝腳本(主服務)

常規安裝環境搭建太複雜, dashboard安裝碰到python依賴不容易解決, 直接使用docker安裝, 這裏總結除了一個安裝 shell script, 以下:php

#!/bin/sh

## env params
MYSQL_HOST=my.falcon.local
MYSQL_PASSWORD=falcon
MYSQL_USER=falcon

## init mysql table before the first running
# cd /tmp && \
# git clone --depth=1 https://github.com/open-falcon/falcon-plus && \
# cd /tmp/falcon-plus/ && \
# for x in `ls ./scripts/mysql/db_schema/*.sql`; do
#     echo init mysql table $x ...;
#     docker exec -i falcon-mysql mysql -h $MYSQL_HOST -u $MYSQL_USER -p $MYSQL_PASSWORD < $x;
# done

## falcon redis
docker run --name falcon-redis --restart always -p 6380:6379 -d redis:4-alpine3.8

## falcon plus
mkdir -p /seniverse/data/falcon
mkdir -p /seniverse/log/falcon

docker run -itd --name falcon-plus \
  --restart always \
  --link=falcon-redis:redis.falcon \
  -p 8433:8433 \
  -p 8080:8080 \
  -p 6060:6060 \
  -p 6030:6030 \
  -e MYSQL_PORT=$MYSQL_USER:$MYSQL_PASSWORD@tcp\($MYSQL_HOST:3306\) \
  -e REDIS_PORT=redis.falcon:6379  \
  -v /seniverse/data/falcon:/open-falcon/data \
  -v /seniverse/log/falcon:/open-falcon/logs \
  openfalcon/falcon-plus:v0.2.1

docker exec falcon-plus sh ctrl.sh start \
  graph hbs judge transfer nodata aggregator agent gateway api alarm

ls -l /seniverse/log/falcon

## falcon dashboard
docker run -itd --name falcon-dashboard \
  -p 8081:8081 \
  --restart always \
  --link=falcon-plus:api.falcon \
  -e API_ADDR=http://api.falcon:8080/api/v1 \
  -e PORTAL_DB_HOST=$MYSQL_HOST \
  -e PORTAL_DB_PORT=3306 \
  -e PORTAL_DB_USER=$MYSQL_USER \
  -e PORTAL_DB_PASS=$MYSQL_PASSWORD \
  -e PORTAL_DB_NAME=falcon_portal \
  -e ALARM_DB_HOST=$MYSQL_HOST \
  -e ALARM_DB_PORT=3306 \
  -e ALARM_DB_USER=$MYSQL_USER \
  -e ALARM_DB_PASS=$MYSQL_PASSWORD \
  -e ALARM_DB_NAME=alarms \
  -w /open-falcon/dashboard openfalcon/falcon-dashboard:v0.2.1  \
  './control startfg'

2. 其餘機器(代理服務)

2.1 下載二進制文件

export FALCON_HOME=/home/wj
export WORKSPACE=$FALCON_HOME/falcon
mkdir -p $WORKSPACE
wget https://github.com/open-falcon/falcon-plus/releases/download/v0.2.1/open-falcon-v0.2.1.tar.gz
tar -xzvf open-falcon-v0.2.1.tar.gz -C $WORKSPACE

2.2 修改host

增長一個指向主服務的別名html

vim /etc/hosts

# falcon server
10.0.1.34       host.server.local

2.3 修改 agent 配置

  • heartbeat.addr
  • transfer.addrs
  • hostname[可選]
  • ip[可選]
cd $WORKSPACE
vim transfer/config/cfg.json

{
    "debug": true,
    "hostname": "my.servermaster.local",
    "ip": "192.168.132.152",
    "plugin": {
        "enabled": false,
        "dir": "./plugin",
        "git": "https://github.com/open-falcon/plugin.git",
        "logs": "./logs"
    },
    "heartbeat": {
        "enabled": true,
        "addr": "host.server.local:6030",
        "interval": 60,
        "timeout": 1000
    },
    "transfer": {
        "enabled": true,
        "addrs": [
            "host.server.local:8433"
        ],
        "interval": 60,
        "timeout": 1000
    },
    "http": {
        "enabled": true,
        "listen": ":1988",
        "backdoor": false
    },
    "collector": {
        "ifacePrefix": ["eth", "em"],
        "mountPoint": []
    },
    "default_tags": {
    },
    "ignore": {
        "cpu.busy": true,
        "df.bytes.free": true,
        "df.bytes.total": true,
        "df.bytes.used": true,
        "df.bytes.used.percent": true,
        "df.inodes.total": true,
        "df.inodes.free": true,
        "df.inodes.used": true,
        "df.inodes.used.percent": true,
        "mem.memtotal": true,
        "mem.memused": true,
        "mem.memused.percent": true,
        "mem.memfree": true,
        "mem.swaptotal": true,
        "mem.swapused": true,
        "mem.swapfree": true
    }
}

2.4 啓動 agent

cd $WORKSPACE
./open-falcon restart agent

./open-falcon monitor agent

經過 monitor 能夠看到 agent和主服務通訊.node

3. 檢查&體驗

默認falcon沒有建立用戶, 須要本身建立, 第一個用戶視爲root用戶.python

4. 實戰

配置一個監控redis的監控, 首先準備腳本redis-monitor.py, 內容略,點解連接可在github上查看到.mysql

mkdir -p /home/wj/falcon-plugins
### 新建腳本複製github上腳本內容
touch /home/wj/falcon-plugins/redis-monitor.py
### 編輯crontab, 並建立一個定時任務, 上報redis信息
sudo crontab -e

### debug
* * * * * python /home/wj/falcon-plugins/redis-monitor.py >> /home/wj/falcon-plugins/redis-monitor.log

定時任務運行結果能夠經過redis-monitor.log查看, 最後看看監控的redis.connected_clients的效果(生成環境監控了一一天): git

5. 遇到問題

  • 採集agent服務信息收集不上:github

    主服務端口可能沒有開通, 能夠經過monitor命令查看詳情.redis

  • 手欠/重裝/其餘緣由刪除endpoint從新收集endpoint信息sql

    在住服務節點, 更新索引執行: curl -s http://127.0.0.1:6071/index/updateAlldocker

6. 參考資料

相關文章
相關標籤/搜索