CentOS6.4 lnmp环境安装配置icinga


简介
icinga是nagios的二次开发包,说是原来的团队觉得nagios进展太慢了,然后跳出来开展了这个项目。

ICINGA-CN说明如下:

ICINGA项目是由Michael Luebben、HendrikB?cker和JoergLinge等人发起的,他们都是现有的Nagios项目社区委员会的成员,他们承诺,新的开源项 目将完全兼容以前的Nagios应用程序及扩展功能。在新项目的网站上,他们是如此定义ICINGA的,这将是一个介于Nagios社区版和企业版间的产 品。特别将致力于解决Nagios项目现在的问题,比如不能及时处理Nagios项目的bug、新功能不能及时添加等。还有在新的ICINGA项目中,将 更好的实现数据库集成方面的功能,标准化第三发应用程序的接口等。中文化项目是由Icinga中文化项目组,基于icinga(http://www.icinga.com)基础上,并在此基础上针对中文需求进行优化及修改,同时集成nagiosgraph或pnp4nagios绘图,包括简体中文、繁体中文(计划),界面以及生成的图像都已中文化。
环境

CentOS 6.4 32bit

已安装lnmp环境

1.安装相关软件包:

[root@yunvn ~]# yum -y install gcc gcc-c++ automake autoconf glibc glibc-common gd gd-devel libjpeg libjpeg-devel libpng libpng-devel libdbi libdbi-devel lib-drivers libdbi-dbd-mysql

2.去官网下载最新版的icinga,下载地址:

 http://sourceforge.net/projects/icinga-cn/files/icinga-cn/

添加运行用户icinga

[root@yunvn ~]# useradd icinga
[root@yunvn ~]# passwd icinga
Changing password for user icinga.
New password:
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
3.编译安装icinga

[root@yunvn icinga]# tar xvf icinga-cn-1.9.3.tar.bz2

[root@yunvn icinga]# cd icinga-cn-1.9.3
[root@yunvn icinga-cn-1.9.3]# ls
AUTHORS         docbook           LICENSE               solaris
base            functions         Makefile.in           subst.in
cgi             html              make-tarball          t
Changelog       icinga.logrotate  module                TESTING
Changelog_json  icinga-rpmlintrc  OutputTrap.pm         tests
common          icinga.spec       p1.pl.in              THANKS
config.guess    include           rc.ido2db.in          tools
config.sub      indent-all.sh     README                t-tap
configure       indent.sh         README.RHEL           update-version
configure.in    INSTALLING        README.RHEL.idoutils  update-version-schema
contrib         install-sh        sample-config         UPGRADING
daemon-init.in  LEGAL             selinux               xdata
[root@yunvn icinga-cn-1.9.3]# ./configure --prefix=/home/wwwroot/icinga

 

*** Configuration summary for icinga-core 1.9.3 07-07-2013 ***:

 General Options:
 -------------------------
        Icinga executable:  icinga
        Icinga user/group:  icinga,icinga
       Command user/group:  icinga,icinga
        Apache user/group:  www,www
            Embedded Perl:  no
             Event Broker:  yes
          ido2db lockfile:  ${prefix}/var/ido2db.lock
             ido sockfile:  ${prefix}/var/ido.sock
          idomod tempfile:  ${prefix}/var/idomod.tmp
           Build IDOUtils:  libdbi, instance_name=default
        libdbi driver dir:  /usr/local/lib/dbd
        Install ${prefix}:  /home/wwwroot/icinga
                Lock file:  ${prefix}/var/icinga.lock
                Temp file:  /tmp/icinga.tmp
                 Chk file:  ${prefix}/var/icinga.chk
           HTTP auth file:  ${prefix}/etc/htpasswd.users
            Lib directory:  ${exec_prefix}/lib
            Bin directory:  ${exec_prefix}/bin
         Plugin directory:  ${exec_prefix}/libexec
   Eventhandler directory:  ${exec_prefix}/libexec/eventhandlers
            Log directory:  ${prefix}/var
   Check result directory:  ${prefix}/var/spool/checkresults
           Temp directory:  /tmp
          State directory:  ${prefix}/var
   Ext Cmd file directory:  ${prefix}/var/rw
           Init directory:  /etc/rc.d/init.d
  Apache conf.d directory:  /etc/httpd/conf.d
       Apache config file:  /etc/httpd/conf.d/icinga.conf
             Mail program:  /bin/mail
                  Host OS:  linux-gnu
       Environment Prefix:  ICINGA_

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/icinga/
                  CGI URL:  http://localhost/icinga/cgi-bin/
                 Main URL:  http://localhost/icinga/cgi-bin/tac.cgi


Review the options above for accuracy.  If they look okay,
type ’make all’ to compile the main program and CGIs.


!!! Please take care about the upgrade documentation !!!

没有报错的话执行:

[root@yunvn icinga-cn-1.9.3]# make all

[root@yunvn icinga-cn-1.9.3]# make install

[root@yunvn icinga-cn-1.9.3]# make install-init

[root@yunvn icinga-cn-1.9.3]# make install-config

[root@yunvn icinga-cn-1.9.3]# make install-eventhandlers

[root@yunvn icinga-cn-1.9.3]# make install-commandmode

[root@yunvn icinga-cn-1.9.3]# make install-idoutils

4.配置
如果您的数据库没有位于本机,您需要更改ido2db.cfg:
socket_type=tcp  
启用idomod event broker 模块
[root@yunvn icinga-cn-1.9.3]# cd /home/wwwroot/icinga/etc
[root@yunvn etc]# cp modules/idoutils.cfg-sample modules/idoutils.cfg

数据库创建和IDOUtils

 

[root@yunvn etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 45
Server version: 5.1.60-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ’help;’ or ’h’ for help. Type ’c’ to clear the current input statement.

mysql> CREATE DATABASE icinga;
Query OK, 1 row affected (0.02 sec)

mysql> GRANT USAGE ON icinga.* TO ’icinga’@’localhost’ 
    ->   IDENTIFIED BY ’icinga’ 
    ->   WITH MAX_QUERIES_PER_HOUR 0 
    ->   MAX_CONNECTIONS_PER_HOUR 0 
    ->   MAX_UPDATES_PER_HOUR 0;
Query OK, 0 rows affected (0.18 sec)

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE      ->   ON icinga.* TO ’icinga’@’localhost’
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.05 sec)

mysql> quit
Bye

回到源码目录导入数据文件:

[root@yunvn etc]# cd /home/icinga/icinga-cn-1.9.3

[root@yunvn icinga-cn-1.9.3]# mysql -u root -p icinga < ./module/idoutils/db/mysql/mysql.sql

 登录mysql看一下dbversion

[root@yunvn icinga-cn-1.9.3]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 47
Server version: 5.1.60-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ’help;’ or ’h’ for help. Type ’c’ to clear the current input statement.
mysql> use icinga;
Database changed
mysql> select * from icinga_dbversion;
+--------------+----------+---------+---------------------+---------------------+
| dbversion_id | name     | version | create_time         | modify_time         |
+--------------+----------+---------+---------------------+---------------------+
|            1 | idoutils | 1.9.0   | 2013-12-09 11:05:03 | 2013-12-09 11:05:03 |
+--------------+----------+---------+---------------------+---------------------+
1 row in set (0.01 sec)

mysql>quit

如果这里的版本显示的是1.9.0就不用执行更新,如果不是请执行以下更新:

mysql -u root -p icinga < ./module/idoutils/db/mysql/upgrade/mysql-upgrade-1.9.0.sql 

编辑数据库配置文件,添加数据库连接参数:

[root@yunvn modules]# cd /home/wwwroot/icinga/etc/

[root@yunvn modules]# vim ido2db.cfg
db_servertype=mysql 
 db_port=3306 
 db_user=icinga 
 db_pass=icinga

配置经典的Web界面,安装Icinga附带的经典web界面("CGIs")

[root@yunvn icinga-cn-1.9.3]# make cgis

[root@yunvn icinga-cn-1.9.3]# make install-cgis

[root@yunvn icinga-cn-1.9.3]# make install-html

安装经典web配置文件

[root@yunvn icinga-cn-1.9.3]# make install-webconf

创建 icingaadmin 账户,登录到Icinga经典web界面. 记住您分配给这个帐户的密码 -稍后你会需要它.

[root@yunvn icinga-cn-1.9.3]# htpasswd -c /home/wwwroot/icinga/etc/htpasswd.users icingaadmin
New password:
Re-type new password:
Adding password for user icingaadmin

如果你想改变用户密码,或添加另一个用户,请使用以下命令:

[root@yunvn icinga-cn-1.9.3]# htpasswd /home/wwwroot/icinga/etc/htpasswd.users <username>

 启动icinga和ido2db,并配置开机启动

[root@yunvn icinga-cn-1.9.3]# service ido2db start
Starting ido2db: done.
[root@yunvn icinga-cn-1.9.3]# service icinga start
Running configuration check...OK
Starting icinga: Starting icinga done.
[root@yunvn icinga-cn-1.9.3]# chkconfig ido2db on
[root@yunvn icinga-cn-1.9.3]# chkconfig icinga on

添加nginx配置参数:

 

server
        {
                listen       80;
                server_name icinga.a.com;
                location / {
                root   /home/wwwroot/icinga/share;
                index  index.html;

                # fix image, css and javascript urls
                # FIXME: find smarter way to fix path
                rewrite ^/icinga/images/(.*).(.*) /images/$1.$2 break;
                rewrite ^/icinga/stylesheets/(.*).css /stylesheets/$1.css break;
                rewrite ^/icinga/js/(.*).(.*) /js/$1.$2 break;

               auth_basic              "Restricted";
               auth_basic_user_file    /home/wwwroot/icinga/etc/htpasswd.users;

        }

              location ~ .cgi$ {
              # define root directory for CGIs
              root /home/wwwroot/icinga/sbin;
              rewrite ^/icinga/cgi-bin/(.*).cgi /$1.cgi break;

              include /etc/nginx/fastcgi_params;
              fastcgi_pass  127.0.0.1:49233;
              fastcgi_index index.php;
              fastcgi_param  SCRIPT_FILENAME  /home/wwwroot/icinga/sbin/$fastcgi_script_name;
               
              auth_basic              "Restricted";
              auth_basic_user_file    /home/wwwroot/icinga/etc/htpasswd.users;

              # without passing these parameters you will not be allowed to view/do anything
              fastcgi_param  AUTH_USER          $remote_user;
              fastcgi_param  REMOTE_USER        $remote_user;
    }

 

 

 


Whatever is worth doing is worth doing well.