Maptail Monitors multiple web access logs at the same time

Source: Internet
Author: User

Originally, maptail was able to deploy on a web server host to view web service access logs in real time. Now there are multiple web servers that need to be monitored, which is a little troublesome. Therefore, one machine is used to monitor multiple web servers at the same time, because the essence of maptail is a demonstration of tail-f, we can combine this, that is, maptail only needs to have access_log, so we only need to synchronize the access logs on other web machines, inotify + rsync is a good choice. rsync is commonly used for "distribution". This time it is used for "aggregation ". The general structure is as follows:

Configuration process:

1. Upgrade Python to 2.6 ~ 2.7

 
  1. #mkdir/root/sourcesoft;cd!$
  2. #wgethttp://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
  3. #yuminstallgcc*
  4. #tar-zxvfPython-2.7.3.tgz
  5. #cdPython-2.7.3
  6. #./configure
  7. #make;makeinstall
  8. #cd/usr/bin
  9. #mvpythonpython.bak
  10. #ln-s/usr/local/bin/pythonpython

Ii. Install nodeJS

 
  1. #cd/root/sourcesoft
  2. #wgethttp://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
  3. #tar-zxvfnode-v0.8.16.tar.gz
  4. #cdnode-v0.8.16
  5. #./configure
  6. #make;makeinstall

If any problem occurs during the above process, you can solve the problem as follows:

1. If the software cannot be installed on yum, the following error occurs:

Note: If you have upgraded Python, the following message may be displayed: TherewasaproblemimportingoneofthePythonmodulesrequiredtorunyum.

 
  1. Solution:
  2. Find the yum file and edit the py file.
  3. # Whichyum
  4. /Usr/bin/yum
  5. # Vi/usr/bin/yum
  6. Set
  7. #! /Usr/bin/python
  8. Changed:
  9. Result of whereispython
  10. #! /Usr/bin/python2.4

2. the following error is prompted when nodejs is installed:

ImportError: Nomodulenamedbz2

 
  1. Solution:
  2. 1.
  3. # Yuminstall-ybzip2 *
  4. 2.
  5. # CdPython-2.7/Modules/zlib
  6. #./Configure; make; makeinstall
  7. 3.
  8. # CdPython-2.7/
  9. # Python2.7setup. pyinstall

3. Install and start the maptail Module

 
  1. #npminstallmaptail-g

Start:

 
  1. #nohup/usr/bin/tail-f/var/log/httpd/access_log|/usr/local/bin/node/usr/local/bin/maptail-h192.168.158.216-p8080&

4. browsing:

Enter http: // 192.168.158.216: 8080 in the browser to access

5. extended use of inotify + rsync for simultaneous monitoring of multiple hosts

1. Install inotify

 
  1. #tarxfinotify-tools-3.14.tar.gz
  2. #cdinotify-tools-3.14
  3. #./configure&&make&&makeinstall

2. Configuration:

192.168.158.219 ==> 192.168.158.216

Configuration on 219:

 
  1. #vim/root/scripts/in_rsync.sh
  2. #!/bin/bash
  3. host1=192.168.158.216
  4. src=/usr/local/apache/logs/web
  5. dst1=weblog219
  6. user1=root
  7. /usr/local/bin/inotifywait-mrq--timefmt'%d/%m/%y%H:%M'--format'%T%w%f%e'-emodify,delete,create,attrib$src\
  8. |whilereadfiles;do
  9. /usr/bin/rsync-zrtopg--delete--password-file=/etc/rsyncd.pass$src$user1@$host1::$dst1>/dev/null2>&1
  10. echo"${files}wasrsynced">>/tmp/rsync.log2>&1>/dev/null
  11. done
  12. #vim/etc/rsyncd.pass
  13. 123456
  14. #chmod600/etc/rsyncd.pass
  15. #nohup/root/scripts/in_rsync.sh&

Configuration on 216:

 
  1. # Vim/etc/rsyncd. conf
  2. Uid = root
  3. Gid = root
  4. Usechroot = no
  5. Maxconnections = 36000
  6. Strictmodes = yes
  7. Logfile =/var/log/rsyncd. log
  8. Pidfile =/var/run/rsyncd. pid
  9. Lockfile =/var/run/rsync. lock
  10. Logformat = % t % a % m % f % B
  11. [Weblog219]
  12. Path =/www/log219/
  13. Authusers = root
  14. Readonly = no
  15. Hostsallow = 192.168.158.0/24
  16. List = no
  17. Uid = root
  18. Gid = root
  19. Secretsfile =/etc/rsyncd. pass
  20. Ignoreerrors = yes
  21. # Vim/etc/rsyncd. pass
  22. Root: 123456
  23. # Chmod600/etc/rsyncd. pass
  24. #/Usr/bin/rsync -- daemon

6. Start and verify the new port

Nohup/usr/bin/tail-f/var/log/httpd/access_log |/usr/local/bin/node/usr/local/bin/maptail-h192.168.158.216-p8219 &

Enter http: // 192.168.158.216: 8080 and http: // 192.168.158.216: 8219 in the browser to view

This article is from the "Ro blog" blog, please be sure to keep this source http://luoweiro.blog.51cto.com/2186161/1169840

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.