open falcon 开源监控环境搭建

写在前面的话

每篇一句

苟有恒,何必三更眠五更起,最无益,莫过一日曝十日寒。

监控部署

go 安装

1
2
3
cd /data/
wget https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.9.1.linux-amd64.tar.gz

/root/.bashrc 文件增加go环境变量配置,针对root用户配置环境变量。如果想所有用户使用可追加在/etc/profile。

1
2
3
export GOROOT=/usr/local/go
export GOPATH=/data/mygoworkspace
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

使环境变量立即生效

1
source /root/.bashrc

验证

1
2
[root@openfalon_zzq_host ~]# go version
go version go1.9.1 linux/amd64

查看所有go 环境变量可使用go env

安装redis

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[root@openfalon_zzq_host ~]# yum install -y redis
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00:00
docker-ce-stable | 2.9 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/5): epel/x86_64/group_gz | 266 kB 00:00:00
(2/5): epel/x86_64/updateinfo | 851 kB 00:00:00
(3/5): extras/7/x86_64/primary_db | 130 kB 00:00:00
(4/5): updates/7/x86_64/primary_db | 3.6 MB 00:00:01
(5/5): epel/x86_64/primary_db | 6.1 MB 00:00:03
Determining fastest mirrors
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package redis.x86_64 0:3.2.10-2.el7 will be installed
--> Processing Dependency: libjemalloc.so.1()(64bit) for package: redis-3.2.10-2.el7.x86_64
--> Running transaction check
---> Package jemalloc.x86_64 0:3.6.0-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
redis x86_64 3.2.10-2.el7 epel 545 k
Installing for dependencies:
jemalloc x86_64 3.6.0-1.el7 epel 105 k
Transaction Summary
========================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 650 k
Installed size: 1.7 M
Downloading packages:
(1/2): jemalloc-3.6.0-1.el7.x86_64.rpm | 105 kB 00:00:00
(2/2): redis-3.2.10-2.el7.x86_64.rpm | 545 kB 00:00:00
----------------------------------------------------------------------------------------------------------------------------------------
Total 968 kB/s | 650 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : jemalloc-3.6.0-1.el7.x86_64 1/2
Installing : redis-3.2.10-2.el7.x86_64 2/2
Verifying : redis-3.2.10-2.el7.x86_64 1/2
Verifying : jemalloc-3.6.0-1.el7.x86_64 2/2
Installed:
redis.x86_64 0:3.2.10-2.el7
Dependency Installed:
jemalloc.x86_64 0:3.6.0-1.el7
Complete!
[root@openfalon_zzq_host ~]# systemctl start redis
[root@openfalon_zzq_host ~]# systemctl status redis
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: active (running) since Sat 2017-12-02 19:21:27 CST; 3s ago
Main PID: 5966 (redis-server)
Memory: 4.2M
CGroup: /system.slice/redis.service
└─5966 /usr/bin/redis-server 127.0.0.1:6379
Dec 02 19:21:27 openfalon_zzq_host systemd[1]: Started Redis persistent key-value database.
Dec 02 19:21:27 openfalon_zzq_host systemd[1]: Starting Redis persistent key-value database...

安装mysql

