lepus 監控平臺搭建

lepus 安裝
平臺:centOS6.9
[root@MySQL lepus]# ./xampp-linux-x64-1.8.2-5-installer.run
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.

XAMPP Core Files : Y (Cannot be edited)

XAMPP Developer Files [Y/n] :y

Is the selection above correct? [Y/n]: y

----------------------------------------------------------------------------
Installation Directory

XAMPP will be installed to /opt/lampp
Press [Enter] to continue :

----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.

Do you want to continue? [Y/n]: y

----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.

+++++++++++++++++++++++++++++================================
[root@MySQL ~]# /opt/lampp/lampp start
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/bash: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

id: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/share/xampp/xampplib: line 11: test: -ne: unary operator expected
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/httpd: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: hostname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/sh: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
XAMPP: netstat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/opt/lampp/bin/gettext: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

cat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

修改:vi /opt/lampp/lampp
[root@MySQL lampp]# vi lampp
#!/bin/bash
#
# For RedHat (thanks to Sudhaker Raj):
# chkconfig: 345 95 05
# description: Starts and stops the XAMPP \
#              used to control Apache, MySQL, ProFTPD.
# For SuSE:
### BEGIN INIT INFO
# Provides:                     apache2 httpd2 xampp
# Required-Start:               $local_fs $remote_fs $network
# Required-Stop:                $local_fs $remote_fs $network
# Default-Start:                3 5
# Default-Stop:                 0 1 2 6
# Short-Description:            XAMPP
# Description:                  Starts and stops XAMPP
### END INIT INFO
###############################################################################
# Copyright 2002-2009 by Apache Friends, GPL-licensed
# Authors:
#   - Kai 'Oswald' Seidler, [email protected]
#   - Kristian W. Marcroft, [email protected]
#   - Christian Speich, [email protected]

osguess() {
        if test -f /etc/redhat-release
        then
                if egrep "Red " /etc/redhat-release > /dev/null       ----->RED
                then
                        echo "rh9"
                        return 0
                else

 vi /opt/lampp/etc/extra/httpd-xampp.conf
              #
# New XAMPP security concept
#
<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))">
        #Require local   -------->註解掉
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</LocationMatch>  

========================

