RHEL6+icinga-pnp4监控服务器搭建
RHEL6+icinga-pnp4监控服务器搭建ICINGA官网:http://www.icinga.com
ICINGA中文化与集成项目:http://icinga-cn.sourceforge.net/
[*] 1.
用YUM来安装所需要的软件包,搭建YUM服务器:
# mount /dev/cdrom /mnt
在/etc/yum.repos.d目录下创建一个以.repo结尾的文件:
# vi /etc/yum.repos.d/server1.repo
然后执行 rpm--import/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ---导入gpgkey
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
[*] 2. 安装相关软件并创建icinga用户
Yum -y install freetype libjpeg libpng fontconfig libdbilibdbi-devel gcc glibc glibc-common gdgd-devel libjpeg libjpeg-devel libpng libpng-devel net-snmp*http* mysql*php* rrdtoolrrdtool-perlgd php-gd
注:以上有些软件包可能会在默认的RHEL中不存在,可以在http://pkgs.org中选择相应版本下载
# useradd –s /sbin/noggin icinga
[*] 3. 复制绘图文件RRD模块
yum installperl-rrdtool
# cd/usr/lib64/perl5/
# cp RRDs.pm/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/
# cd/usr/lib64/perl5/auto/RRDs/
# cp RRDs.so /usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/
32位系统文件在/usr/lib/perl5下
[*] 4. 下载ICINGA-PNP4和其它软件
Icinga-pnp4-cn:
http://nchc.dl.sourceforge.net/project/icinga-cn/icinga-pnp4nagios-cn/icinga-pnp4-cn-1.7.1.tar.xz
nrpe-icinga:
http://nchc.dl.sourceforge.net/project/icinga-cn/nrpe-icinga/nrpe-icinga-2.12.tar.bz2
nagios-plugins:
http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
[*] 5. 安装软件:
由于软件是以.xz结尾的,所以要用xz来解压
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
#cdicinga-pnp4-cn-1.7.1
# ./configure--prefix=/usr/local/icinga --with-rdbm --with-rdbm-incdir=/usr/include/rdbm/--with-rdbm-libdir=/usr/lib64/ --enable-idoutils--with-web-apache-path=/etc/httpd/conf.d/ --with-perl_lib_path=/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi--with-command-group=icinga --with-command-user=icinga
configure: error: Perl Module Time::HiRes not available
需要安装一个perl-Time-HiRes扩展包的支持,我们运行如下命令:
# yuminstall perl-Time-
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
#make all
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
解决方法:
编辑cgi/status.c这个文件
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
源码包出现一个小小的错误if 少了一i,我们把i添加上。Make clean后再使用make all
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
#make install
#makeinstall-init加入到服务中/etc/init.d/
#make install-api
#makeinstall-commandmode生成icingaNaNd
#makeinstall-idoutils默认已启用ido2db
#makeinstall-webconf生成apache配置文件/etc/httpd/conf.d
#makeinstall-processperfdata安装process_perfdata.pl
#makeinstall-plugins安装pnp4相关工具
#makeinstall-config生成配置文件
chkconfig --addicingamka
chkconfig icingaon
chkconfig httpd on
chkconfig mysqldon
[*] 6. 创建数据库并导入数据
mysql–uroot
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
导入数据时报错
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
解决方法:vim module/idoutils/db/mysql/mysql.sql 删除4处“collate utf8_general_cs”重新导入
[*] 7. 安装nagios-plugins
#tarzxvf nagios-plugins-1.4.15.tar.gz
#cdnagios-plugins-1.4.15
#./configure--prefix=/usr/local/icinga--with-cgiurl=/icinga/cgi-bin --with-htmurl=/icinga --with-nagios-user=icinga--with-nagios- group=icinga
make
让icinga支持check_snmp
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
make install
[*] 8. 安装nrpe-icinga
#tar jxvfnrpe-icinga-2.12.tar.bz2
#cd nrpe-icinga-2.12
#./configure--prefix=/usr/local/nrpe --with-nrpe-user=icinga --with-nrpe-group=icinga--with-nagios-user=icinga --with-nagios-group=icinga
#make all
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
解决方法:删除Makefile 86,89,92行前面的空格,并用tab键对齐。同时在91行suse后面加上“:”
#makeinstall
#make install-daemon-config
#cp /usr/local/nrpe/libexec/check_nrpe/usr/local/icinga/libexec/
#cp /usr/local/nrp/bin/nrpe/usr/local/icinga/bin/
#cp sample-config/nrpe.cfg/usr/local/incinga/etc/
# rm –rf /usr/local/nrpe
[*] 9. 设置icinga的访问密码
htpasswd-c/usr/local/icinga/etc/htpasswd.users icingaadmin
输入两次密码
[*] 10.测试文件
/usr/local/icinga/bin/icinga -v/usr/local/icinga/etc/icinga.cfg
[*] 11.启动服务
serviceicinga start
service httpd start
service>
chkconfig >
[*] 12.访问icinga
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
[*] 13.测试PNP4
点击服务旁边http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
根据提示对install.php进行改名,改完成刷新一下页面
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
查看current load
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
[*] 14.使用sendemail发送报警邮件
下载 sendEmail-v1.56.tar.gz
#cd sendEmail-v1.56
# cp sendEmail /usr/local/bin
发送测试邮件:
/usr/local/bin/sendEmail–f luodi@cdld.com –t luodi@cdld.com –s mail.cdld.com–u “from icinga” –xu luodi –xp ldcdld123–m test mail
注:-t 表示接收者的邮箱
-s 表示SMTP服务器的域名或者ip
-u 表示邮件的主题
-xu 表示SMTP验证的用户名
-xp 表示SMTP验证的密码(注意,这个密码貌似有限制,例如我用d!5neyland就不能被正确识别)
-m 表示邮件的内容如果你不带-m参数的话,就会提示你自行输入
vi /usr/local/icinga/etc/objects/commands.cfg
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** icinga*****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:$HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time:$LONGDATETIME$\n" | /usr/local/bin/sendEmail –fluodi@cdld.com–t $CONTACTEMAIL$–s mail.cdld.com–u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is$HOSTSTATE$ **" –xu luodi@cdld.com –xp ldcdld123 }
# 'notify-service-by-email'command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** icinga *****\n\nNotificationType: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress:$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditionalInfo:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail –f luodi@cdld.com–t $CONTACTEMAIL$ –s mail.cdld.com–u "** $NOTIFICATIONTYPE$ ServiceAlert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" –xu luodi–xp ldcdld123 }
注:使用#注释commands.cfg中默认定义的邮件配置文件
[*] 15.Icinga基本配置完成,关于主机定义、服务定义可以查看文档
http://blog.运维网.com/e/u261/themes/default/images/spacer.gif
页:
[1]