mysql源在国外安装太慢了,建议web页面下载安装包
mysql 下载官网地址

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[root@openfalon_zzq_host ~]# mv mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar mysql
[root@openfalon_zzq_host ~]# cd mysql/
[root@openfalon_zzq_host mysql]# ll
total 579372
-rw-r--r-- 1 root root 593274880 Dec 2 20:06 mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
[root@openfalon_zzq_host mysql]# tar -xvf mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
mysql-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm
mysql-community-embedded-5.7.20-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
mysql-community-libs-5.7.20-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.20-1.el7.x86_64.rpm
mysql-community-devel-5.7.20-1.el7.x86_64.rpm
mysql-community-server-5.7.20-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm
mysql-community-client-5.7.20-1.el7.x86_64.rpm
mysql-community-test-5.7.20-1.el7.x86_64.rpm
mysql-community-common-5.7.20-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.20-1.el7.x86_64.rpm
[root@openfalon_zzq_host mysql]# ls -lrt
total 1158752
-rw-r--r-- 1 7155 31415 25090196 Sep 14 23:44 mysql-community-client-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 278300 Sep 14 23:44 mysql-community-common-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3778120 Sep 14 23:44 mysql-community-devel-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 46238924 Sep 14 23:44 mysql-community-embedded-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 24077232 Sep 14 23:44 mysql-community-embedded-compat-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 128440800 Sep 14 23:44 mysql-community-embedded-devel-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2238604 Sep 14 23:44 mysql-community-libs-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2115892 Sep 14 23:44 mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 55538708 Sep 14 23:44 mysql-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 171597916 Sep 14 23:45 mysql-community-server-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 15256460 Sep 14 23:45 mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 118609776 Sep 14 23:45 mysql-community-test-5.7.20-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 593274880 Dec 2 20:06 mysql-5.7.20-1.el7.x86_64.rpm-bundle.tar
[root@openfalon_zzq_host mysql]# yum -y remove mariadb-libs*
[root@openfalon_zzq_host mysql]# rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.20-1.e################################# [100%]
[root@openfalon_zzq_host mysql]# rpm -ivh mysql-community-libs-
mysql-community-libs-5.7.20-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm
[root@openfalon_zzq_host mysql]# rpm -ivh mysql-community-libs-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.20-1.el7################################# [100%]
[root@openfalon_zzq_host mysql]# rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.20-1.e################################# [100%]
[root@openfalon_zzq_host mysql]# rpm -ivh mysql-community-server-
mysql-community-server-5.7.20-1.el7.x86_64.rpm mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm
[root@openfalon_zzq_host mysql]# rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.20-1.e################################# [100%]
[root@openfalon_zzq_host mysql]# rpm -ivh mysql-community-devel-5.7.20-1.el7.x86_64.rpm
warning: mysql-community-devel-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-devel-5.7.20-1.el################################# [100%]

配置mysql设置默认字符集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@openfalon_zzq_host mysql]# vi /etc/my.cnf
[root@openfalon_zzq_host mysql]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character_set_server= utf8
[client]
default-character-set= utf8
[root@openfalon_zzq_host mysql]# systemctl start mysqld
[root@openfalon_zzq_host mysql]# systemctl enable mysqld
[root@openfalon_zzq_host mysql]# systemctl list-unit-files |grep -i mysqld
mysqld.service enabled