[root@lepus data]# /opt/lampp/lampp restart
Restarting XAMPP for Linux 1.8.2-5...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...ok.
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
[root@lepus data]# ll
total 126604
-rw-r--r-- 1 root root   6805861 Sep 20 16:43 lepus-master.zip
-rw-r--r-- 1 root root   6801780 Sep 20 16:43 Lepus.zip
-rw-r--r-- 1 root root     99967 Sep 20 16:43 MySQLdb-python.zip
-rwxr-xr-x 1 root root 115925624 Sep 20 16:42 xampp-linux-x64-1.8.2-5-installer.run
[root@lepus data]# unzip MySQLdb-python.zip
Archive:  MySQLdb-python.zip
c8b2744ea2b1e4419b7e3d93928e92c95f366815
   creating: MySQLdb1-master/
  inflating: MySQLdb1-master/.gitignore 
  inflating: MySQLdb1-master/.travis.yml 
  inflating: MySQLdb1-master/GPL-2.0 
  inflating: MySQLdb1-master/HISTORY 
  inflating: MySQLdb1-master/INSTALL 
  inflating: MySQLdb1-master/MANIFEST.in 
   creating: MySQLdb1-master/MySQLdb/
  inflating: MySQLdb1-master/MySQLdb/__init__.py 
  inflating: MySQLdb1-master/MySQLdb/connections.py 
   creating: MySQLdb1-master/MySQLdb/constants/
  inflating: MySQLdb1-master/MySQLdb/constants/CLIENT.py 
  inflating: MySQLdb1-master/MySQLdb/constants/CR.py 
  inflating: MySQLdb1-master/MySQLdb/constants/ER.py 
  inflating: MySQLdb1-master/MySQLdb/constants/FIELD_TYPE.py 
  inflating: MySQLdb1-master/MySQLdb/constants/FLAG.py 
  inflating: MySQLdb1-master/MySQLdb/constants/REFRESH.py 
  inflating: MySQLdb1-master/MySQLdb/constants/__init__.py 
  inflating: MySQLdb1-master/MySQLdb/converters.py 
  inflating: MySQLdb1-master/MySQLdb/cursors.py 
  inflating: MySQLdb1-master/MySQLdb/release.py 
  inflating: MySQLdb1-master/MySQLdb/times.py 
  inflating: MySQLdb1-master/README.md 
  inflating: MySQLdb1-master/_mysql.c 
  inflating: MySQLdb1-master/_mysql_exceptions.py 
  inflating: MySQLdb1-master/distribute_setup.py 
   creating: MySQLdb1-master/doc/
  inflating: MySQLdb1-master/doc/FAQ.rst 
  inflating: MySQLdb1-master/doc/Makefile 
  inflating: MySQLdb1-master/doc/MySQLdb.constants.rst 
  inflating: MySQLdb1-master/doc/MySQLdb.rst 
  inflating: MySQLdb1-master/doc/_mysql.rst 
  inflating: MySQLdb1-master/doc/_mysql_exceptions.rst 
  inflating: MySQLdb1-master/doc/conf.py 
  inflating: MySQLdb1-master/doc/index.rst 
  inflating: MySQLdb1-master/doc/make.bat 
  inflating: MySQLdb1-master/doc/modules.rst 
  inflating: MySQLdb1-master/doc/user_guide.rst 
  inflating: MySQLdb1-master/metadata.cfg 
  inflating: MySQLdb1-master/pymemcompat.h 
  inflating: MySQLdb1-master/setup.cfg 
  inflating: MySQLdb1-master/setup.py 
  inflating: MySQLdb1-master/setup_common.py 
  inflating: MySQLdb1-master/setup_posix.py 
  inflating: MySQLdb1-master/setup_windows.py 
  inflating: MySQLdb1-master/site.cfg 
   creating: MySQLdb1-master/tests/
  inflating: MySQLdb1-master/tests/capabilities.py 
  inflating: MySQLdb1-master/tests/configdb.py 
  inflating: MySQLdb1-master/tests/dbapi20.py 
  inflating: MySQLdb1-master/tests/default.cnf 
  inflating: MySQLdb1-master/tests/test_MySQLdb_capabilities.py 
  inflating: MySQLdb1-master/tests/test_MySQLdb_dbapi20.py 
  inflating: MySQLdb1-master/tests/test_MySQLdb_nonstandard.py 
  inflating: MySQLdb1-master/tests/travis.cnf 
[root@lepus data]# cd MySQLdb
-bash: cd: MySQLdb: No such file or directory
[root@lepus data]# cd MySQLdb1-master/
[root@lepus MySQLdb1-master]# ll
total 188
-rw-r--r-- 1 root root 16295 Aug 19  2013 distribute_setup.py
drwxr-xr-x 2 root root  4096 Aug 19  2013 doc
-rw-r--r-- 1 root root 18092 Aug 19  2013 GPL-2.0
-rw-r--r-- 1 root root  5687 Aug 19  2013 HISTORY
-rw-r--r-- 1 root root  6636 Aug 19  2013 INSTALL
-rw-r--r-- 1 root root   338 Aug 19  2013 MANIFEST.in
-rw-r--r-- 1 root root  1981 Aug 19  2013 metadata.cfg
-rw-r--r-- 1 root root 80803 Aug 19  2013 _mysql.c
drwxr-xr-x 3 root root  4096 Aug 19  2013 MySQLdb
-rw-r--r-- 1 root root  2352 Aug 19  2013 _mysql_exceptions.py
-rw-r--r-- 1 root root  3203 Aug 19  2013 pymemcompat.h
-rw-r--r-- 1 root root  1266 Aug 19  2013 README.md
-rw-r--r-- 1 root root   563 Aug 19  2013 setup.cfg
-rw-r--r-- 1 root root  1088 Aug 19  2013 setup_common.py
-rw-r--r-- 1 root root  3233 Aug 19  2013 setup_posix.py
-rw-r--r-- 1 root root   648 Aug 19  2013 setup.py
-rw-r--r-- 1 root root  1334 Aug 19  2013 setup_windows.py
-rw-r--r-- 1 root root   665 Aug 19  2013 site.cfg
drwxr-xr-x 2 root root  4096 Aug 19  2013 tests
[root@lepus MySQLdb1-master]# which mysql_config
/usr/bin/mysql_config
[root@lepus MySQLdb1-master]# vi site.cfg
[options]
# embedded: link against the embedded server library
# threadsafe: use the threadsafe client
# static: link against a static library (probably required for embedded)

