hmonitor install
基础环境
1
2
3
4
5
6
7
8
9
10
11
12[root@alarmcenter ~]# python -V
Python 2.7.13
[root@alarmcenter ~]# pip -V
pip 9.0.1 from /usr/local/python27/lib/python2.7/site-packages (python 2.7)
[root@alarmcenter ~]# mysql -V
mysql Ver 14.14 Distrib 5.6.36, for Linux (x86_64) using EditLine wrapper
注意:数据库要添加动态库:
echo '/mnt/app/mysql/lib' | tee /etc/ld.so.conf.d/mysql.conf
ldconfighmonitor install
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//下载
[root@alarmcenter ~]# cd /mnt/web/
[root@alarmcenter web]# git clone https://github.com/smallasa/hmonitor.git
//安装依赖包
[root@alarmcenter web]# cd hmonitor/
[root@alarmcenter hmonitor]# cat requirements.txt
# python version : 2.7.13
# pip version : 9.0.1
tornado>=4.2
torndb==0.3
requests>=2.7.0
six>=1.9.0
stevedore>=1.5.0
MySQL-python>=1.2.5
[root@alarmcenter hmonitor]# pip install -r requirements.txt
//初始化数据库
[root@alarmcenter hmonitor]# mysql -S /mnt/data/mysql/mysql.sock < db.sql
[root@alarmcenter hmonitor]# mysql -S /mnt/data/mysql/mysql.sock -e "show tables in hmonitor;"
+-----------------------+
| Tables_in_hmonitor |
+-----------------------+
| ALERT_FILTER |
| ALERT_MSG |
| AUTOFIX_BINDING |
| AUTOFIX_LOG |
| HM_TRIGGER |
| TRIGGER_EVENTS |
| USERS |
| USERS_TRIGGER_BINDING |
+-----------------------+
//数据库授权
[root@alarmcenter hmonitor]# mysql -S /mnt/data/mysql/mysql.sock
mysql> grant all privileges on hmonitor.* to 'hmonitor'@'127.0.0.1' identified by 'hmonitor' with grant option;
mysql> flush privileges;
[root@alarmcenter hmonitor]# mysql -uhmonitor -phmonitor -h127.0.0.1
mysql>
// hmonitor 安装
[root@alarmcenter hmonitor]# python setup.py build
[root@alarmcenter hmonitor]# python setup.py installhmonitor 配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15//hmonitor.py
[root@alarmcenter hmonitor]# vim hmonitor.py
#MySQL
define("port", default=8888, help="run on the given port", type=int)
define("mysql_host", default="{127.0.0.1:3306}", help="hmonitor database host")
define("mysql_database", default="{hmonitor}", help="hmonitor database name")
define("mysql_user", default="{hmonitor}", help="hmonitor database user")
define("mysql_password", default="{htmonitor}", help="hmonitor database password")
#Zabbix
define("zabbix_user", default="{Admin}", help="Zabbix user name")
define("zabbix_password", default="{zabbix}", help="Zabbix password")
define("zabbix_url", default="{http://zabbix.domain.cn}", help="Zabbix URL")
#Executor
define("executor_driver", default="ssh", help="remote executor driver")
define("executor_user", default="stack", help="remote executor user")