建openfalcon用户,root 初始登陆mysql密码见/var/log/mysqld.log

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
28
29
30
31
32
33
34
35
36
37
38
39
[root@openfalon_zzq_host mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20
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> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_number_count=3;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=3;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER 'openfalcon'@'localhost' IDENTIFIED BY 'Open123';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CREATE USER 'openfalcon'@'localhost' IDENTIFIED BY 'Open123';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to openfalcon@localhost ;
Query OK, 0 rows affected (0.00 sec)

下载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
28
[root@openfalon_zzq_host ~]# mkdir -p $GOPATH/src/github.com/open-falcon
[root@openfalon_zzq_host ~]# cd $GOPATH/src/github.com/open-falcon
[root@openfalon_zzq_host open-falcon]# git clone https://github.com/open-falcon/falcon-plus.git
Cloning into 'falcon-plus'...
remote: Counting objects: 7990, done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 7990 (delta 7), reused 18 (delta 6), pack-reused 7950
Receiving objects: 100% (7990/7990), 15.43 MiB | 103.00 KiB/s, done.
Resolving deltas: 100% (4110/4110), done.
[root@openfalon_zzq_host open-falcon]# cd $GOPATH/src/github.com/open-falcon/falcon-plus/scripts/mysql/db_schema/
[root@openfalon_zzq_host db_schema]# ls -l
total 24
-rw-r--r-- 1 root root 1952 Dec 2 19:30 1_uic-db-schema.sql
-rw-r--r-- 1 root root 7573 Dec 2 19:30 2_portal-db-schema.sql
-rw-r--r-- 1 root root 3391 Dec 2 19:30 3_dashboard-db-schema.sql
-rw-r--r-- 1 root root 1807 Dec 2 19:30 4_graph-db-schema.sql
-rw-r--r-- 1 root root 2560 Dec 2 19:30 5_alarms-db-schema.sql
[root@openfalon_zzq_host mysql]# cd $GOPATH/src/github.com/open-falcon/falcon-plus/scripts/mysql/db_schema/
[root@openfalon_zzq_host db_schema]# mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql
Enter password:
[root@openfalon_zzq_host db_schema]# mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql
Enter password:
[root@openfalon_zzq_host db_schema]# mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql
Enter password:
[root@openfalon_zzq_host db_schema]# mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql
Enter password:
[root@openfalon_zzq_host db_schema]# mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
Enter password:

源码编译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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[root@openfalon_zzq_host db_schema]# cd $GOPATH/src/github.com/open-falcon/falcon-plus/
[root@openfalon_zzq_host falcon-plus]# make all
go build -o bin/agent/falcon-agent ./modules/agent
go build -o bin/aggregator/falcon-aggregator ./modules/aggregator
go build -o bin/graph/falcon-graph ./modules/graph
go build -o bin/hbs/falcon-hbs ./modules/hbs
go build -o bin/judge/falcon-judge ./modules/judge
go build -o bin/nodata/falcon-nodata ./modules/nodata
go build -o bin/transfer/falcon-transfer ./modules/transfer
go build -o bin/gateway/falcon-gateway ./modules/gateway
go build -o bin/api/falcon-api ./modules/api
go build -o bin/alarm/falcon-alarm ./modules/alarm
go build -ldflags "-X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=0.2.1" -o open-falcon
[root@openfalon_zzq_host falcon-plus]# make pack
go build -ldflags "-X main.GitCommit=`git rev-parse --short HEAD` -X main.Version=0.2.1" -o open-falcon
tar -C out -zcf open-falcon-v0.2.1.tar.gz .
[root@openfalon_zzq_host falcon-plus]# ls -l
total 43640
drwxr-xr-x 12 root root 143 Dec 2 19:33 bin
drwxr-xr-x 2 root root 106 Dec 2 19:30 cmd
-rw-r--r-- 1 root root 5479 Dec 2 19:30 CODE_OF_CONDUCT.md
drwxr-xr-x 8 root root 132 Dec 2 19:30 common
drwxr-xr-x 2 root root 211 Dec 2 19:30 config
-rw-r--r-- 1 root root 1587 Dec 2 19:30 CONTRIBUTING.md
drwxr-xr-x 2 root root 92 Dec 2 19:30 docker
drwxr-xr-x 6 root root 205 Dec 2 19:30 docs
drwxr-xr-x 2 root root 53 Dec 2 19:30 g
-rw-r--r-- 1 root root 11358 Dec 2 19:30 LICENSE
-rw-r--r-- 1 root root 30112 Dec 2 19:30 logo.png
drwxr-xr-x 2 root root 112 Dec 2 19:30 logos
-rw-r--r-- 1 root root 1575 Dec 2 19:30 main.go
-rw-r--r-- 1 root root 2239 Dec 2 19:30 Makefile
drwxr-xr-x 12 root root 143 Dec 2 19:30 modules
-rw-r--r-- 1 root root 462 Dec 2 19:30 NOTICE
-rwxr-xr-x 1 root root 4095129 Dec 2 19:33 open-falcon
-rw-r--r-- 1 root root 40503087 Dec 2 19:33 open-falcon-v0.2.1.tar.gz
-rw-r--r-- 1 root root 4615 Dec 2 19:30 README.md
drwxr-xr-x 3 root root 19 Dec 2 19:30 scripts
drwxr-xr-x 2 root root 23 Dec 2 19:30 test
drwxr-xr-x 2 root root 25 Dec 2 19:30 vagrant
drwxr-xr-x 5 root root 77 Dec 2 19:30 vendor
-rw-r--r-- 1 root root 6 Dec 2 19:30 VERSION
-rw-r--r-- 1 root root 684 Dec 2 19:30 version.go

安装open falcon

指定安装目录

1
2
3
[root@openfalon_zzq_host falcon-plus]# export FALCON_HOME=/data
[root@openfalon_zzq_host falcon-plus]# export WORKSPACE=$FALCON_HOME/open-falcon
[root@openfalon_zzq_host falcon-plus]# mkdir -p $WORKSPACE

解压及修改配置文件

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
28
29
30
31
32
33
34
35
36
37
38
39
40
[root@openfalon_zzq_host open-falcon]# tar -xzvf /data/mygoworkspace/src/github.com/open-falcon/falcon-plus/open-falcon-v0.2.1.tar.gz -C $WORKSPACE
[root@openfalon_zzq_host open-falcon]# pwd
/data/open-falcon
[root@openfalon_zzq_host open-falcon]# ls -l
total 4000
drwxr-xr-x 7 root root 72 Dec 2 19:33 agent
drwxr-xr-x 5 root root 43 Dec 2 19:33 aggregator
drwxr-xr-x 5 root root 43 Dec 2 19:33 alarm
drwxr-xr-x 6 root root 55 Dec 2 19:33 api
drwxr-xr-x 5 root root 43 Dec 2 19:33 gateway
drwxr-xr-x 6 root root 55 Dec 2 19:33 graph
drwxr-xr-x 5 root root 43 Dec 2 19:33 hbs
drwxr-xr-x 5 root root 43 Dec 2 19:33 judge
drwxr-xr-x 5 root root 43 Dec 2 19:33 nodata
-rwxr-xr-x 1 root root 4095129 Dec 2 19:33 open-falcon
lrwxrwxrwx 1 root root 16 Dec 2 19:33 plugins -> ./agent/plugins/
lrwxrwxrwx 1 root root 15 Dec 2 19:33 public -> ./agent/public/
drwxr-xr-x 5 root root 43 Dec 2 19:33 transfer
[root@openfalon_zzq_host open-falcon]# grep -Ilr 3306 ./ | xargs -n1 -- sed -i 's/root:/openfalcon:Open123/g'
[root@openfalon_zzq_host open-falcon]# cat aggregator/config/cfg.json
{
"debug": true,
"http": {
"enabled": true,
"listen": "0.0.0.0:6055"
},
"database": {
"addr": "openfalcon:Open123@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true",
"idle": 10,
"ids": [1, -1],
"interval": 55
},
"api": {
"connect_timeout": 500,
"request_timeout": 2000,
"plus_api": "http://127.0.0.1:8080",
"plus_api_token": "default-token-used-in-server-side",
"push_api": "http://127.0.0.1:1988/v1/push"
}
}

启动运行

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
[root@openfalon_zzq_host db_schema]# cd $WORKSPACE
[root@openfalon_zzq_host open-falcon]# ./open-falcon start
[falcon-graph] 9098
[falcon-hbs] 9107
[falcon-judge] 9116
[falcon-transfer] 9122
[falcon-nodata] 9128
[falcon-aggregator] 9135
[falcon-agent] 9143
[falcon-gateway] 9150
[falcon-api] 9156
[falcon-alarm] 9168
[root@openfalon_zzq_host open-falcon]# ./open-falcon check
falcon-graph UP 9098
falcon-hbs UP 9107
falcon-judge UP 9116
falcon-transfer UP 9122
falcon-nodata UP 9128
falcon-aggregator UP 9135
falcon-agent UP 9143
falcon-gateway UP 9150
falcon-api UP 9156
falcon-alarm UP 9168
[root@openfalon_zzq_host open-falcon]# pwd
/data/open-falcon

更多用法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@openfalon_zzq_host open-falcon]# ./open-falcon -h
Usage:
open-falcon [flags]
open-falcon [command]
Available Commands:
check Check the status of Open-Falcon modules
help Help about any command
monitor Display an Open-Falcon module's log
reload Reload an Open-Falcon module's configuration file
restart Restart Open-Falcon modules
start Start Open-Falcon modules
stop Stop Open-Falcon modules
Flags:
-v, --version show version
Use "open-falcon [command] --help" for more information about a command.
[root@openfalon_zzq_host open-falcon]#
For debugging , You can check $WorkDir/$moduleName/log/logs/xxx.log

