当前位置: > Linux服务器 > 监控工具 >

更换nagios为Icinga

时间:2014-09-10 10:49来源:linux.it.net.cn 作者:it
更换nagios为Icinga

 花了一上午解决nagios转换icinga
安装基础环境LAMP
yum -y install gcc gcc-c++ cmake autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glibc-common gd gd-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel openssl openssl-devel rrdtool rrdtool-devel perl-rrdtool perl perl-devel
 
yum install -y httpd httpd-devel httpd-manual mod_ssl mod_perl mod_auth_mysql mysql mysql-server mysql-devel libdbi libdbi-devel libdbi-drivers libdbi-dbd-mysql php php-gd php-mysql php-perl php-devel php-mcrypt libmcrypt php-mysql php-xml php-pdo php-pear php-mbstring php-pear php-xmlrpc php-bcmath php-snmp lm_sensors lm_sensors-devel perl-DBD-MySQL net-snmp net-snmp-utils net-snmp-perl net-snmp-devel beecrypt-devel
 
添加服务
chkconfig httpd on
chkconfig mysqld on
 
创建账户信息
 
useradd -m icinga -s /sbin/nologin
 
添加组
 
groupadd icinga
 
usermod -a -G icinga apache
usermod -a -G icinga icinga
 
安装Icinga-pnp4(包括IDOUtils)
 
tar -jxvf icinga-pnp4-cn-1.9.3.tar.bz2
 
cd icinga-pnp4-cn-1.9.3
 
./configure --prefix=/usr/local/icinga --with-icinga-user=icinga --with-icinga-group=icinga --with-command-user=icinga --with-command-group=icinga --enable-idoutils --with-httpd-conf=/etc/httpd/conf.d --enable-nanosleep --enable-event-broker
 
 
 make install编译和安装
 #> make all
安装二进制文件, 初始化脚本, 配置文件样本, 一些事件处理函数, 和设置外部命令目录的权限.
 
make install
make install-init
make install-config
make install-eventhandlers
make install-commandmode
make install-idoutils 
make install-processperfdata  #安装process_perfdata.pl
make install-plugins #安装pnp4相关工具
或使用
make fullinstall
make install-config
 
make cgis
 
make install-cgis
 
make install-html
 
make install-webconf
 
创建 icingaadmin 账户,登录到Icinga经典web界面. 记住您分配给这个帐户的密码 -稍后你会需要它.
htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin
 
service httpd restart
 
创建数据库,用户, 授权:
 
CREATE DATABASE icinga;
 
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;
 
GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost';
  
FLUSH PRIVILEGES;
 
\q
 
向MySQL导入数据库架构:
 
cd /path/to/icinga-src/module/idoutils/db/mysql
mysql -u root -p icinga < mysql.sql
 
 
tar jxvf icinga-plugins-1.4.16.tar.bz2 
cd icinga-plugins-1.4.16  
编译并安装插件安装到目录/usr/local/icinga
./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-icinga-user=icinga --with-icinga-group=icinga 
make 
make install 
 
 
安装check_nrpe 插件
tar -zxvf nrpe-2.14.tar.gz  
cd nrpe-2.14   
./configure --prefix=/usr/local/icinga
make all
make install-plugin
 
启动IDOUtils和Icinga
 
service ido2db start
 
/usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg
 
service icinga start
 
客户端主机的配置
添加用户(普通账户)icinga
 
/usr/sbin/useradd icinga
passwd icinga
客户端编译和安装Icinga插件
tar xvzf icinga-plugins-1.4.16.tar.gz
cd icinga-plugins-1.4.16 
./configure -prefix=/usr/local/icinga --with-icinga-user=icinga --with-icinga-group=icinga 
make
make install
备注
查看播件文件是否已安装在这个目录
 
ls /usr/local/icinga/libexec
 
客户端编译和安装Nrpe
tar xvzf icinga-nrpe-2.14.tar.gz
cd icinga-nrpe-2.14  
./configure --prefix=/usr/local/icinga --with-nrpe-user=icinga --with-nrpe-group=icinga --with-icinga-user=icinga --with-icinga-group=icinga
make all
make install
make install-plugin
make install-daemon
make install-daemon-config
make install-init
配置客户端Nrpe
添加nrpe服务器地址,允许服务器对其读取信息
 
vi /usr/local/icinga/etc/nrpe.cfg
allowed_hosts=127.0.0.1,IPADDRESS
增加command字段来添加要监控的服务
 
 command[check_users]=/usr/local/icinga/libexec/check_users -w 5 -c 10
 command[check_load]=/usr/local/icinga/libexec/check_load -w 15,10,5 -c 30,25,20
 command[check_hda1]=/usr/local/icinga/libexec/check_disk -w 20% -c 10% -p /dev/hda1 
 command[check_zombie_procs]=/usr/local/icinga/libexec/check_procs -w 5 -c 10 -s Z 
 command[check_total_procs]=/usr/local/icinga/libexec/check_procs -w 150 -c 200  
 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 
启动Nrpe
 
service icinga-nrpe start
 
更换nagios为Icinga

(责任编辑:IT)
------分隔线----------------------------