搭建ICINGA监控

搭建ICINGA监控  

2012-09-27 15:54:20|  分类:rhel_监控|  标签:|字号 订阅

一、环境:

OS: CentOS 6.2 Minimal

IP: 172.16.51.9

HOSTNAME: icinga.hqew.com

二、搭建

源码包存放位置:/usr/local/src

1、安装基本软件包

 

  1. # yum install -y make automake gcc-c++ httpd gcc glibc glibc-common gd gd-devel libjpeg libjpeg-devel libpng libpng-devel mysql mysql-server libdbi libdbi-devel libdbi-drivers libdbi-dbd-mysql

 

关闭防火墙,禁用selinux

 

  1. # chkconfig iptables off >> service iptables stop
  2. # sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

 

2、下载icinga源码包及nagios插件

  1. # cd /usr/local/src
  2. # wget -c http://cdnetworks-kr-1.dl.sourceforge.net/project/icinga-cn/icinga-cn/icinga-cn-1.7.0/icinga-cn-1.7.0.tar.xz
  3. # wget -c http://cdnetworks-kr-1.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz

3、创建icinga用户

 

  1. # useradd – m icinga
  2. # passwd icinga
  3. # groupadd icinga-cmd
  4. # usermod -a -G icinga-cmd icinga
  5. # usermod -a -G icinga-cmd apache

 

4、编译安装icinga

 

  1. # yum install -y xz
  2. # xz -d icinga-cn-1.7.0.tar.xz
  3. # tar xf icinga-cn-1.7.0.tar
  4. # cd icinga-cn-1.7.0
  5. # ./configure –with-command-group=icinga-cmd –enable-idoutils
  6. # make all
  7. # make install
  8. # make install-init
  9. # make install-config
  10. # make install-eventhandlers
  11. # make install-commandmode

 

或者更简便:

 

  1. # make fullinstall
  2. # make install-config

 

5、编辑警报联系人

  1. # vi /usr/local/icinga/etc/objects/contacts.cfg

6、启用idomod event broker module

 

  1. # cd /usr/local/icinga/etc/module
  2. # cp idoutils.cfg-sample idoutils.cfg
  3. # chown icinga.icinga idoutils.cfg

 

7、创建数据库

 

  1. # service mysqld start
  2. # mysql

 

 

  1. mysql> drop database test;
  2. Query OK, 0 rows affected (0.00 sec)
  3.  
  4. mysql> use mysql
  5. Reading table information for completion of table and column names
  6. You can turn off this feature to get a quicker startup with -A
  7.  
  8. Database changed
  9. mysql> delete from user where user='';
  10. Query OK, 2 rows affected (0.00 sec)
  11.  
  12. mysql> update user set password=password('123456') where user='root';
  13. Query OK, 3 rows affected (0.00 sec)
  14. Rows matched: 3 Changed: 3 Warnings: 0
  15.  
  16. mysql> flush privileges;
  17. Query OK, 0 rows affected (0.00 sec)
  18.  
  19. mysql> create database icinga;
  20. Query OK, 1 row affected (0.00 sec)
  21.  
  22. mysql> grant usage on *.* to icinga@localhost identified by 'icinga' with MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;
  23. Query OK, 0 rows affected (0.00 sec)
  24.  
  25. mysql> grant select,insert,update,delete,drop,create view on icinga.* to icinga@localhost;
  26. Query OK, 0 rows affected (0.00 sec)
  27.  
  28. mysql> flush privileges;
  29. Query OK, 0 rows affected (0.00 sec)
  30.  
  31. mysql> \q

 

 

8、导入数据库

  1. # mysql -p icinga < /usr/local/src/icinga-cn-1.7.0/module/idoutils/db/mysql.sql
  2. Enter password:
  3. ERROR 1273 (HY000) at line 627: Unknown collation: 'utf8_general_cs'

解决:

编辑mysql.sql,删除utf8_geneal_cs,共有四个,然后重新导入。

9、配置ido2db.cfg

  1. # vi /usr/local/etc/icinga/etc/ido2db.cfg

确保如下内容:

 

  1. db_servertype=mysql
  2. db_port=3306
  3. db_user=icinga
  4. db_pass=icinga

 

10、配置Classic Web界面

  1. # cd /usr/local/src/icinga-cn-1.7.0
  2. # make cgis
  3. # make install-cgis
  4. # make install-html
  5. # make install-webconf

11、启动httpd服务

  1. # chkconfig httpd on >> service httpd start

12、编译安装Nagios插件

  1. # cd /usr/local/src
  2. # tar xf nagios-plugins-1.4.15.tar.gz
  3. # cd nagios-plugins-1.4.15
  4. # ./configure –prefix=/usr/local/icinga/ –with-cgiurl=/icinga/cgi-bin –with-htmurl=/icinga -with-nagios-user=icinga –with-nagios-group=icinga
  5. # make >> make install

13、启动idoutilsicinga

 

  1. # service ido2db start
  2. # service icinga start
  3. # chkconfig –add icinga >> chkconfig icinga on

PS:

启动icinga之前可以先测试一下配置文件

 

  1. # /usr/local/icinga/bin/icinga -v /usr/local/icinga/etc/icinga.cfg

编译安装nrpe

 

  1. # cd /usr/local/src
  2. # wget -c http://cdnetworks-kr-1.dl.sourceforge.net/project/icinga-cn/nrpe-icinga/nrpe-icinga-2.12.tar.bz2
  3. # tar xf nrpe-icinga-2.12.tar.bz2
  4. # ./configure
  5. # make all

 

  1.  
  2. Makefile:86: *** missing separator. Stop.

解决:

编辑Makefile,删除8592行(判断操作系统)

 

  1. # vi Makefile
  2. # make all
  3. # make install
  4. # make install-plugin
  5. # make install-init
  6. # make install-xinetd
  7. # make install-daemon-config

测试

  1. # /usr/local/icinga/libexec/check_nrpe -H 127.0.0.1
  2. NRPE v2.12
  3. # /usr/local/icinga/libexec/check_nrpe -H 172.16.51.7
  4. CHECK_NRPE: Error - Could not complete SSL handshake.

解决:

配置被监控linux主机

 

  1. # vi /usr/local/icinga/etc/nrpe.cfg
  2. allowed_hosts=127.0.0.1,172.16.51.9
  3. # /etc/init.d/icinga-nrpe restart
  4. # /usr/local/icinga/libexec/check_nrpe -H 172.16.51.7
  5. NRPE v2.12
如果要安装icinga-web可以按照如下操作:
icinga还有安卓版的手机客户端,需要在服务器上安装icinga-mobile,安装方法如下:
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值