安装前端

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
28
[root@openfalon_zzq_host open-falcon]# cd $WORKSPACE
[root@openfalon_zzq_host open-falcon]# git clone https://github.com/open-falcon/dashboard.git
Cloning into 'dashboard'...
remote: Counting objects: 1044, done.
remote: Total 1044 (delta 0), reused 0 (delta 0), pack-reused 1044
Receiving objects: 100% (1044/1044), 1.42 MiB | 49.00 KiB/s, done.
Resolving deltas: 100% (565/565), done.
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools"
[root@openfalon_zzq_host dashboard]# virtualenv ./env
New python executable in ./env/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
[root@openfalon_zzq_host dashboard]# mkdir ~/.pip
[root@openfalon_zzq_host dashboard]# vi ~/.pip/pip.conf
[root@openfalon_zzq_host dashboard]# cat ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
[root@openfalon_zzq_host dashboard]# ./env/bin/pip install -r pip_requirements.txt
.........
Successfully installed Flask Flask-Babel Jinja2 Werkzeug gunicorn python-dateutil requests mysql-python python-ldap itsdangerous Babel speaklater markupsafe six pytz
Cleaning up...

修改配置

1
2
3
4
5
6
7
dashboard的配置文件为: 'rrd/config.py',请根据实际情况修改
## API_ADDR 表示后端api组件的地址
API_ADDR = "http://127.0.0.1:8080/api/v1"
## 根据实际情况,修改PORTAL_DB_*, 默认用户名为root,默认密码为"",修改为openfalcon\Open123
## 根据实际情况,修改ALARM_DB_*, 默认用户名为root,默认密码为"",修改为openfalcon\Open123

