Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9249318
  • 博文数量: 1669
  • 博客积分: 16831
  • 博客等级: 上将
  • 技术积分: 12594
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 07:23
个人简介

柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!

文章分类

全部博文(1669)

文章存档

2023年(4)

2022年(1)

2021年(10)

2020年(24)

2019年(4)

2018年(19)

2017年(66)

2016年(60)

2015年(49)

2014年(201)

2013年(221)

2012年(638)

2011年(372)

分类: 系统运维

2012-09-29 10:05:09

搭建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 
  3. # wget -c 

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

 

 

8、导入数据库

  1. # mysql -p icinga < /usr/local/src/icinga-cn-1.7.0/module/idoutils/db/mysql
  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 
  3. # tar xf nrpe-icinga-2.12.tar.bz2
  4. # ./configure
  5. # make all

 

  1. 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
阅读(2174) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~