embedded = False
threadsafe = True
static = False

# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
#mysql_config = /usr/local/bin/mysql_config
mysql_config = /usr/bin/mysql_config
# http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip
# Windows connector libs for MySQL. You need a 32-bit connector for your 32-bit Python build.
connector = C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2
~
~
~
~
~
~
"site.cfg" 17L, 701C written
[root@lepus MySQLdb1-master]# python setup.py  build
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    use_setuptools()
  File "/data/MySQLdb1-master/distribute_setup.py", line 145, in use_setuptools
    return _do_download(version, download_base, to_dir, download_delay)
  File "/data/MySQLdb1-master/distribute_setup.py", line 124, in _do_download
    to_dir, download_delay)
  File "/data/MySQLdb1-master/distribute_setup.py", line 194, in download_setuptools
    src = urlopen(url)
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1190, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
[root@lepus MySQLdb1-master]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.221.245 lepus.test.com lepus
[root@lepus MySQLdb1-master]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=lepus.test.com
[root@lepus MySQLdb1-master]# python --verson
Unknown option: --
Unknown option: -e
Unknown option: -r
Unknown option: -o
Unknown option: -n
Unknown option: --
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
[root@lepus MySQLdb1-master]# python --version
Python 2.6.6
[root@lepus MySQLdb1-master]# python setup.py build
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz           -------->注意看提示,手動將此包安裝,然後再次編譯。
Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    use_setuptools()
  File "/data/MySQLdb1-master/distribute_setup.py", line 145, in use_setuptools
    return _do_download(version, download_base, to_dir, download_delay)
  File "/data/MySQLdb1-master/distribute_setup.py", line 124, in _do_download
    to_dir, download_delay)
  File "/data/MySQLdb1-master/distribute_setup.py", line 194, in download_setuptools
    src = urlopen(url)
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1190, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>

[root@lepus MySQLdb1-master]# python setup.py install
1)下載軟件安裝包

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

2)對可執行文件授權,並創建軟連接

#  cd lepus
#  chmod +x lepus*
# ln -s /usr/local/lepus/lepus /usr/local/sbin/lepus
# ln -s /usr/local/lepus/lepus_monitor /usr/local/sbin/lepus_mointor

3).在監控機創建監控數據庫,並授權。

mysql> create database lepus default character set utf8;
mysql> grant select,insert,update,delete,create on lepus.* to 'lepus_user'@'localhost' identified by '123456';
mysql> flush privileges;

4)導入SQL文件夾裏的初始化SQL文件(表結構和數據文件)

# mysql -uroot –p  lepus < sql/lepus_table.sql
# mysql -uroot –p  lepus < sql/lepus_data.sql

5) 修改配置文件

進入到安裝目錄/usr/local/lepus

# cd /usr/local/lepus/

# vim etc/config.ini

監控機MySQL數據庫連接地址

[monitor_server]
host="127.0.0.1"
port=3306
user=" lepus_user "
passwd="123456"
dbname="lepus"

6) 啓動Lepus (可選)

此時,你可以執行啓動命令啓動lepus採集進程

[root@ebs-cloud lepus]# lepus start
lepus server start success!
[root@ebs-cloud lepus]# ps -ef|grep lepus
root     11553     1  0 14:40 pts/0    00:00:00 /bin/bash /usr/local/sbin/lepus start
root     11555 11553  0 14:40 pts/0    00:00:00 python lepus.py
root     11571 11555  0 14:40 pts/0    00:00:00 python lepus.py
root     11590  1851  0 14:40 pts/0    00:00:00 grep lepus

