这两天又开始写些技术的东西了。
重新整理了以前的分类,发现08、09两年只写了可怜的几篇,也远离了Maemo世界。
如果腰椎恢复了,希望能重回Maemo世界,向Evan学习,能参与中文输入就更好了 :)
这两天又开始写些技术的东西了。
重新整理了以前的分类,发现08、09两年只写了可怜的几篇,也远离了Maemo世界。
如果腰椎恢复了,希望能重回Maemo世界,向Evan学习,能参与中文输入就更好了 :)
Cacti和Nagios都是好用的运维监控软件,NPC(Nagios Plugin for Cacti)是一个Cacti插件,安装后可以在Cacti界面里使用Nagios的功能。官方安装文档在这里。
我的安装环境是这样的:
PHP必须安装PDO 和 JSON扩展。由于NPC使用了Ext JS,如果没有JSON扩展,NPC的界面不会出来,只能看到一个空白页面。Ubuntu 6.06下安装PDO可以参考这里。
按照官方文档安装配置好后,遇到了没有显示任何数据的问题,host, hostgroup, service, servicegroup等等都看不到。
检查了NPC的数据库表,有数据,说明NDOUtils已经工作。没有出现在界面上,说明是NPC从数据库读出来到界面显示过程中出现的问题。
用Firebug找出NPC界面为了获取显示数据的Ajax请求(比如/cacti/plugins/npc/npc.php?module=servicegroups&action=getHostStatusPortlet),直接在浏览器里访问,可以看到出了异常:Fatal error: Uncaught exception 'Doctrine_Exception' with message 'Couldn't find class NpcServicegroups' 。显然是Doctrine没有加载到NPC定义的领域类。
经过一番对Doctrine的调试,发现原因在Doctrine类的loadModels方法(Line 516 in Doctrine.php)
$e = explode('.', $file->getFileName());
这里getFileName返回了带绝对路径的文件名,导致autoload函数失败。改成下面这样就解决了。
$e = explode('.', basename($file->getFileName()));
不过还是不明白为什么getFileName返回的是带绝对路径的文件名,是跟我的系统环境有关系吗?有熟悉PHP的朋友能解释一下就好了。
1. 创建相关目录
$ sudo mkdir /etc/nginx
$ sudo mkdir /etc/nginx/conf.d
$ sudo mkdir /etc/nginx/sites-available
$ sudo mkdir /etc/nginx/sites-enabled
$ sudo mkdir /var/log/nginx
$ sudo mkdir -p /var/lib/nginx/body
$ sudo mkdir /var/lib/nginx/proxy
$ sudo mkdir /var/lib/nginx/fastcgi
2. 编译安装
$ ./configure --prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--user=www-data \
--group=www-data \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--with-md5=/usr/lib \
--with-sha1=/usr/lib \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-pcre \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-http_stub_status_module
$ make
$ sudo make install
$ sudo mv /usr/html /var/www/nginx-default
3. 修改配置文件
/etc/nginx/nginx.conf
user www-data;
worker_processes  5;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    server_tokens off;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
access_log /var/log/nginx/access.log;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;
    gzip  on;
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-available/default
server {
    listen       80;
    server_name  localhost;
    location / {
        root   /var/www/nginx-default;
        index  index.html index.htm;
    }
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/nginx-default;
    }
}
启用default vhost
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
4. 创建init脚本
$ sudo vi /etc/init.d/nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
        . /etc/default/nginx
fi
set -e
. /lib/lsb/init-functions
case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
                --exec $DAEMON -- $DAEMON_OPTS || true
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
                --exec $DAEMON || true
        echo "$NAME."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
                /var/run/$NAME.pid --exec $DAEMON || true
        sleep 1
        start-stop-daemon --start --quiet --pidfile \
                /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
        echo "$NAME."
        ;;
  reload)
      echo -n "Reloading $DESC configuration: "
      start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
          --exec $DAEMON || true
      echo "$NAME."
      ;;
  status)
      status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
      ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
        exit 1
        ;;
esac
exit 0
$ sudo chmod +x /etc/init.d/nginx
$ sudo /usr/sbin/update-rc.d -f nginx defaults
5. 启动、停止、重启nginx服务
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart
最近一段时间以来,项目中使用maven-eclipse-plugin的eclipse:eclipse目标时比较恼人。pom里已经加入了aspectj的依赖,但生成的.classpath里却没有相应的classpathentry。
今天google到了解决办法,有两个:
1. 强制使用上个版本的maven-eclipse-plugin
  
  
2. 设置ajdtVersion为none