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

Installation instructions of Nagios on CentOS 6.4 64bit

[复制链接]

尚未签到

发表于 2019-1-13 15:28:29 | 显示全部楼层 |阅读模式
  # Installation instructions of Nagios on CentOS 6.4 64bit
  Author : Larry Zhao
  Q    Q : 920057952
  B L O G: larryzhao.blog.运维网.com
  E-mail : zhaolong0508@126.com
  #  NTP Service
  yum install ntp
  service ntpd start
  chkconfig ntpd on
  crontab -e
  * * * * * /usr/sbin/ntpdate cn.pool.ntp.org
  

  # Packets Prepare
  nagios-3.3.1.tar.gz nagios-plugins-1.4.15.tar.gz  nrpe-2.12.tar.gz  rrdtool-1.4.7.tar.gz  pnp4nagios-0.6.6.tar.gz
  

  # We use X-shell to upload these files to our server
  mkdir /upload;cd /upload
  

  ######################### Nagios Server 10.0.0.145 ######################################
  tar zxvf nagios-3.3.1.tar.gz
  tar zxvf nagios-plugins-1.4.15.tar.gz
  tar zxvf nrpe-2.12.tar.gz
  tar zxvf rrdtool-1.4.7.tar.gz
  tar zxvf pnp4nagios-0.6.6.tar.gz
  rm -f *.gz
  # Environment Prepare
  yum install -y net-snmp net-snmp-utils httpd gcc glibc glibc-common *gd* php php-mysql mysql mysql-server mysql-devel openssl-devel
  yum install -y libpangocairo pango pango-devel cairo cairo-devel redhat-lsb-graphics pkgconfig groff glib glib-devel libart* gettext gettext-devel libxml2 libxml2-devel
  yum install -y freetype freetype-devel libpng libpng-devel libjpeg libjpeg-devel  libiconv libiconv-devel  qpixman qpixman-devel
  #SELINUX
  vim /etc/selinux/config
  SELINUX=disabled
  

  #IPTABLES
  service iptables stop
  chkconfig iptables off
  

  # Install Nagios
  groupadd nagcmd
  useradd -m nagios
  usermod -a -G nagcmd nagios
  usermod -a -G nagcmd apache
  cd nagios
  ./configure --with-command-group=nagcmd --enable-event-broker
  make all && make install && make install-init && make install-config && make install-commandmode && make install-webconf
  htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  # type new password twice
  Here we use nagios as our password
  

  service httpd start
  chkconfig httpd on
  cd ../nagios-plugins-1.4.15/
  ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql
  make && make install
  chkconfig --add nagios
  chkconfig nagios on
  vim /etc/profile
  # Insert "PATH=$PATH:/usr/local/nagios/bin" into /etc/profile
  PATH=$PATH:/usr/local/nagios/bin
  #save and exit
  . /etc/profile
  nagios -v /usr/local/nagios/etc/nagios.cfg
  service nagios start
  #Now if you want access your nagios server, http://ip/nagios. Username:nagiosadmin Password:nagios
  

  cd ../nrpe-2.12/
  ./configure --enable-ssl --with-ssl-lib=/lib/
  make all && make install-plugin
  

  

  # It is necessary to insert some lines of code into /usr/local/nagios/etc/objects/commands.cfg
  vim /usr/local/nagios/etc/objects/commands.cfg
  #check nrpe
  define command{
  command_name check_nrpe
  command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
  }
  #save and exit
  

  #We can use the command_line below to check our config files
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  

  cd ../rrdtool-1.4.7
  ./configure --prefix=/usr/local/rrdtool
  make && make install
  

  cd ../pnp4nagios-0.6.6
  chown nagios.nagios *
  chmod +x *
  ./configure --prefix=/usr/local/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool
  make all
  make install
  make install-webconf
  make install-config
  make install-init
  

  cd /usr/local/pnp4nagios/etc/
  mv misccommands.cfg-sample misccommands.cfg
  mv nagios.cfg-sample nagios.cfg
  mv rra.cfg-sample rra.cfg
  mv npcd.cfg-sample npcd.cfg
  mv process_perfdata.cfg-sample process_perfdata.cfg
  cd pages/
  mv web_traffic.cfg-sample web_traffic.cfg
  cd ../check_commands/
  mv check_all_local_disks.cfg-sample  check_all_local_disks.cfg
  mv check_nrpe.cfg-sample  check_nrpe.cfg
  mv check_nwstat.cfg-sample  check_nwstat.cfg
  service npcd restart
  

  # Nagios config files
  vim /usr/local/nagios/etc/nagios.cfg
  process_performance_data=1
  host_perfdata_command=process-host-perfdata
  service_perfdata_command=process-service-perfdata
  

  vim /usr/local/nagios/etc/objects/commands.cfg
  # 'process-host-perfdata' command definition
  define command{
  command_name   process-host-perfdata
  command_line   /usr/local/pnp4nagios/libexec/process_perfdata.pl
  }
  # 'process-service-perfdata' command definition
  define command{
  command_name   process-service-perfdata
  command_line   /usr/local/pnp4nagios/libexec/process_perfdata.pl
  }
  command_name    process-service-perfdata
  command_line    /usr/local/nagios/libexec/process_perfdata.pl
  }
  

  vim /usr/local/nagios/etc/objects/templates.cfg
  define host {
  name          host-pnp
  action_url    /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
  register   0
  }
  define service {
  name         srv-pnp
  action_url   /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
  register   0
  }
  

  cp /upload/pnp4nagios-0.6.6/contrib/ssi/* /usr/local/nagios/share/ssi/
  

  cd /usr/local/pnp4nagios/share/
  mv install.php install.php.bak
  #check npcd.cfg
  /usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg
  #First time to access
  http://ip/php4nagios
  

  # create some config files as we like
  cd /usr/local/nagios/etc/objects/
  touch mylinux.cfg;vim mylinux.cfg
  define host{
  use             linux-server,host-pnp
  host_name       puppet
  alias           puppty_jd_server
  address         10.0.0.148
  }
  define serviceextinfo {
  host_name               puppet
  service_description     check_load
  action_url   /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$'class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
  }
  define service{
  use                     generic-service,srv-pnp
  host_name               puppet
  service_description     check_local_load
  check_command           check_nrpe!check_load
  }
  define service{
  use                     generic-service,srv-pnp
  host_name               puppet
  service_description     check_users
  check_command           check_nrpe!check_users
  }
  vim ../nagios.cfg
  #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
  cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
  

  service nagios restart
  service npcd restart
  service httpd restart
  ############################ Nagios Client 10.0.0.148 ###################################
  

  #  NTP Service
  yum install ntp
  service ntpd start
  chkconfig ntpd on
  crontab -e
  * * * * * /usr/sbin/ntpdate cn.pool.ntp.org
  

  # Packets Prepare
  nagios-plugins-1.4.15.tar.gz  nrpe-2.12.tar.gz
  

  # We use X-shell to upload these files to our server
  mkdir /upload;cd /upload
  tar zxvf nagios-plugins-1.4.15.tar.gz
  tar zxvf nrpe-2.12.tar.gz
  rm -f *.gz
  

  # Environment Prepare
  yum -y install net-snmp net-snmp-utils openssl-devel gcc glibc glibc-common *gd*
  #SELINUX
  vim /etc/selinux/config
  SELINUX=disabled
  

  #IPTABLES
  service iptables stop
  chkconfig iptables off
  

  useradd nagios
  cd nagios-plugins-1.4.15
  ./configure --with-nagios-user=nagios --with-nagios-group=nagios
  make && make install
  

  cd ../nrpe-2.12
  ./configure --enable-ssl --with-ssl-lib=/usr/lib/
  make all
  make install-plugin && make install-daemon && make install-daemon-config
  chown -R nagios:nagios /usr/local/nagios
  cp /usr/local/nagios/etc/nrpe.cfg /etc/nrpe.cfg
  #allowed_hosts change to the nagios server's IP address
  vim /etc/nrpe.cfg
  allowed_hosts=10.0.0.145
  

  #Three lines need to change, you can use set nu to find them
  vim /etc/snmp/snmpd.conf
  line 41 com2sec notConfigUser  default     larryzhao
  line 62 access  notConfigGroup ""      any       noauth    exact  mib2 none none
  line 89 view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
  service snmpd restart
  chkconfig snmpd on
  

  #Start nrpe service
  /usr/local/nagios/bin/nrpe -c /etc/nrpe.cfg -d
  #To check nrpe work status
  ps -ef |grep nrpe
  #add nrpe to rc.local
  vim /etc/rc.d/rc.local
  /usr/local/nagios/bin/nrpe -c /etc/nrpe.cfg -d
  

  

  ############################### E-mail Notice ##########################################
  yum install -y sendmail
  yum install -y sendmail-cf
  m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
  vi /etc/mail/local-host-names
  larryzhao.com
  vi /etc/mail/submit.cf
  find #Dj$w.Foo.COM
  Djlarryzhao.com
  service sendmail restart
  

  vim /usr/local/nagios/etc/objects/contacts.cfg
  define contact{
  contact_name                    nagiosadmin
  use                             generic-contact
  alias                           Nagios Admin
  email                           zhaolong0508@126.com,920057952@qq.com
  }
  
  vim /usr/local/nagios/etc/objects/commands.cfg
  # 'notify-host-by-email' command definition
  define command{
  command_name    notify-host-by-email
  command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
  }
  

  # 'notify-service-by-email' command definition
  define command{
  command_name    notify-service-by-email
  command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
  }
  

  

  

  

  

  

  

  

  
  





运维网声明 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-662860-1-1.html 上篇帖子: Nagios简介与安装(1) 下篇帖子: Nagios安装与配置(2)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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