启动运行

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@openfalon_zzq_host dashboard]# bash control start
falcon-dashboard started..., pid=9953
[root@openfalon_zzq_host dashboard]# tailf var/app.log
[2017-12-02 20:36:42 +0000] [9953] [INFO] Starting gunicorn 19.1.1
[2017-12-02 20:36:42 +0000] [9953] [INFO] Listening at: http://0.0.0.0:8081 (9953)
[2017-12-02 20:36:42 +0000] [9953] [INFO] Using worker: sync
[2017-12-02 20:36:42 +0000] [9958] [INFO] Booting worker with pid: 9958
[2017-12-02 20:36:42 +0000] [9963] [INFO] Booting worker with pid: 9963
[2017-12-02 20:36:42 +0000] [9964] [INFO] Booting worker with pid: 9964
[2017-12-02 20:36:42 +0000] [9965] [INFO] Booting worker with pid: 9965
^C
[root@openfalon_zzq_host dashboard]# netstat -tlunp |grep 8081
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 9953/python

首次登陆注册用户为管理员权限

监控指标

监控折线图

邮件api

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
28
29
30
31
32
33
34
35
36
37
38
39
40
[root@openfalon_zzq_host dashboard]# mkdir -p $GOPATH/src/github.com/niean && cd $GOPATH/src/github.com/niean
[root@openfalon_zzq_host niean]# git clone https://github.com/niean/mailsender.git && cd mailsender
Cloning into 'mailsender'...
remote: Counting objects: 50, done.
remote: Total 50 (delta 0), reused 0 (delta 0), pack-reused 50
Unpacking objects: 100% (50/50), done.
[root@openfalon_zzq_host mailsender]# go get ./...
[root@openfalon_zzq_host mailsender]# ./control build
0.0.1
[root@openfalon_zzq_host mailsender]# cp cfg.example.json cfg.json
[root@openfalon_zzq_host mailsender]# vi cfg.json
[root@openfalon_zzq_host mailsender]# cat cfg.json
{
"debug":true,
"http":{
"enable":true,
"listen":"0.0.0.0:1986"
},
"rpc":{
"enable":false,
"listen":"0.0.0.0:1988"
},
"mail":{
"enable" : true,
"sendConcurrent" : 5,
"maxQueueSize" : 1000,
"fromUser" : "openfalcon_monitor",
"mailServerHost" : "smtp.yeah.net",
"mailServerPort" : 25,
"mailServerAccount" : "zhaoqianzhang@yeah.net",
"mailServerPasswd" : "xxxxxxxxxxxxxxxxxxxxxxx"
}
}
[root@openfalon_zzq_host mailsender]# ./control start
tycs-mailsender start ok, pid=10458
[root@openfalon_zzq_host mailsender]# cat var/app.log
2017/12/02 20:48:35 cfg.go:76: g.ParseConfig ok, file cfg.json
2017/12/02 20:48:35 http.go:37: http.startHttpServer ok, listening 0.0.0.0:1986
[root@openfalon_zzq_host mailsender]# netstat -tlunp |grep 1986
tcp6 0 0 :::1986 :::* LISTEN 10458/./tycs-mailse

