運維監控系統之Open-Falcon

運維監控系統之Open-Falcon


一、Open-Falcon介紹

1、監控系統,可以從運營級別(基本配置即可),以及應用級別(二次開發,通過端口進行日誌上報),對服務器、操作系統、中間件、應用進行全面的監控,及報警,對我們的系統正常運行的作用非常重要。

2、基礎監控

CPU、Load、內存、磁盤、IO、網絡相關、內核參數、ss 統計輸出、端口採集、核心服務的進程存活信息採集、關鍵業務進程資源消耗、NTP offset採集、DNS解析採集,這些指標,都是open-falcon的agent組件直接支持的。

Linux運維基礎採集項:http://book.open-falcon.org/zh/faq/linux-metrics.html

對於這些基礎監控選項全部理解透徹的時刻,也就是對Linux運行原理及命令進階的時刻。

3、第三方監控

術業有專攻,運行在OS上的應用甚多,Open-Falcon的開發團隊不可能把所有的第三方應用的監控全部做完,這個就需要開源社區提供更多的插件,當前對於很多常用的第三方應用都有相關插件了。

4、JVM監控

對於Java作爲主要開發語言的大多數公司,對於JVM的監控不可或缺。

每個JVM應用的參數,比如GC、類加載、JVM內存、進程、線程,都可以上報給Falcon,而這些參數的獲得,都可以通過MxBeans實現。

使用 Java 平臺管理 bean:http://www.ibm.com/developerworks/cn/java/j-mxbeans/

5、業務應用監控

對於業務需要監控的接口,比如響應時間等。可以根據業務的需要,上報相關數據到Falcon,並通過Falcon查看結果。

二、Zabbix、Nagios、Open-Falcon這3大開源運維監控工具的比較

 

三、Open-Falcon編寫的整個腦洞歷程

參考:http://mp.weixin.qq.com/s?__biz=MjM5OTcxMzE0MQ==&mid=400225178&idx=1&sn=c98609a9b66f84549e41cd421b4df74d

小米開源監控系統OpenFalcon應對高併發7種手段:http://h2ex.com/894

官網:

http://open-falcon.org/

https://book.open-falcon.org

https://github.com/open-falcon/falcon-plus/releases

 

說明:Open-Falcon部署分爲前端(客戶端)和後端(服務端)

四、後端部署(服務端)

參考官方文檔:https://book.open-falcon.org/zh_0_2/quick_install/prepare.html

1、系統環境

