open-falcon ---客戶機agent操作


 

open-falcon的agent用於采集機器負載監控指標,比如cpu.idle、load.1min、disk.io.util等等,每隔60秒push給Transfer。agent與Transfer建立了長連接,數據發送速度比較快,agent提供了一個http接口/v1/push用於接收用戶手工push的一些數據,然后通過長連接迅速轉發給Transfer。agent項目之前是一個獨立項目名字叫falcon-eye ,其自帶有web頁面來自於linux-dash項目。參考:https://book.open-falcon.org/zh/quick_install/graph_components.html

客戶機上只需要配置啟動agent即可:
[root@IDC-Admin-02 ~]# cat /data/work/open-falcon/agent/cfg.json
{
    "debug": true,
    "hostname": "",
    "ip": "",
    "plugin": {
        "enabled": false,                                    #默認不開啟插件機制
        "dir": "./plugin",
        "git": "https://github.com/open-falcon/plugin.git",
        "logs": "./logs"
    },
    "heartbeat": {
        "enabled": true,                                    #此處enabled要設置為true
        "addr": "127.0.0.1:6030",                           #hbs的地址,端口是hbs的rpc端口
        "interval": 60,
        "timeout": 1000
    },
    "transfer": {
        "enabled": true,                                   #此處enabled要設置為true
        "addrs": [
            "192.168.1.30:8433",                           #transfer的地址,這里寫服務端的IP地址,因為transfer部署在服務端,端口是transfer的rpc端口
            "192.168.1.30:8433"
        ],
        "interval": 60,
        "timeout": 1000
    },
    "http": {
        "enabled": true,
        "listen": ":1988",
        "backdoor": false
    },
    "collector": {
        "ifacePrefix": ["bond", "em"]           #默認配置只會采集網卡名稱前綴是bond、em的網卡流量,配置為空就會采集所有的,lo的也會采集。
    },
    "ignore": {                                 #默認采集了200多個metric,可以通過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
    }
}


[root@IDC-Admin-02 ~]# cd /data/work/open-falcon/agent/
[root@IDC-Admin-02 agent]# ./control start
falcon-agent started..., pid=183538
[root@IDC-Admin-02 agent]# ps -ef|grep 183538
root     183538      1  0 00:08 pts/0    00:00:00 ./falcon-agent -c cfg.json
root     183555 183270  0 00:08 pts/0    00:00:00 grep 183538
[root@IDC-Admin-02 agent]# lsof -i:1988
COMMAND      PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
falcon-ag 183538 root    4u  IPv6 9968490      0t0  TCP *:tr-rsrb-p2 (LISTEN)

驗證 
看var目錄下的log是否正常,或者瀏覽器訪問其1988端口。另外agent提供了一個--check參數,可以檢查agent是否可以正常跑在當前機器上。
[root@IDC-Admin-02 agent]# ./falcon-agent --check
cpustat  ... ok
disk.io  ... ok
memory   ... ok
ss -s    ... ok
netstat  ... ok
ss -tln  ... ok
ps aux   ... ok
du -bs   ... ok
kernel   ... ok
df.bytes ... ok
net.if   ... ok
loadavg  ... ok

打開url  http://IP:1988可以查看相關監控信息   (假設這里客戶機ip為192.168.1.22)

由於這台客戶機的hostname為IDC-Admin-02。所以可以在服務端的dashboard界面里搜索Endpoint。(這里是根據客戶機的hostname來匹配搜索的,可以將客戶機的主機名按照一定的規則命名或者做hosts映射,比如web01.wang.com、web02.wang.com、backup.wang.com等*.wang.com,那么這里Endpoint搜索的話,就根據wang.com進行搜索,就會匹配出對應的客戶機)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM