Icinga.docx
《Icinga.docx》由会员分享,可在线阅读,更多相关《Icinga.docx(9页珍藏版)》请在冰豆网上搜索。
Icinga
RHEL6+icinga-pnp4监控服务器搭建原创作者:
成都LD
ICINGA官网:
ICINGA中文化与集成项目:
http:
//icinga-
1.
用YUM来安装所需要的软件包,搭建YUM服务器:
[root@mail~]#mount/dev/cdrom/mnt
在/etc/yum.repos.d目录下创建一个以.repo结尾的文件:
[root@mail~]#vi/etc/yum.repos.d/server1.repo
然后执行rpm--import/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ---导入gpgkey
2.安装相关软件并创建icinga用户
Yum-yinstallfreetypelibjpeglibpngfontconfiglibdbilibdbi-develgccglibcglibc-commongdgd-devellibjpeglibjpeg-devellibpnglibpng-develnet-snmp*http*mysql*php*rrdtoolrrdtool-perlgdphp-gd
注:
以上有些软件包可能会在默认的RHEL中不存在,可以在http:
//pkgs.org中选择相应版本下载
[root@localhost/]#useradd–s/sbin/nogginicinga
3.复制绘图文件RRD模块
[root@localhost/]#cd/usr/lib64/perl5/
#cpRRDs.pm/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/
[root@localhost/]#cd/usr/lib64/perl5/auto/RRDs/
#cpRRDs.so/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/
32位系统文件在/usr/lib/perl5下
4.下载ICINGA-PNP4和其它软件
Icinga-pnp4-cn:
nrpe-icinga:
nagios-plugins:
5.安装软件:
由于软件是以.xz结尾的,所以要用xz来解压
[root@localhostopt]#cdicinga-pnp4-cn-1.7.1
[root@localhosticinga-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
#makeall
解决方法:
编辑cgi/status.c这个文件
源码包出现一个小小的错误if少了一i,我们把i添加上。
Makeclean后再使用makeall
#makeinstall
#makeinstall-init加入到服务中/etc/init.d/
#makeinstall-api
#makeinstall-commandmode生成icinga.cmd
#makeinstall-idoutils默认已启用ido2db
#makeinstall-webconf生成apache配置文件/etc/httpd/conf.d
#makeinstall-processperfdata安装process_perfdata.pl
#makeinstall-plugins安装pnp4相关工具
#makeinstall-config生成配置文件
chkconfig--addicinga
chkconfigicingaon
chkconfighttpdon
chkconfigmysqldon
6.创建数据库并导入数据
mysql–uroot
导入数据时报错
解决方法:
vimmodule/idoutils/db/mysql/mysql.sql删除4处“collateutf8_general_cs”重新导入
7.安装nagios-plugins
[root@localhostopt]#tarzxvfnagios-plugins-1.4.15.tar.gz
[root@localhostopt]#cdnagios-plugins-1.4.15
[root@localhostnagios-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
[root@localhostnagios-plugins-1.4.15]make
让icinga支持check_snmp
[root@localhostnagios-plugins-1.4.15]makeinstall
8.安装nrpe-icinga
[root@localhostopt]#tarjxvfnrpe-icinga-2.12.tar.bz2
[root@localhostopt]#cdnrpe-icinga-2.12
[root@localhostnrpe-icinga-2.12]#./configure--prefix=/usr/local/nrpe--with-nrpe-user=icinga--with-nrpe-group=icinga--with-nagios-user=icinga--with-nagios-group=icinga
[root@localhostnrpe-icinga-2.12]#makeall
解决方法:
删除Makefile86,89,92行前面的空格,并用tab键对齐。
同时在91行suse后面加上“:
”
[root@localhostnrpe-icinga-2.12]#makeinstall
[root@localhostnrpe-icinga-2.12]#makeinstall-daemon-config
[root@localhostnrpe-icinga-2.12]#cp/usr/local/nrpe/libexec/check_nrpe/usr/local/icinga/libexec/
[root@localhostnrpe-icinga-2.12]#cp/usr/local/nrp/bin/nrpe/usr/local/icinga/bin/
[root@localhostnrpe-icinga-2.12]#cpsample-config/nrpe.cfg/usr/local/incinga/etc/
[root@localhostnrpe-icinga-2.12]#rm–rf/usr/local/nrpe
9.设置icinga的访问密码
htpasswd-c/usr/local/icinga/etc/htpasswd.usersicingaadmin
输入两次密码
10.测试文件
/usr/local/icinga/bin/icinga-v/usr/local/icinga/etc/icinga.cfg
11.启动服务
serviceicingastart
servicehttpdstart
serviceido2dbstart
chkconfigido2dbon
12.访问icinga
13.测试PNP4
点击服务旁边
根据提示对install.php进行改名,改完成刷新一下页面
查看currentload
14.使用sendemail发送报警邮件
下载sendEmail-v1.56.tar.gz
[root@localhostnrpe-icinga-2.12]#cdsendEmail-v1.56
[root@localhostsendEmail-v1.56]#cpsendEmail/usr/local/bin
发送测试邮件:
/usr/local/bin/sendEmail–fluodi@–tluodi@–s–u“fromicinga”–xuluodi–xpldcdld123–mtestmail
注:
-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'commanddefinition
definecommand{
command_namenotify-host-by-email
command_line/usr/bin/printf"%b""*****icinga*****\n\nNotificationType:
$NOTIFICATIONTYPE$\nHost:
$HOSTNAME$\nState:
$HOSTSTATE$\nAddress:
$HOSTADDRESS$\nInfo:
$HOSTOUTPUT$\n\nDate/Time:
$LONGDATETIME$\n"|/usr/local/bin/sendEmail–fluodi@–t$CONTACTEMAIL$–s–u"**$NOTIFICATIONTYPE$HostAlert:
$HOSTNAME$is$HOSTSTATE$**"–xuluodi@–xpldcdld123}
#'notify-service-by-email'commanddefinition
definecommand{
command_namenotify-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–fluodi@–t$CONTACTEMAIL$–s–u"**$NOTIFICATIONTYPE$ServiceAlert:
$HOSTALIAS$/$SERVICEDESC$is$SERVICESTATE$**"–xuluodi–xpldcdld123}
注:
使用#注释commands.cfg中默认定义的邮件配置文件
15.Icinga基本配置完成,关于主机定义、服务定义可以查看文档
谢谢!
!
!
注:
转载此文档请保留出处
原创作者:
成都LD