ICINGA项目是 由Michael Luebben、Hendrik Backer和JoergLinge等人发起的,他们都是现有的Nagios项目社区委员会的成员,他们承诺,新的开源项 目将完全兼容以前的Nagios应用程序及扩展功能。在新项目的网站上,他们是如此定义ICINGA的,这将是一个介于Nagios社区版和企业版间的产 品。特别将致力于解决Nagios项目现在的问题,比如不能及时处理Nagios项目的bug、新功能不能及时添加等。还有在新的ICINGA项目中,将 更好的实现数据库集成方面的功能,标准化第三发应用程序的接口等。
中文项目地址:http://icinga-cn.sourceforge.net/
Icinga的功能是监控服务和主机,但是他自身并不包括这部分功能,所有的监控、检测功能都是通过各种插件来完成的。
启动 Icinga后,它会周期性的自动调用插件去检测服务器状态,同时 Icinga 会维持一个队列,所有插件返回来的状态信息都进入队列,Icinga每次都从队首开始读取信息,并进行处理后,把状态结果通过 web 显示出来。
Icinga 提供了许多插件,利用这些插件可以方便的监控很多服务状态。安装完成后,在Icinga 主目录下的/libexec 里放有 Icinga 自带的可以使用的所有插件,如,check_disk 是检查磁盘空间的插件,check_load是检查CPU负载的,等等。每一个插件可以通过运行./check_xxx -h 来查看其使用方法和功能。Icinga 可以识别 4 种状态返回信息,即 :
Icinga 根据插件返回来的值,来判断监控对象的状态,并通过 web 显示出来,以供管理员及时发现故障。
以下安装步骤都在监控服务器主机172.24.133.18上进行
下载源包
wget <span style="color:#A9A9A9;">http://192.168.153.87:9999/icinga/httpd-2.2.27.tar.gz</span> //使用yum install httpd替代
wget <span style="color:#A9A9A9;">http://192.168.153.87:9999/icinga/mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz</span> //使用yum install mysql mysql-server替代
wget <span style="color:#A9A9A9;">http://192.168.153.87:9999/icinga/php-5.3.27.tar.gz</span> //使用yum install php替代
wget http://192.168.153.87:9999/icinga/icinga-core-1.11.7.tar.gz
wget http://192.168.153.87:9999/icinga/monitoring-plugins-2.0.tar.gz
wget http://192.168.153.87:9999/icinga/nrpe-2.15.tar.gz //此处为配合icinga绑定,不使用yum源安装
wget http://192.168.153.87:9999/icinga/pnp4nagios-0.6.24.tar.gz
tar zxvf httpd-2.2.27.tar.gz
cd httpd-2.2.27l
./configure --prefix=/usr/local/apache2 \
--enable-modules='deflate rewrite exprires ssl proxy' --with-ssl
make -j 4 && make install
yum install httpd
tar zxvf mysql-5.6.20-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.6.20-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
echo 'export PATH=/usr/local/apache2/bin:/usr/local/mysql/bin:$PATH' >> /etc/profile
source /etc/profile
echo /usr/local/mysql/lib >> /etc/ld.so.conf
ldconfig
useradd -M -s /sbin/nologin mysql
rm -f /etc/my.cnf
./scripts/mysql_install_db --user=mysql
/usr/local/mysql/support-files/mysql.server start
mysqladmin -uroot password dbpasswd -S /tmp/mysql.sock
yum install mysql mysql-server
tar zxvf php-5.3.27.tar.gz
cd php-5.3.27
./configure --prefix=/usr/local/php5 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-gd --with-zlib --with-iconv --enable-sockets \
--enable-ftp --enable-xml --enable-zip --enable-mbstring \
--enable-soap --with-xmlrpc --with-libxml-dir --with-curl \
--with-jpeg-dir --with-png-dir --with-mhash --with-freetype-dir \
--with-gettext --disable-debug --disable-dom
make -j 8 && make install
cp php.ini-production /usr/local/php5/lib/php.ini
echo 'addtype application/x-httpd-php .php'>> /usr/local/apache2/conf/httpd.conf
yum install php
yum install libjpeg libjpeg-devel libpng libpng-devel
yum install gd gd-devel
yum install libdbi libdbi-devel libdbi-dbd-mysql -y
tar xvf icinga-core-1.11.7.tar.gz
cd icinga-core-1.11.7
groupadd icinga
useradd -s /sbin/nologin -g icinga icinga
./configure --prefix=/usr/local/icinga \
--with-icinga-user=icinga --with-icinga-group=icinga \
--with-command-user=icinga --with-command-group=icinga \
--enable-idoutils --enable-nanosleep --enable-event-broker \
--with-web-user=daemon -with-web-group=daemon \
--with-httpd-conf=/etc/httpd/conf.d/ \
-with-gd-lib=/usr/lib
make -j 4 all
make fullinstall
make install-config
make cgis
make install-cgis
make install-html
make install-webconf
htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
mysql -uroot -p
mysql> CREATE DATABASE icinga;
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;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost';
mysql>FLUSH PRIVILEGES;
mysql> quit;
mysql -uroot -D icinga < module/idoutils/db/mysql/mysql.sql
cd /usr/local/icinga/etc
cp ido2db.cfg-sample ido2db.cfg
vi /usr/local/icinga/etc/ido2db.cfg
db_servertype=mysql
db_port=3306
db_user=icinga
db_pass=icinga
tar zxvf monitoring-plugins-2.0.tar.gz
cd monitoring-plugins-2.0
./configure --prefix=/usr/local/icinga \
--with-nagios-user=icinga --with-nagios-group=icinga \
--enable-perl-modules
make -j 4 && make install
cd /usr/local/icinga/libexec/ && scp 192.168.153.87:/root/box/icinga/check_ceph/* ./
chown -R icinga:icinga check_ceph_*
若bin/ceph路径不同,需修改check_ceph_*中的"CEPH_COMMAND = "和 "RGW_COMMAND = "
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure --prefix=/usr/local/icinga \
--with-nrpe-user=icinga --with-nrpe-group=icinga \
--with-nagios-user=icinga --with-nagios-group=icinga
make -j 4 all
make install
make install-plugin
make install-daemon
make install-daemon-config
cp init-script /etc/init.d/nrpe
chmod +x /etc/init.d/nrpe
vi /usr/local/icinga/etc/nrpe.cfg
allowed_hosts=127.0.0.1,172.24.133.18
command[check_ssh]=/usr/local/icinga/libexec/check_ssh -H localhost
command[check_swap]=/usr/local/icinga/libexec/check_swap -w 20% -c 10%
command[check_mysql]=/usr/local/icinga/libexec/check_mysql -H localhost -uroot -ptomcat2008
command[check_apache]=/usr/local/icinga/libexec/check_apachestatus -H localhost -p 80
command[check_ntp]=/usr/local/icinga/libexec/check_ntp -H localhost -w 0.5 -c 1
command[check_snmp]=/usr/local/icinga/libexec/check_snmp_service -H localhost -C monitor_energysh
command[check_osd]=/usr/local/icinga/libexec/check_ceph_osd -H 172.24.133.17
command[check_rgw]=/usr/local/icinga/libexec/check_ceph_rgw -i radosgw.node3
command[check_ceph_health]=/usr/local/icinga/libexec/check_ceph_health
command[check_mon]=/usr/local/icinga/libexec/check_ceph_mon -H 172.24.133.17 -I node3
service httpd restart
/etc/init.d/ido2db start
/etc/init.d/icinga start
/etc/init.d/nrpe start
yum install rrdtool*
yum install php-gd
yum install perl-Time-HiRes
tar zxvf pnp4nagios-0.6.24.tar.gz
cd pnp4nagios-0.6.24
./configure --prefix=/usr/local/icinga \
--with-nagios-user=icinga --with-nagios-group=icinga \
--with-httpd-conf=/etc/httpd/conf.d
make -j 4 all
make fullinstall
make install-config
make install-webconf
cp /usr/local/icinga/etc/rra.cfg-sample /usr/local/icinga/etc/rra.cfg
vi /etc/httpd/conf.d/pnp4nagios.conf
Alias /pnp4nagios "/usr/local/icinga/share"
<Directory "/usr/local/icinga/share">
..................
AuthName "icinga Access"
AuthType Basic
AuthUserFile /usr/local/icinga/etc/htpasswd.users
Require valid-user
.......................
</Directory>
vi /usr/local/icinga/etc/icinga.cfg
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
enable_environment_macros=1
vi /usr/local/icinga/etc/objects/commands.cfg //最后两项
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/icinga/libexec/process_perfdata.pl
}
define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/icinga/libexec/process_perfdata.pl -d HOSTPERFDATA
}
vi /usr/local/icinga/etc/objects/templates.cfg //复制追加到尾部
define host{
name host-pnp4
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
register 0
process_perf_data 0
}
define service{
name service-pnp4
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
process_perf_data 0
}
vi /usr/local/icinga/etc/objects/localhost.cfg
//所有linux-server后加”,host-pnp4”和”,service-pnp4”
对应define host/service
define host{
use linux-server,host-pnp4
….....
}
define service{
use local-service, service-pnp4
host_name localhost
….....
}
rm -fv /usr/local/icinga/share/install.php
make install-webconf
make install-init
icinga.cfg
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
host_perfdata_file=/tmp/host-perfdata
service_perfdata_file=/tmp/service-perfdata
host_perfdata_file=/usr/local/icinga/var/host-perfdata
service_perfdata_file=/usr/local/icinga/var/service-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTAT
ETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
host_perfdata_file_mode=a
service_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
service_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
service_perfdata_file_processing_command=process-service-perfdata-file
event_broker_options=-1
新增
broker_module=/usr/local/icinga/lib/npcdmod.o config_file=/usr/local/icinga/etc/npcd.cfg
command.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
define command{
command_name process-service-perfdata-file
command_line /bin/mv /usr/local/icinga/var/service-perfdata /usr/local/icinga/var/spool/service-perfdata.$TIMET$
}
define command{
command_name process-host-perfdata-file
command_line /bin/mv /usr/local/icinga/var/host-perfdata /usr/local/icinga/var/spool/host-perfdata.$TIMET$
}
templates.cfg
define host{
name host-pnp4
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
register 0
}
define service{
name service-pnp4
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
> service npcd start
> service icinga restart
> service httpd restart
[[File:|File:]]
假设:安装被监控端服务器:172.24.133.17
创建icinga用户和组,使用icinga启动nrpe
allowed_hosts=127.0.0.1,172.24.133.18
command[check_ssh]=/usr/local/icinga/libexec/check_ssh -H localhost
command[check_swap]=/usr/local/icinga/libexec/check_swap -w 20% -c 10%
command[check_mysql]=/usr/local/icinga/libexec/check_mysql -H localhost -uroot -ptomcat2008
command[check_apache]=/usr/local/icinga/libexec/check_apachestatus -H localhost -p 80
command[check_ntp]=/usr/local/icinga/libexec/check_ntp -H localhost -w 0.5 -c 1
command[check_snmp]=/usr/local/icinga/libexec/check_snmp_service -H localhost -C monitor_energysh
[root@nd0302014911 ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/nds/lib
define host{
use linux-server,host-pnp4
host_name 172.24.133.17
alias 172.24.133.17
address 172.24.133.17
}
define service{
use linux-service,service-pnp4
host_name 172.24.133.17
service_description Current Users
check_command check_nrpe!check_ssh
}
...............................
/etc/init.d/icinga reload
check_traffic.sh
check_load -w $ARG1$ -c $ARG2$
check_load -r -w 2.0,3.0,4.0 -c 5.0,6.0,7.0
check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
check_swap -w $ARG1$ -c $ARG2$
check_swap -w 80 -c 70
check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$
check_http -I $HOSTADDRESS$ $ARG1$
check_ssh $ARG1$ $HOSTADDRESS$
check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$
command[check_osd]=/usr/local/icinga/libexec/check_ceph_osd -H 172.24.133.18
command[check_rgw]=/usr/local/icinga/libexec/check_ceph_rgw -i radosgw.node3
command[check_ceph_health]=/usr/local/icinga/libexec/check_ceph_health
command[check_mon]=/usr/local/icinga/libexec/check_ceph_mon -H 172.24.133.18 -I node3
[http://172.24.133.18:81/] 组内集群监控