maptail的原理是基于node.js, 通过调用WEB服务器访问日志实时打印访问信息. 注:下面node是基于源码编译安装.并依赖python2.6~2.7版本,如果python是2.6以上版本无需再安装. 软件包下载地址: maptail:https://github.com/stagas/maptail/ node:http://nodejs.o
maptail的原理是基于node.js, 通过调用WEB服务器访问日志实时打印访问信息.
注:下面node是基于源码编译安装.并依赖python2.6~2.7版本,如果python是2.6以上版本无需再安装.
软件包下载地址:
maptail:https://github.com/stagas/maptail/
node:http://nodejs.org
<code class="bash">#wget http://nodejs.org/dist/v0.10.0/node-v0.10.0.tar.gz#tar zxvf node-v0.10.0.tar.gz#cd node-v0.10.0#./configure#make && make install</code>
解压出来就可以了,无需编译安装.
<code class="bash">#wget https://github.com/stagas/maptail/archive/master.zip#unzip master.zip#mv maptail-master /usr/local/maptail</code>
运行maptail报以下错误安装以下依赖包:
Error: Cannot find module 'geoip-lite-with-city-data'
Error: Cannot find module 'express'
Error: Cannot find module 'simpl'
<code class="bash">#cd /usr/local/maptail/bin#npm install geoip-lite#npm install express#npm install simpl</code>
修改maptail.js.
<code class="bash">#cd /usr/local/maptail/lib#vi maptail.js</code>
将geoip-lite-with-city-data改为geoip-lite
<code class="bash">#cd /usr/local/maptail/node_modules/geoip-lite/data#wget https://github.com/bluesmoon/node-geoip/blob/master/data/geoip-city-names.dat#wget https://github.com/bluesmoon/node-geoip/blob/master/data/geoip-city.dat</code>
<code class="bash">#cd /usr/local/maptail/bin#nohup tail -fn 20 /htdocs/logs/access.log | ./maptail -h 192.168.1.1 -p 8080 &</code>
访问:http://192.168.1.1:8080
注:/htdocs/logs/access.log为站点访问日志文件.