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

Installing Nagios 4.0.2 On CentOS 6.5 (Including NRPE installation)

[复制链接]

尚未签到

发表于 2019-1-15 08:11:54 | 显示全部楼层 |阅读模式
Installing Nagios 4.0.2 On CentOS 6.5 x86_64

Introduction
  Nagios is a monitoring tool under GPL licence. This tool lets you  monitor servers, network hardware (switches, routers, ...) and  applications. A lot of plugins are available and its big community makes  Nagios the biggest open source monitoring tool. This tutorial shows how  to install Nagios 4.0.2 on CentOS 6.5.
  

  Note: you should config postfix mail running correctly first.
  please setup NTP for time synchronization
Prerequisites
  Make sure you've set the hostname correctly, otherwise to modify /etc/sysconfig/network file.

  After installing your CentOS server, you have to disable selinux & install some packages to make nagios work.
  To disable selinux, open the file: /etc/selinux/config
# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive // change this value to disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted   Now, download all packages you need:
# yum -y install gd gd-devel httpd php gcc glibc glibc-common make net-snmp net-snmp-devel net-snmp-utils openssl-devel mysql-devel (使用check_mysql所需) openssh-clients (使用check_by_ssh所需)

  
[root@tecmint]# groupadd nagios
  useradd -s /bin/false -g nagios nagios
  

  Next, add apache user to the nagios group.
[root@tecmint]# usermod -G nagios apache

Nagios Installation
  Create a directory:
# mkdir /root/nagios
  Navigate to this directory:
# cd /root/nagios
  Download nagios-core & plugin:
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.gz.
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.5.tar.gz
  Untar nagios core:
# tar xvzf nagios-4.0.2.tar.gz
  Go to the nagios dir:
# cd nagios
  Configure before make:
# ./configure --with-command-group=nagios --enable-nanosleep --enable-event-broker

  Make all necessary files for Nagios:
# make all
  Installation:
# make install
# make install-init
# make install-commandmode
# make install-config
Open the “contacts.cfg” file with your choice of editor and set the  email address  associated with the nagiosadmin contact definition to receiving email alerts.
# vi /usr/local/nagios/etc/objects/contacts.cfg

# make install-webconf
  Create a password to log into the web interface:
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
chown nagios.nagios /usr/local/nagios/etc/htpasswd.users
Note: more users can be added with htpasswd /usr/local/nagios/etc/htpasswd.users username, this username should be matched with contacts in the contacts.cfg
  

  Now, you have to install the plugins:
# cd ..
# tar xvzf nagios-plugins-1.5.tar.gz
# cd nagios-plugins-1.5
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
  

  Verify Nagios Configuration Files
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  

  Start the service and start it on boot:
# chkconfig --add nagios
# chkconfig --level 35 nagios on
# chkconfig --level 35 httpd on


vi /etc/hosts to add ip_address and hostname

vi /etc/httpd/conf/httpd.conf to modify "ServerName"
touch /var/www/html/index.html to avoid get localhost HTTP error “Nagios HTTP WARNING: HTTP/1.1 403 Forbidden”
# service nagios start
# service httpd start


  Now, connect to your nagios system:
  http://Your-Nagios-IP/nagios and enter login : nagiosadmin & password you have chosen above.
  

And after the installation ?
  After  the installation you have to configure all your host & services in  nagios configuration files.This step is performed in command line and is  complicated, so I recommand to install tool like Centreon, that is a  beautiful front-end to add you host & services.
  

  Install NRPE:
On Remote Linux Host:
1. yum -y install gcc glibc glibc-common gd gd-devel make net-snmp net-snmp-devel net-snmp-utils openssl-devel mysql-devel (使用check_mysql所需)

  
2. groupadd nagios
  useradd -s /bin/false -g nagios nagios
  
3. mkdir /root/nagios
  cd /root/nagios
  wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz

  tar xvf nagios-plugins-1.5.tar.gz
  
4. cd nagios-plugins-1.5
  ./configure
  make; make install
  chown nagios.nagios /usr/local/nagios
  chown -R nagios.nagios /usr/local/nagios
  
5. cd /root/nagios
  wget http://garr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

  tar xzf nrpe-2.15.tar.gz
  
6. cd nrpe-2.15
  ./configure
  make all
  make install-plugin
  make install-daemon
  make install-daemon-config
  
7. vi /usr/local/nagios/etc/nrpe.cfg add monitoring server ip to "allowed_hosts=127.0.0.1,monitoring_ip_address" line
  所有需要检测本地资源的命令都写在此文件中 -- nrpe.cfg

  
8. cp /root/nagios/nrpe-2.15/init-script /etc/init.d/nrpe
  chmod 755 /etc/init.d/nrpe
  chkconfig --add nrpe
  service nrpe start
  
9. check nrpe version: /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
  
10. configure firewall rules

  iptables -A INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
  service iptables save
On Monitoring Host:
1. cd /root/nagios
  wget http://garr.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

  tar xzf nrpe-2.15.tar.gz
  
2. cd nrpe-2.15
  ./configure
  make all
  make install-plugin
  
3. check remote host nrpe version:
  /usr/local/nagios/libexec/check_nrpe -H remote_ip_address
  
4. create check_nrpe command:
vi /usr/local/nagios/etc/objects/commands.cfg
define command{
    command_name    check_nrpe
    command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
    }
  
5. cd /usr/local/nagios/etc/objects/

  touch hosts.cfg services.cfg
  chown nagios.nagios hosts.cfg services.cfg
  chmod 664 hosts.cfg services.cfg
  
6. vi /usr/local/nagios/etc/nagios.cfg
add

  "cfg_file=/usr/local/nagios/etc/objects/hosts.cfg'
  "cfg_file=/usr/local/nagios/etc/objects/services.cfg'
  
7. service nagios restart
For Windows client using NSClient++ x64
  1. install NSCP-0.4.1.102-x64.msi on Windows Server 2012



  

  2. on nagios monitoring server
  vi /usr/local/nagios/etc/objects/windows.cfg
  根据需要修改windows主机的名称及IP address
  

  3. vi /usr/local/nagios/etc/nagios.cfg
  cfg_file=/usr/local/nagios/etc/objects/windows.cfg
  

  4. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  service nagios restart
  

  Nagstamon桌面报警器
  1. 从 http://nagstamon.ifw-dresden.de/  下载最新的版本,我这里下载的是windows版--Nagstamon_0.9.11_setup.exe

  

  2. 安装完后配置下


  

  3. 显示效果





运维网声明 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-663378-1-1.html 上篇帖子: nagios监控搭建及配置 下篇帖子: 云计算管理三大利器之Nagios
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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