[root@open-falcon-server ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2、系統優化

#安裝下載軟件
yum install wget -y
 
#更換aliyun源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 
#下載epel源
yum install epel-release.noarch -y
rpm -Uvh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum clean all
yum makecache
 
#下載常用軟件
yum install git telnet net-tools tree nmap sysstat lrzsz dos2unix tcpdump ntpdate -y
 
#配置時間同步
ntpdate cn.pool.ntp.org
 
#更改主機名
hostnamectl set-hostname open-falcon-server
hostname open-falcon-server
 
#開啓緩存
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf
grep keepcache /etc/yum.conf
 
#關閉selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
 
#關閉防火牆
systemctl stop firewalld.service
systemctl disable firewalld.service

3、軟件環境準備

#安裝 redis

1
yum install redis -y

#redis常用命令

redis-server     redis 服務端
 
redis-cli    redis 命令行客戶端
 
redis-benchmark  redis 性能測試工具
 
redis-check-aof   AOF文件修復工具
 
redis-check-dump  RDB文件修復工具
 
redis-sentinel     Sentinel 服務端

#啓動redis

#啓動redis
[root@open-falcon-server ~]# redis-server &
[1] 3308
[root@open-falcon-server ~]# 3308:C 27 Oct 08:37:26.435 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
3308:M 27 Oct 08:37:26.436 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                 
           _.-``__ ''-._                                            
      _.-``    `.  `_.  ''-._           Redis 3.2.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 3308
  `-._    `-._  `-./  _.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |           http://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              
 
3308:M 27 Oct 08:37:26.437 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
3308:M 27 Oct 08:37:26.437 # Server started, Redis version 3.2.10
3308:M 27 Oct 08:37:26.437 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
3308:M 27 Oct 08:37:26.438 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
3308:M 27 Oct 08:37:26.438 * The server is now ready to accept connections on port 6379

#安裝mysql

[root@open-falcon-server ~]#wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 
 
[root@open-falcon-server ~]# ll
total 12
-rw-------. 1 root root 1262 Oct 27  2017 anaconda-ks.cfg
-rw-r--r--. 1 root root 6140 Nov 12  2015 mysql-community-release-el7-5.noarch.rpm
 
[root@open-falcon-server ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]
[root@open-falcon-server ~]# ll /etc/yum.repos.d/
total 48
-rw-r--r--. 1 root root 2573 Nov 21  2014 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 Dec  9  2015 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1309 Dec  9  2015 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Dec  9  2015 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  290 Dec  9  2015 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Dec  9  2015 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Dec  9  2015 CentOS-Sources.repo
-rw-r--r--. 1 root root 1952 Dec  9  2015 CentOS-Vault.repo
-rw-r--r--. 1 root root  951 Jun 24 23:04 epel.repo
-rw-r--r--. 1 root root 1050 Jun 24 23:04 epel-testing.repo
-rw-r--r--. 1 root root 1209 Jan 29  2014 mysql-community.repo
-rw-r--r--. 1 root root 1060 Jan 29  2014 mysql-community-source.repo
 
[root@open-falcon-server ~]#yum install -y mysql-server<br>
#啓動mysql並設置開機自啓動
[root@open-falcon-server ~]# systemctl start mysqld.service
[root@open-falcon-server ~]# systemctl enable mysqld.service
 
[root@open-falcon-server ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.38 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> exit
Bye

#檢查服務

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@open-falcon-server ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      3308/redis-server *
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1443/sshd          
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1634/master        
tcp6       0      0 :::3306                 :::*                    LISTEN      3283/mysqld        
tcp6       0      0 :::6379                 :::*                    LISTEN      3308/redis-server *
tcp6       0      0 :::22                   :::*                    LISTEN      1443/sshd          
tcp6       0      0 ::1:25                  :::*                    LISTEN      1634/master        
udp        0      0 0.0.0.0:68              0.0.0.0:*                           2042/dhclient      
udp        0      0 0.0.0.0:4817            0.0.0.0:*                           2042/dhclient      
udp6       0      0 :::20380                :::*                                2042/dhclient

4、初始化MySQL表結構(備註:導入表結構後,注意檢查)

cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git
cd /tmp/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
rm -rf /tmp/falcon-plus/

#設置數據庫密碼 (備註:用戶名:root ,密碼: password )

[root@open-falcon-server open-falcon]# mysqladmin -uroot password "password"
Warning: Using a password on the command line interface can be insecure.

#檢查導入的數據庫表

[root@open-falcon-server open-falcon]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.6.38 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| alarms             |
| dashboard          |
| falcon_portal      |
| graph              |
| mysql              |
| performance_schema |
| uic                |
+--------------------+
8 rows in set (0.00 sec)
 
mysql> exit
Bye

 

5、配置Go語言開發環境

#安裝go語言開發包(備註:安裝需要epel源)

1
yum install golang -y

#檢查版本

[root@open-falcon-server ~]# go version
 go version go1.8.3 linux/amd64

#查看go的安裝路徑

[root@open-falcon-server ~]# find / -name go
/etc/alternatives/go
/var/lib/alternatives/go
/usr/bin/go
/usr/lib/golang/src/cmd/go  #需要的是這個路徑
/usr/lib/golang/src/go
/usr/lib/golang/bin/go
/usr/lib/golang/pkg/linux_amd64/go

#設置環境變量GOROOT和GOPATH

export GOROOT=/usr/lib/golang
export GOPATH=/home

6、下載編譯好的二進制版本

https://github.com/open-falcon/falcon-plus/releases

直接下載官方編譯好的二進制版本(x86 64位平臺)

#開始安裝open-falcon

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@open-falcon-server ~]# export FALCON_HOME=/home/work
[root@open-falcon-server ~]# export WORKSPACE=$FALCON_HOME/open-falcon
[root@open-falcon-server ~]# mkdir -p $WORKSPACE
 
#上傳軟件
[root@open-falcon-server ~]# ll
-rw-r--r--. 1 root root 40031472 Oct 29 2017 open-falcon-v0.2.1.tar.gz
 
#解壓
[root@open-falcon-server ~]# tar -xf open-falcon-v0.2.1.tar.gz -C $WORKSPACE
[root@open-falcon-server ~]# cd $WORKSPACE
<br>#查看解壓結果
[root@open-falcon-server open-falcon]# ll
total 3896
drwxrwxr-x. 7 501 501      67 Aug 15 19:16 agent
drwxrwxr-x. 5 501 501      40 Aug 15 19:16 aggregator
drwxrwxr-x. 5 501 501      40 Aug 15 19:16 alarm
drwxrwxr-x. 6 501 501      51 Aug 15 19:16 api
drwxrwxr-x. 5 501 501      40 Aug 15 19:16 gateway
drwxrwxr-x. 6 501 501      51 Aug 15 19:16 graph
drwxrwxr-x. 5 501 501      40 Aug 15 19:16 hbs
drwxrwxr-x. 5 501 501      40 Aug 15 19:16 judge
drwxrwxr-x. 5 501 501      40 Aug 15 19:16 nodata
-rwxrwxr-x. 1 501 501 3987469 Aug 15 19:16 open-falcon
lrwxrwxrwx. 1 501 501      16 Aug 15 19:16 plugins -> ./agent/plugins/
lrwxrwxrwx. 1 501 501      15 Aug 15 19:16 public -> ./agent/public/
drwxrwxr-x. 5 501 501      40 Aug 15 19:16 transfer

7、修改配置文件cfg.json

坑:

部分模塊依賴連接數據庫,因爲如果不修改配置文件,aggregator模塊會出現無法啓動,graph、hbs、nodata、api、alarm模塊會出現開啓不報錯但是狀態爲開啓失敗的情況。

如果需要每個模塊都能正常啓動,需要將上面模塊的cfg.json的數據庫信息進行修改。根據本教程的配置,需要修改配置文件所在的目錄: 

模塊配置文件所在路徑
aggregator   /home/work/aggregator/config/cfg.json
graph/home/work/graph/config/cfg.json
hbs/home/work/hbs/config/cfg.json
nodata/home/work/nodata/config/cfg.json
api/home/work/api/config/cfg.json
alarm/home/work/alarm/config/cfg.json

1)修改aggregator的配置文件

vim /home/work/aggregator/config/cfg.json

mysql的root密碼爲空,則去掉“password”,若不爲空,則用root密碼替換“password”。

 

2)修改graph的配置文件

vim /home/work/graph/config/cfg.json

mysql的root密碼爲空,則去掉“password”,若不爲空,則用root密碼替換“password”。

 

3)修改hbs的配置文件

vim /home/work/hbs/config/cfg.json

 

mysql的root密碼爲空,則去掉“password”,若不爲空,則用root密碼替換“password”。

 

4)修改nodata的配置文件

vim /home/work/nodata/config/cfg.json

 

mysql的root密碼爲空,則去掉“password”,若不爲空,則用root密碼替換“password”。

 

5)修改api的配置文件

vim /home/work/api/config/cfg.json

 

mysql的root密碼爲空,則去掉“password”,若不爲空,則用root密碼替換“password”。

 

6)修改alarm的配置文件

vim /home/work/alarm/config/cfg.json

 

mysql的root密碼爲空,則去掉“password”,若不爲空,則用root密碼替換“password”。 

 

8、啓動後端模塊

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[root@open-falcon-server open-falcon]# cd /home/work/open-falcon
 
#啓動服務
[root@open-falcon-server open-falcon]# ./open-falcon start
[falcon-graph] 25682
[falcon-hbs] 25691
[falcon-judge] 25699
[falcon-transfer] 25705
[falcon-nodata] 25711
[falcon-aggregator] 25718
[falcon-agent] 25726
[falcon-gateway] 25733
[falcon-api] 25739
[falcon-alarm] 25751
 
#檢查服務啓動狀態
[root@open-falcon-server open-falcon]# ./open-falcon check
        falcon-graph         UP           25682
          falcon-hbs         UP           25691
        falcon-judge         UP           25699
     falcon-transfer         UP           25705
       falcon-nodata         UP           25711
   falcon-aggregator         UP           25718
        falcon-agent         UP           25726
      falcon-gateway         UP           25733
          falcon-api         UP           25739
        falcon-alarm         UP           25751

#更多的命令行工具用法

# ./open-falcon [start|stop|restart|check|monitor|reload] module
./open-falcon start agent
 
./open-falcon check
        falcon-graph         UP           53007
          falcon-hbs         UP           53014
        falcon-judge         UP           53020
     falcon-transfer         UP           53026
       falcon-nodata         UP           53032
   falcon-aggregator         UP           53038
        falcon-agent         UP           53044
      falcon-gateway         UP           53050
          falcon-api         UP           53056
        falcon-alarm         UP           53063
 
#For debugging , You can check $WorkDir/$moduleName/log/logs/xxx.log

至此後端部署完成。

8、其它用法

#重載配置(備註:修改vi cfg.json配置文件後,可以用下面命令重載配置)

curl 127.0.0.1:1988/config/reload

五、前端部署 (備註:在另外一臺服務器上面操作)

1、創建工作目錄

export HOME=/home/work
export WORKSPACE=$HOME/open-falcon
mkdir -p $WORKSPACE
cd $WORKSPACE

2、克隆前端組件代碼

git clone https://github.com/open-falcon/dashboard.git

3、安裝依賴包

yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools" -y

坑:

#省略下面這三步不操作(備註:因執行virtualenv ./env;安裝的pip版本爲1.4.1,再用pip安裝pip_requirements.txt文件中的軟件。都會出現報錯的情況,導致無法安裝成功。主要原因就是pip版本的問題。)解決這個問題,請參考第4步
#進入目錄
cd $WORKSPACE/dashboard/
virtualenv ./env
source env/bin/activate#如果安裝了高版本pip,請先卸載pip uninstall pip   再按兩次y
#指定源安裝包(備註:這步如果安裝不成功,請檢查pip版本是否爲pip-9.0.1)
pip install -r pip_requirements.txt -i

4、先安裝ez_setup.py,再安裝pip

#下載ez_setup.py
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py --insecure
 
#下載pip
wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
 
#解壓並安裝
tar xf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py install
cd ..

#配置環境變量  (備註:這步不需要操作了)

#查看pip路徑
[root@prometheus dashboard]# which pip
/usr/bin/pip
 
#配置pip環境變量
[root@prometheus dashboard]# vi /etc/profile
#pip path
export PATH="/usr/bin/pip/bin:$PATH"
#使環境變量生效source /etc/profile
#測試是否可用
[root@prometheus dashboard]# pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.

#查看需要安裝的軟件

[root@prometheus dashboard]# cat pip_requirements.txt
Flask==0.10.1
Flask-Babel==0.9
Jinja2==2.7.2
Werkzeug==0.9.4
gunicorn==19.1.1
python-dateutil==2.2
requests==2.3.0
mysql-python
python-ldap

#利用pip安裝上面這些軟件

[root@prometheus]# cd /home/work/open-falcon/dashboard<br><br>#安裝軟件
[root@prometheus dashboard]# pip install -r pip_requirements.txt
Collecting Flask==0.10.1 (from -r pip_requirements.txt (line 1))
Downloading Flask-0.10.1.tar.gz (544kB)
100% |████████████████████████████████| 552kB 955kB/s
Collecting Flask-Babel==0.9 (from -r pip_requirements.txt (line 2))
Downloading Flask-Babel-0.9.tar.gz
Collecting Jinja2==2.7.2 (from -r pip_requirements.txt (line 3))
Downloading Jinja2-2.7.2.tar.gz (378kB)
100% |████████████████████████████████| 378kB 2.0MB/s
Collecting Werkzeug==0.9.4 (from -r pip_requirements.txt (line 4))
Downloading Werkzeug-0.9.4.tar.gz (1.1MB)
100% |████████████████████████████████| 1.1MB 1.1MB/s
Collecting gunicorn==19.1.1 (from -r pip_requirements.txt (line 5))
Downloading gunicorn-19.1.1-py2.py3-none-any.whl (104kB)
100% |████████████████████████████████| 112kB 3.4MB/s
Collecting python-dateutil==2.2 (from -r pip_requirements.txt (line 6))
Downloading python-dateutil-2.2.tar.gz (259kB)
100% |████████████████████████████████| 266kB 1.9MB/s
Collecting requests==2.3.0 (from -r pip_requirements.txt (line 7))
Downloading requests-2.3.0-py2.py3-none-any.whl (452kB)
100% |████████████████████████████████| 460kB 305kB/s
Collecting mysql-python (from -r pip_requirements.txt (line 8))
Downloading MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 2.4MB/s
Collecting python-ldap (from -r pip_requirements.txt (line 9))
Downloading python-ldap-2.4.45.tar.gz (296kB)
100% |████████████████████████████████| 296kB 2.6MB/s
Collecting itsdangerous>=0.21 (from Flask==0.10.1->-r pip_requirements.txt (line 1))
Downloading itsdangerous-0.24.tar.gz (46kB)
100% |████████████████████████████████| 51kB 2.4MB/s
Collecting Babel>=1.0 (from Flask-Babel==0.9->-r pip_requirements.txt (line 2))
Downloading Babel-2.5.1-py2.py3-none-any.whl (6.8MB)
100% |████████████████████████████████| 6.8MB 196kB/s
Collecting speaklater>=1.2 (from Flask-Babel==0.9->-r pip_requirements.txt (line 2))
Downloading speaklater-1.3.tar.gz
Collecting markupsafe (from Jinja2==2.7.2->-r pip_requirements.txt (line 3))
Downloading MarkupSafe-1.0.tar.gz
Collecting six (from python-dateutil==2.2->-r pip_requirements.txt (line 6))
Downloading six-1.11.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in ./env/lib/python2.7/site-packages/setuptools-33.1.1-py2.7.egg (from python-ldap->-r pip_requirements.txt (line 9))
Collecting pytz>=0a (from Babel>=1.0->Flask-Babel==0.9->-r pip_requirements.txt (line 2))
Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
100% |████████████████████████████████| 491kB 1.7MB/s
Installing collected packages: Werkzeug, markupsafe, Jinja2, itsdangerous, Flask, pytz, Babel, speaklater, Flask-Babel, gunicorn, six, python-dateutil, requests, mysql-python, python-ldap
Running setup.py install for Werkzeug ... done
Running setup.py install for markupsafe ... done
Running setup.py install for Jinja2 ... done
Running setup.py install for itsdangerous ... done
Running setup.py install for Flask ... done
Running setup.py install for speaklater ... done
Running setup.py install for Flask-Babel ... done
Running setup.py install for python-dateutil ... done
Running setup.py install for mysql-python ... done
Running setup.py install for python-ldap ... done
Successfully installed Babel-2.5.1 Flask-0.10.1 Flask-Babel-0.9 Jinja2-2.7.2 Werkzeug-0.9.4 gunicorn-19.1.1 itsdangerous-0.24 markupsafe-1.0 mysql-python-1.2.5 python-dateutil-2.2 python-ldap-2.4.45 pytz-2017.2 requests-2.3.0 six-1.11.0 speaklater-1.3

5、修改配置

#配置說明:

dashboard的配置文件爲: 'rrd/config.py',請根據實際情況修改
 
## API_ADDR 表示後端api組件的地址
API_ADDR = "http://127.0.0.1:8080/api/v1"
 
## 根據實際情況,修改PORTAL_DB_*, 默認用戶名爲root,默認密碼爲""
## 根據實際情況,修改ALARM_DB_*, 默認用戶名爲root,默認密碼爲""

#修改方法

[root@Open-Falcon-client]#cd /home/work/open-falcon/dashboard/rrd
 
[root@Open-Falcon-client rrd]# cp config.py config.py.bak
 
(env)[root@Open-Falcon-client rrd]# vi config.py
#-*-coding:utf8-*-
# Copyright 2017 Xiaomi, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
  
# app config
import os
LOG_LEVEL = os.environ.get("LOG_LEVEL",'DEBUG')
SECRET_KEY = os.environ.get("SECRET_KEY","secret-key")
PERMANENT_SESSION_LIFETIME = os.environ.get("PERMANENT_SESSION_LIFETIME",3600 * 24 * 30)
SITE_COOKIE = os.environ.get("SITE_COOKIE","open-falcon-ck")
 
# Falcon+ API
API_ADDR = os.environ.get("API_ADDR","http://192.168.1.180:8080/api/v1")
 
# portal database
# TODO: read from api instead of db
PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","192.168.1.180")
PORTAL_DB_PORT = int(os.environ.get("PORTAL_DB_PORT",3306))
PORTAL_DB_USER = os.environ.get("PORTAL_DB_USER","root")
PORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","password")
PORTAL_DB_NAME = os.environ.get("PORTAL_DB_NAME","falcon_portal")
 
# alarm database
# TODO: read from api instead of db
ALARM_DB_HOST = os.environ.get("ALARM_DB_HOST","192.168.1.180")
ALARM_DB_PORT = int(os.environ.get("ALARM_DB_PORT",3306))
ALARM_DB_USER = os.environ.get("ALARM_DB_USER","root")
ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","password")
ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms")
 
# ldap config
LDAP_ENABLED = os.environ.get("LDAP_ENABLED",False)
LDAP_SERVER = os.environ.get("LDAP_SERVER","ldap.forumsys.com:389")
LDAP_BASE_DN = os.environ.get("LDAP_BASE_DN","dc=example,dc=com")
LDAP_BINDDN_FMT = os.environ.get("LDAP_BINDDN_FMT","uid=%s,dc=example,dc=com")
LDAP_SEARCH_FMT = os.environ.get("LDAP_SEARCH_FMT","uid=%s")
LDAP_ATTRS = ["cn","mail","telephoneNumber"]
LDAP_TLS_START_TLS = False
LDAP_TLS_CACERTDIR = ""
LDAP_TLS_CACERTFILE = "/etc/openldap/certs/ca.crt"
LDAP_TLS_CERTFILE = ""
LDAP_TLS_KEYFILE = ""
LDAP_TLS_REQUIRE_CERT = True
LDAP_TLS_CIPHER_SUITE = ""
 
# i18n
BABEL_DEFAULT_LOCALE = 'zh_CN'
BABEL_DEFAULT_TIMEZONE = 'Asia/Shanghai'
# aviliable translations
LANGUAGES = {
'en': 'English',
'zh_CN': 'Chinese-Simplified',
}
 
# portal site config
MAINTAINERS = ['root']
CONTACT = '[email protected]'
 
try:
from rrd.local_config import *
except:
print "[warning] no local config file"

 #啓動服務

#啓動服務
有兩種方法:
法一:
(env)[root@Open-Falcon-client dashboard]# bash control start
falcon-dashboard started..., pid=40853
 
法二:
(env)[root@Open-Falcon-client dashboard]# ./control start
falcon-dashboard started..., pid=40853
 
#查看日誌
(env)[root@Open-Falcon-client dashboard]# ./control tail
[2017-10-29 15:30:20 +0000] [40853] [INFO] Starting gunicorn 19.1.1
[2017-10-29 15:30:20 +0000] [40853] [INFO] Listening at: http://0.0.0.0:8081 (40853)
[2017-10-29 15:30:20 +0000] [40853] [INFO] Using worker: sync
[2017-10-29 15:30:20 +0000] [40858] [INFO] Booting worker with pid: 40858
[2017-10-29 15:30:20 +0000] [40863] [INFO] Booting worker with pid: 40863
[2017-10-29 15:30:20 +0000] [40864] [INFO] Booting worker with pid: 40864
[2017-10-29 15:30:20 +0000] [40866] [INFO] Booting worker with pid: 40866
 
#退出env環境
(env)[root@Open-Falcon-client dashboard]# deactivate
[root@Open-Falcon-client dashboard]#

#訪問網站

http://192.168.1.181:8081

#關於登錄賬號的問題或參考FAQ

請自行註冊管理員用戶名和密碼

#登錄界面

6、其它用法

#以開發者模式啓動

./env/bin/python wsgi.py
 
open http://127.0.0.1:8081 in your browser.

#開啓8081端口 (備註:如果關閉了防火牆,則直接忽略這步

1)防火牆添加8081端口永久開放

firewall-cmd --add-port=8081/tcp --permanent

2)重新載入防火牆配置

firewall-cmd --reload

#停止dashboard運行

1
bash control stop

#查看dashboard運行狀態

1
bash control status

 

六、FAQ

  • Q: open-falcon v0.2 有管理員帳號嗎?

  • A: 可以通過dashboard自行註冊新用戶,第一個用戶名爲root的帳號會被認爲是超級管理員,超級管理員可以設置其他用戶爲管理員。


  • Q: open-falcon v0.2 dashboard 可以禁止用戶自己註冊嗎?

  • A: 可以的,在api組件的配置文件中,將signup_disable配置項修改爲true,重啓api即可。




作者出自:

https://www.cnblogs.com/nulige/p/7741580.html


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章