发送邮件测试

1
2
[root@openfalon_zzq_host mailsender]# curl -X POST -d "tos=243278982@qq.com;subject=some_subject;content=some_content;user=zzq" "192.168.2.104:1986/mail/sender"
{"msg":"success","data":"ok"}

收到测试邮件
收到邮件

与openfalcon 联动配置邮件告警

1
2
3
4
5
6
7
8
9
[root@openfalon_zzq_host anteye]# cd $WORKSPACE
[root@openfalon_zzq_host open-falcon]# pwd
/data/open-falcon
[root@openfalon_zzq_host open-falcon]# vi alarm/config/cfg.json
[root@openfalon_zzq_host open-falcon]# cat alarm/config/cfg.json |grep mail
"userMailQueue": "/queue/user/mail"
"mail": "http://192.168.2.104:1986/mail/sender",
"mail": 50
[root@openfalon_zzq_host open-falcon]# ./open-falcon restart

配置系统组用于收取邮件

配置告警策略模板

触发告警的列表

收到anteye进程挂了的告警邮件

收到anteye进程恢复的通知邮件

自身监控组件监控

监控原理就是curl 探测对应组件,正常会返返回ok
curl http://192.168.2.104:9912/health

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
[root@openfalon_zzq_host niean]# cd $GOPATH/src/github.com/niean
[root@openfalon_zzq_host niean]# git clone https://github.com/niean/anteye.git
Cloning into 'anteye'...
remote: Counting objects: 76, done.
remote: Total 76 (delta 0), reused 0 (delta 0), pack-reused 76
Unpacking objects: 100% (76/76), done.
[root@openfalon_zzq_host niean]# cd anteye
[root@openfalon_zzq_host anteye]# go get ./...
[root@openfalon_zzq_host anteye]# ./control build
build ok, vsn=0.0.3 636a998
[root@openfalon_zzq_host anteye]# cp cfg.example.json cfg.json
[root@openfalon_zzq_host anteye]# vi cfg.json
[root@openfalon_zzq_host anteye]# cat cfg.json
{
"debug": false,
"http": {
"enable": true,
"listen": "0.0.0.0:8001"
},
"mail" : {
"enable": true,
"url" : "http://192.168.2.104:1986/mail/sender",
"receivers" : "243278982@qq.com,zhangzhaoqian0909@gmail.com"
},
"sms" : {
"enable": false,
"url" : "http://sms.server:1986/sms/sender",
"receivers" : "18001163885,13811685238"
},
"callback" : {
"enable": false,
"url" : "http://tycloudstart.com:1986/anteys/alarm"
},
"monitor" : {
"cluster" : [
"transfer,192.168.2.104:6060/health",
"nodata,192.168.2.104:6090/health",
"alarm,192.168.2.104:9912/health"
]
}
}
[root@openfalon_zzq_host ~]# curl http://192.168.2.104:9912/health
ok
[root@openfalon_zzq_host anteye]# ./control start
tycs-anteye start ok, pid=11060
[root@openfalon_zzq_host anteye]# netstat -tlunp|grep 8001
tcp6 0 0 :::8001 :::* LISTEN 11060/./tycs-anteye
[root@openfalon_zzq_host anteye]# cat var/app.log
2017/12/02 21:02:41 cfg.go:83: g:ParseConfig, ok, cfg.json
2017/12/02 21:02:41 monitor.go:36: monitor.Start ok
2017/12/02 21:02:41 http.go:44: http.startHttpServer ok, listening 0.0.0.0:8001

故意关闭alarm组件

1
2
[root@openfalon_zzq_host open-falcon]# ./open-falcon stop alarm
[falcon-alarm] down

----纸上得来终觉浅绝知此事要躬行----
最好的赞赏是您的阅读!
0%