Techyou labs
真正的爱应该超越生命的长度,心灵的宽度,灵魂的深度
常用标签
September 15, 2011

环境:
随着linux服务器可用性、稳定性逐步增强,企业对线上服务也要求越来越严格,需要有专门的监控系统监控服务的正常运转,并有问题及时发邮件、报警给linux SA。
可能用这个的不是很多,跟nagios无缝兼容。
参数对比可以参考如下:
https://www.icinga.org/nagios/feature-comparison/
一、系统环境:
服务器系统版本:Ubuntu10.04.2 x64 LTS
nginx版本:nginx-0.8.55
Icinga版本:icinga-1.5.0
1.1:系统需求:
Apache/Nginx
    GCC compiler
    C/C++ development libraries
    GD development libraries
    libdbi/libdbi-drivers, database like MySQL or PostgreSQL

1.2:基础环境安装:
Apache,PHP,Perl,Mysql,我这里使用Nginx来代替Apache,Mysql已经编译安装,详细过程在此略过。
apt-get install build-essential libgd2-xpm-dev libjpeg62 libjpeg62-dev libpng12 libpng12-dev libdbi0 libdbi0-dev libdbd-mysql
二:Icinga安装
2.1:用户添加
useradd -c "Icinga Monitor" -s /bin/false -r icinga
passwd icinga

为了方便从web管理台发送执行命令,需再添加一个组:icinga-cmd,并且将webserver和icinga用户添加到该组
groupadd icinga-cmd
usermod -a -G icinga-cmd icinga
usermod -a -G icinga-cmd www-data

2.2:icinga安装
wget --content-disposition http://sourceforge.net/projects/icinga/files/icinga/1.5.0/icinga-1.5.0.tar.gz/download
wget --content-disposition http://sourceforge.net/projects/icinga/files/icinga-web/1.5.0/icinga-web-1.5.0.tar.gz/download
wget --content-disposition http://sourceforge.net/projects/icinga/files/icinga-mobile/0.1.0/icinga-mobile-0.1.0.zip/download
wget --content-disposition http://sourceforge.net/projects/icinga/files/icinga-reporting/1.5.0/icinga-reports-1.5.0.tar.gz/download
wget --content-disposition http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz

./configure --prefix=/usr/local/icinga --enable-idoutils --enable-embedded-perl --enable-ssl --with-icinga-user=icinga --with-icinga-group=icinga --with-command-user=icinga --with-command-group=icinga-cmd --with-web-user=www-data --with-web-group=www-data --with-httpd-conf=/etc/apache2/conf.d
make all
  make install
     - This installs the main program (Icinga Core), CGIs
       (Classical Web), API, and HTML files

  make install-init
     - This installs the init script in /etc/init.d

  make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file

  make install-idoutils
     - This installs the database addon IDOUtils into the
       destination directory

  make install-api
     - This installs the Icinga API in /usr/local/icinga/share

  make install-config
     - This installs *SAMPLE* config files in /usr/local/icinga/etc
       You'll have to modify these sample files before you can
       use Icinga.  Read the HTML documentation for more info
       on doing this.  Pay particular attention to the docs on
       object configuration files, as they determine what/how
       things get monitored!

  make install-webconf
     - This installs the Apache config file for the classical
       Icinga web interface

为了方便,我们直接完全安装
make fullinstall
2.3 Nagios插件安装
./configure --prefix=/usr/local/icinga --enable-shared --enable-static --with-nagios-user=icinga --with-nagios-group=icinga
make && make install

2.3安装fcgi
wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.73.tar.gz
wget http://www.cpan.org/modules/by-module/FCGI/FCGI-ProcManager-0.22.tar.gz

2.4,配置nginx支持Perl
apt-get install autoreconf
apt-get install autotools
apt-get install autotools-dev
apt-get install autoconf
apt-get install libfcgi-dev
apt-get install spawn-fcgi

wget --content-disposition http://github.com/gnosek/fcgiwrap/tarball/master
tar xf gnosek-fcgiwrap-cdd6b8475744989940f9ce8322999e9ed4f0a6ec.tar.gz
cd gnosek-fcgiwrap-cdd6b8475744989940f9ce8322999e9ed4f0a6ec/
aclocal && autoheader && autoconf
./configure --prefix=/usr/local/fcgiwrap
make && make install

#启动fcgidaemon监听脚本
#!/bin/bash
FCGI_SOCKET=/dev/shm/fcgiwrap.sock
FCGI_PROGRAM=/usr/local/fcgiwrap/sbin/fcgiwrap
FCGI_USER=www-data
FCGI_GROUP=icinga-cmd
FCGI_EXTRA_OPTIONS="-M 0700"
ALLOWED_ENV="PATH"
/usr/bin/spawn-fcgi -s $FCGI_SOCKET -u $FCGI_USER -g $FCGI_GROUP -f $FCGI_PROGRAM
#/usr/bin/spawn-fcgi -a 127.0.0.1 -p 8999 -u $FCGI_USER -g $FCGI_GROUP -f $FCGI_PROGRAM

#编写init启动脚本
#!/bin/bash
C_SCRIPT=/usr/local/fcgiwrap/fcgidaemon
RETVAL=0
case "$1" in
start)
echo "Starting fastcgi"
$C_SCRIPT
RETVAL=$?
  ;;
stop)
echo "Stopping fastcgi"
killall -9 fcgiwrap
RETVAL=$?
  ;;
restart)
echo "Restarting fastcgi"
killall -9 fcgiwrap
$C_SCRIPT
RETVAL=$?
  ;;
*)
echo "Usage: c-fastcgi {start|stop|restart}"
exit 1
  ;;
esac
exit $RETVAL

错误处理:
1:/usr/bin/ld: cannot find -lperl
解决:sudo apt-get install libperl-dev
2:所有主机监控状态ok,但状态显示均为pendding
原因:自己手贱注释掉了模版里面默认的检测主机存活状态的check-host-alive命令。。。
解决:怎么改的就怎么改回去..
参考资料:
http://nginx.localdomain.pl/wiki/FcgiWrap
http://wiki.nginx.org/NginxHttpCoreModuleJa
https://gist.github.com/1120459
http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/
http://www.kimberconsulting.com/doku.php/nagiosonnginx
https://github.com/gnosek/fcgiwrap/blob/master/README.rst

暂无评论

添加新评论