[关闭]
@llplmlyd 2019-09-30T16:28:05.000000Z 字数 2758 阅读 931

LNMP下天兔监控

Linux


python2.6 pip升级后pip失效报错

  1. Traceback (most recent call last):
  2. File "/usr/bin/pip", line 7, in <module>
  3. from pip._internal import main
  4. File "/usr/lib/python2.6/site-packages/pip/_internal/__init__.py", line 19, in <module>
  5. from pip._vendor.urllib3.exceptions import DependencyWarning
  6. File "/usr/lib/python2.6/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
  7. from .connectionpool import (
  8. File "/usr/lib/python2.6/site-packages/pip/_vendor/urllib3/connectionpool.py", line 92
  9. _blocking_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}
  10. ^
  11. SyntaxError: invalid syntax

解决办法

  1. # 1, 从官方github获取具体版本的pip
  2. # https://github.com/pypa/get-pip
  3. wget https://raw.githubusercontent.com/pypa/get-pip/master/2.6/get-pip.py
  4. # 2,运行刚才获取的pip文件
  5. python2.6 get-pip.py

测试

  1. pip -V
  2. pip

环境

  1. CentOS6
  2. python2.6.6 天兔监控不支持python3

安装依赖环境

  1. # 安装pip
  2. yum install python-pip
  3. # * 安装MySQLdb依赖包 必须
  4. yum -y install mysql-devel
  5. yum install gcc libffi-devel python-devel openssl-devel

安装 lepus 采集器

referring to http://www.dbarun.com/docs/lepus/install/scripts/

  1. cd /usr/local
  2. git clone https://github.com/ruzuojun/lepus.git

对可执行文件授予执行权限,并创建软连接

  1. cd lepus
  2. chmod +x lepus*
  3. ln -s /usr/local/lepus/lepus /usr/local/sbin/lepus
  4. ln -s /usr/local/lepus/lepus_monitor /usr/local/sbin/lepus_mointor

安装所需要的数据库

  1. # 安装 MySQLdb,MySQLdb for python,在pip list里卖弄的名字实际是 MySQL-python
  2. pip install MySQL-python
  3. cd /usr/local/lepus
  4. python test_driver_mysql.py
  5. # 返回MySQL python drivier is ok! 表示 MySQLdb安装成功

安装Web管理台

在监控机创建监控数据库,并授权

  1. cd /usr/local/lepus
  2. mysql
  3. mysql> create database lepus default character set utf8;
  4. mysql> grant select,insert,update,delete,create on lepus.* to 'lepus'@'localhost' identified by 'lepus';
  5. mysql> flush privileges;
  6. mysql> use lepus;
  7. mysql> source sql/lepus_table.sql
  8. mysql> source sql/lepus_data.sql
  9. mysql> exit
  10. vim etc/config.ini

修改监控机数据库连接地址

  1. [monitor_server]
  2. host="127.0.0.1"
  3. port=3306
  4. user=" lepus "
  5. passwd="lepus"
  6. dbname="lepus"

启动lepus

  1. lepus start

配置web天兔监控nginx

  1. cd /usr/local/lepus
  2. cp -rf web/* /usr/local/nginx/html/
  3. cd ../nginx
  4. vim html/application/config/database.php

database.php:

  1. $db['default']['hostname'] = '127.0.0.1';
  2. $db['default']['username'] = 'lepus';
  3. $db['default']['password'] = 'lepus';
  4. $db['default']['database'] = lepus;
  5. # php中安装的数据库驱动/连接器是mysqli,注意这里的dbdriver设置
  6. $db['default']['dbdriver'] = 'mysqli';

修改其中一个nginx的include配置文件 conf.d/mysql.conf

  1. server {
  2. listen 10.32.82.21:81;
  3. #server_name www.mysql.com;
  4. root html;
  5. location / {
  6. # nginx重定向
  7. if (!-e $request_filename)
  8. {
  9. rewrite ^(.*)$ /index.php?s=$1 last;
  10. break;
  11. }
  12. root html;
  13. fastcgi_pass 127.0.0.1:9000;
  14. fastcgi_index index.php;
  15. # fastcgi.conf 位于/usr/local/nginx/fastcgi.conf
  16. index index.php index.htm index.html;
  17. include fastcgi.conf;
  18. }
  19. # css文件启用
  20. location ~ \.css {
  21. add_header Content-Type text/css;
  22. }
  23. # js文件启用
  24. location ~ \.js {
  25. add_header Content-Type application/x-javascript;
  26. }
  27. }

测试监控系统

  1. http://10.32.82.21:81
  2. # 默认管理员账号密码admin/Lepusadmin

监控和告警设置

配置监控

  1. 在被监控的数据库端执行授权
  2. mysql> grant select,process,super on *.* to 'lepus_monitor'@'ip' identified by 'password';
  3. mysql> flush privilegesi
  4. # 授权完成之后在web端进行监控数据库添加方可响应
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注