设为首页 收藏本站
查看: 1536|回复: 0

RHEL6+icinga-pnp4监控服务器搭建

[复制链接]

尚未签到

发表于 2019-1-26 10:45:09 | 显示全部楼层 |阅读模式
  RHEL6+icinga-pnp4监控服务器搭建
  
  
  ICINGA官网:http://www.icinga.com
  ICINGA中文化与集成项目:http://icinga-cn.sourceforge.net/

  •   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 -y install freetype libjpeg libpng fontconfig libdbi  libdbi-devel gcc glibc glibc-common gdgd-devel libjpeg libjpeg-devel libpng libpng-devel net-snmp*  http* mysql*  php* rrdtool  rrdtool-perl  gd php-gd
  注:以上有些软件包可能会在默认的RHEL中不存在,可以在http://pkgs.org中选择相应版本下载
  [root@localhost  /]# useradd –s /sbin/noggin   icinga

  •   3.      复制绘图文件RRD模块
  yum install  perl-rrdtool
  [root@localhost  /]# cd/usr/lib64/perl5/
  # cp RRDs.pm/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/
  [root@localhost  /]# 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来解压
  
  [root@localhost opt]#cd  icinga-pnp4-cn-1.7.1
  [root@localhost icinga-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扩展包的支持,我们运行如下命令:
  [root@localhost pnp4nagios-0.6.21]# yuminstall perl-Time-

  #make all

  解决方法:
  编辑cgi/status.c这个文件

  源码包出现一个小小的错误if 少了一i,我们把i添加上。Make clean后再使用make all

  #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 --addicinga  mka
  chkconfig icingaon
  chkconfig httpd on
  chkconfig mysqldon

  •   6.      创建数据库并导入数据
  mysql  –u  root

  导入数据时报错

  解决方法:vim module/idoutils/db/mysql/mysql.sql 删除4处“collate utf8_general_cs”重新导入

  •   7.      安装nagios-plugins
  [root@localhost opt]#tarzxvf nagios-plugins-1.4.15.tar.gz
  [root@localhost opt]#cdnagios-plugins-1.4.15
  [root@localhost nagios-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@localhost nagios-plugins-1.4.15] make
  让icinga支持check_snmp

  [root@localhost nagios-plugins-1.4.15] make install

  •   8.      安装nrpe-icinga
  [root@localhost  opt]#tar jxvf  nrpe-icinga-2.12.tar.bz2
  [root@localhost  opt]#cd nrpe-icinga-2.12
  [root@localhost 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
  [root@localhost nrpe-icinga-2.12]#make all

  解决方法:删除Makefile 86,89,92行前面的空格,并用tab键对齐。同时在91行suse后面加上“:”
  [root@localhost nrpe-icinga-2.12]#make  install
  [root@localhost nrpe-icinga-2.12]#make install-daemon-config
  [root@localhost nrpe-icinga-2.12]#cp /usr/local/nrpe/libexec/check_nrpe/usr/local/icinga/libexec/
  [root@localhost nrpe-icinga-2.12]#cp /usr/local/nrp/bin/nrpe  /usr/local/icinga/bin/
  [root@localhost nrpe-icinga-2.12]#cp sample-config/nrpe.cfg  /usr/local/incinga/etc/
  [root@localhost  nrpe-icinga-2.12]# 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.  启动服务
  service  icinga start
  service httpd start

  service>
  chkconfig >

  •   12.  访问icinga

  
  
  
  
  

  •   13.  测试PNP4
  点击服务旁边
  
  根据提示对install.php进行改名,改完成刷新一下页面
  
  查看current load
  

  •   14.  使用sendemail发送报警邮件
  下载 sendEmail-v1.56.tar.gz
  [root@localhost  nrpe-icinga-2.12]#cd sendEmail-v1.56
  [root@localhost  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基本配置完成,关于主机定义、服务定义可以查看文档
  



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-667715-1-1.html 上篇帖子: icinga2通过check_ping.pl插件生成可用性监控 下篇帖子: icinga2对特定服务设置专门发邮件策略
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表