但是因爲沒有添加主機,所以查看日誌會看到如下提示,屬於正常提示。您也可以在部署完Lepus WEB控制檯後再進行啓動。

[root@ebs-cloud lepus]# tail -f logs/lepus.log

2015-08-03 13:09:09 [WARNING] check mongodb: not found any servers

2015-08-03 13:09:09 [INFO] check mongodb controller finished.

2015-08-03 13:09:12 [INFO] check redis controller started.

2015-08-03 13:09:12 [WARNING] check redis: not found any servers

2015-08-03 13:09:12 [INFO] check redis controller finished.

2015-08-03 13:09:15 [INFO] check os controller started.

2015-08-03 13:09:15 [WARNING] check os: not found any servers

2015-08-03 13:09:15 [INFO] check os controller finished.

2015-08-03 13:09:38 [INFO] alarm controller started.

2015-08-03 13:09:38 [INFO] alarm controller finished.

如果啓動失敗,可以通過記錄的日誌信息查看錯誤,通過log信息我們可以定位啓動失敗的問題:

# tail -f logs/lepus.log
    import functions as func
  File "./include/functions.py", line 285, in <module>
    mail_host = get_option('smtp_host')
  File "./include/functions.py", line 242, in get_option
    conn=MySQLdb.connect(host=host,user=user,passwd=passwd,port=int(port),connect_timeout=5,charset='utf8')
  File "/usr/lib64/python2.6/site-packages/MySQL_python-1.2.4-py2.6-linux-x86_64.egg/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib64/python2.6/site-packages/MySQL_python-1.2.4-py2.6-linux-x86_64.egg/MySQLdb/connections.py", line 193, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
`_mysql_exceptions.OperationalError: (1045, "Access denied for user 'lepus'@'localhost' (using password: YES)")`

到這裏,Lepus採集程序安裝完畢!

複製lepus/web文件夾裏的文件到Apache對應的網站虛擬目錄(備註:根據不同的安裝方式,這個目錄是不一樣的,如果採用xampp安裝的Apache環境,則默認程序目錄爲/opt/lampp/htdocs/), 當然,爲了更好的維護項目,通常我們會爲每個項目配置一個獨立的虛擬主機目錄。具體步驟如下:

修改/opt/lampp/etc/httpd.conf文件,將下面的denied修改爲granted

<Directory />
    AllowOverride none
    Require all granted
</Directory>

取消這一行的註釋

Include etc/extra/httpd-vhosts.conf

修改/opt/lampp/etc/extra/httpd-vhosts.conf 文件,配置虛擬目錄,示例如下:

<VirtualHost *:80>
    ServerAdmin demo.lepus.cc
    DocumentRoot "/usr/local/lepus/web"
    ServerName demo.lepus.cc
    ServerAlias demo.lepus.cc
    ErrorLog "logs/demo.lepus.cc-error_log"
    CustomLog "logs/demo.lepus.cc-access_log" common
</VirtualHost>

修改完成後重啓apache服務

打開application\config\database.php文件,修改PHP連接監控服務器的數據庫信息

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'lepus_user';
$db['default']['password'] = 'xxxxxx';
$db['default']['database'] = lepus;
$db['default']['dbdriver'] = 'mysql';

登錄進行添加主機和監控

通過瀏覽器輸入IP地址或域名打開監控界面,即可登錄系統。.默認管理員賬號密碼admin/Lepusadmin登錄後請修改管理員密碼,增加普通賬號。

啓動和關閉監控系統

執行以下命令啓動系統採集進程

# lepus start

執行以下命令關閉系統採集進程

# lepus stop

執行以下命令監控系統是否正常運行

# lepus status
lepus server is running…

查看啓動關閉幫助命令

# lepus –help
lepus help:
support-site:  www.lepus.cc
====================================================================
start        Start lepus monitor server; Command: #lepus start
stop         Stop lepus monitor server; Command: #lepus stop
status       Check lepus monitor run status; Command: #lepus status


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