1. 程式人生 > >使用open-falcon監控vSphere

使用open-falcon監控vSphere

vsphere-monitor

一、環境準備

# yum -y install redis mariadb-server
# yum install -y python-virtualenv python-devel mariadb-devel openldap-devel
# yum groupinstall "Development tools"
# systemctl start redis
# systemctl status redis
# systemctl start mariadb
# systemctl status mariadb


二、初始化MySQL表結構

# git clone https://github.com/open-falcon/scripts.git 
# cd falcon-plus/scripts/mysql/db_schema/
# mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql
# mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql
# mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql
# mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql
# mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql


三、創建工作目錄並下載解壓文件

# wget https://codeload.github.com/open-falcon/falcon-plus/tar.gz/v0.2.1 -O open-falcon-v0.2.1.tar.gz
# export FALCON_HOME=/etc
# export WORKSPACE=$FALCON_HOME/open-falcon
# mkdir -p $WORKSPACE
# tar -zxvf open-falcon-v0.2.1.tar.gz -C $WORKSPACE


四、啟動open-falcon

# cd /etc/open-falcon
# ./open-falcon start       ##啟動open-falcon 
# ./open-falcon check       ##檢查所有模塊的啟動狀況
        falcon-graph         UP            2920 
          falcon-hbs         UP            2929 
        falcon-judge         UP            2938 
     falcon-transfer         UP            2946 
       falcon-nodata         UP            2951 
   falcon-aggregator         UP            2959 
        falcon-agent         UP            2965 
      falcon-gateway         UP            2972 
          falcon-api         UP            2980 
        falcon-alarm         UP            2986


五、安裝並啟用dashboard

# cd /etc/open-falcon
# git clone https://github.com/open-falcon/dashboard.git
# yum -y install python-pip python-wheel
# pip install --upgrade pip
# pip install -r pip_requirements.txt -i https://pypi.douban.com/simple 
# cd dashboard
# ./control start
# ./control status
falcon-dashboard now is running, pid=3040

註1:dashboard的配置文件為:"rrd/config.py",請根據實際情況修改。
註2:dashbord沒有默認創建任何賬號包括管理賬號,需要自行通過頁面註冊賬號。想擁有管理全局的超級管理員賬號,需手動註冊用戶名為root的賬號。


六、安裝vsphere-monitor

# git clone https://github.com/freedomkk-qfeng/vsphere-monitor.git
# yum install -y python-virtualenv
# cd vsphere-monitor
# virtualenv ./env
# ./env/bin/pip install -r requirement.txt


七、配置並運行vsphere-monitor

# vim config.py
#coding=utf-8 
# falcon
endpoint = "vcenter" # 上報給 open-falcon 的 endpoint
push_api = "http://127.0.0.1:6060/api/push" # 上報的 http api 接口
interval = 60 # 上報的 step 間隔
# vcenter
host = "192.168.100.111" # vcenter 的地址
user = "[email protected]" # vcenter 的用戶名
pwd = "abcdef" # vcenter 的密碼
port = 443 # vcenter 的端口
# esxi
esxi_names = [] # 需要采集的 esxi ,留空則全部采集
# datastore
datastore_names = [] # 需要采集的 datastore ,留空則全部采集 
# vm
vm_enable = True # 是否要采集虛擬機信息
vm_names = []    # 需要采集的虛擬機,留空則全部采集
# env/bin/python /root/vsphere-monitor/vsphere-monitor.py            ##運行vsphere-monitor
# crontab -e                         ##添加定時任務
# crontab -l                         ##列出定時任務
0-59/1 * * * * /root/vsphere-monitor/env/bin/python /root/vsphere-monitor/vsphere-monitor.py


八、監控圖如下

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

註:詳細內容請參詳:https://book.open-falcon.org/zh_0_2/usage/vsphere.html



使用open-falcon監控vSphere