Deployment Monitoring Three Musketeers Nagios server monitoring

Source: Internet
Author: User

Nagios Introduction: Nagios is an open source free network monitoring tool that can effectively monitor Windows, Linux and UNIX host status, switch routers and other network devices, printers, etc. Send mail or SMS alarm when the system or service status is abnormal the first time to notify the site operators, after the status of the resumption of normal mail or SMS notification. The features that Nagios can monitor are:
    • 1, monitoring network services (SMTP, POP3, HTTP, NNTP, ping, etc.);
    • 2, monitor the host resources (processor load, disk utilization, etc.);
    • 3, simple plug-in design allows users to easily expand their services to detect methods;
    • 4, parallel service inspection mechanism;
    • 5, with the ability to define the hierarchical structure of the network, with the "parent" host definition to express the relationship between the network host, this relationship can be used to identify and clarify the host outage or unreachable state;
    • 6, when the service or host problems arise and resolve the alarm sent to the contact person (via email, SMS, user-defined mode);
    • 7, can define some processing procedures, so that it can be in service or host failure to play a preventive role;
    • 8, automatic log scrolling function;
    • 9, can support and implement redundant monitoring of the host;
    • 10, the optional web interface for viewing the current network status, notification and fault history, log files and so on;
    • 11, can be viewed through the mobile phone system monitoring information;
    • 12. Custom event handling controller can be specified
The circumstances of the case:
Host system IP Address
Nagios CentOS 7.4 192.168.100.130
be monitored CentOS 7.4 192.168.100.131
Deploying the Nagios Monitoring System 1. Turn off the firewall:
systemctl stop firewalldsystemctl disable firewalldsetenforce 0
2. Create Nagios Users:
useradd -M -s /sbin/nologin nagiosmkdir /usr/local/nagioschown -R nagios.nagios /usr/local/nagios
3. Installation Environment:
yum -y install gcc gcc-c++ make perl openssl-devel
4. Compile and install Nagios:
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.1.tar.gztar zxvf nagios-4.3.1.tar.gzcd nagios-4.3.1/./configure --prefix=/usr/local/nagiosmake allmake installmake install-init   # 把nagios做成一个运行脚本,使nagios随系统开机启动make install-commandmode  # 给外部命令访问nagios配置文件的权限make install-config  # 把配置文件样例复制到nagios的安装目录
chkconfig --add /etc/rc.d/init.d/nagioschkconfig --level 35 nagios onchkconfig --list nagios
5. Verify that the installation is successful:
[[email protected] nagios-4.3.1]# ls /usr/local/nagios/bin  etc  libexec  sbin  share  var                    #查看文件是否存在
6. Install the Nagios-plugins plugin:
tar zxvf nagios-plugins-1.5.tar.gz -C /opt/cd /opt/nagios-plugins-1.5./configure --prefix=/usr/local/nagiosmake && make install
7. Install the Web service:
yum -y install httpd php
8. Modify the HTTP configuration file:
vim /etc/httpd/conf/httpd.conf User nagios      #管理用户和组修改成nagiosGroup nagiosDirectoryIndex index.html index.php   #添加 index.phpAddType application/x-httpd-php .php     
# 为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"   #末尾添加<Directory "/usr/local/nagios/sbin">      AuthType Basic      Options ExecCGI      AllowOverride None      Order allow,deny      Allow from all      AuthName "Nagios Access"      AuthUserFile /usr/local/nagios/etc/htpasswd                   Require valid-user </Directory> Alias /nagios "/usr/local/nagios/share" <Directory "/usr/local/nagios/share">      AuthType Basic      Options None      AllowOverride None      Order allow,deny      Allow from all      AuthName "nagios Access"      AuthUserFile /usr/local/nagios/etc/htpasswd      
9. Create an Access Authentication file:
[[email protected] ]# htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadm  #用户名 nagiosadmNew password:         #密码Re-type new password: Adding password for user nagiosadm
10. Turn on the service and visit Http://192.168.100.130/nagios:
systemctl start httpd.service systemctl start nagios.service

11. Modify the Objects Profile Template: 1. Modify Templates.cfg:
cd /usr/local/nagios/etc/objectsvim templates.cfg  #定义主机和服务模板的配置文件contact_groups  test   #5个全部修改  定义联系组的名称
2. Add Hosts.cfg:
vim hosts.cfg  #hosts.cfg主要用来指定被监控的主机地址以及相关属性信息(不能有任何空格)define host{           use                     linux-server #引用主机linux-server的属性信息,linux-server主机在templates.cfg文件中进行了定义。        host_name               Nagios-Linux #主机名        alias                   Nagios-Linux #主机别名        address                 192.168.100.131 #被监控的主机地址,这个地址可以是ip,也可以是域名。        }   #定义一个主机组   define hostgroup{              hostgroup_name          bsmart-servers#主机组名称,可以随意指定。        alias                   bsmart servers#主机组别名        members                 Nagios-Linux#主机组成员,其中“Nagios-Linux”就是上面定义的主机。             }
3. localhost.cfg file #用来监控本机 generally do not need to change 4. Windows.cfg #用来监控windows There is no need to use 5. Add Services.cfg:
vim services.cfg  #主要用于定义监控的服务和主机资源define service{          use                     local-service #引用local-service服务的属性值,local-service在templates.cfg文件中进行了定义。        host_name               Nagios-Linux #指定要监控哪个主机上的服务,“Nagios-Server”在hosts.cfg文件中进行了定义。        service_description     check-host-alive #对监控服务内容的描述,以供维护人员参考。        check_command           check-host-alive #指定检查的命令。        }  
6. Modify Contacts.cfg:
vim contacts.cfg #定义联系人和联系人组的配置文件(不能有空格)define contact{        contact_name                    nagiosadm #联系人的名称,这个地方不要有空格        use                             generic-contact #引用generic-contact的属性信息,其中“generic-contact”在templates.cfg文件中进行定义        alias                           Nagios Admin        email                           [email protected]    #邮箱        }define contactgroup{        contactgroup_name       test #联系人组的名称,同样不能空格        alias                   Technical Support #联系人组描述        members                 nagiosadm #联系人组成员,其中“nagiosadm”就是上面定义的联系人,如果有多个联系人则以逗号相隔        }
7. commands.cfg file #此文件默认是存在的, can be used without modification, of course, if there are new commands to join, this file can be added 12. Modify the Nagios configuration file: 1. Resource.cfg file #是nagios的变量定义文件2. Modify Cgi.cfg:
cd /usr/local/nagios/etc/ vim cgi.cfg  #文件用来控制相关cgi脚本#由于nagios的web监控界面验证用户为nagiosadm,所以只需在cgi.cfg文件中添加此用户的执行权限#末尾添加default_user_name=nagiosadmauthorized_for_system_information=nagiosadmin,nagiosadm  authorized_for_configuration_information=nagiosadmin,nagiosadm  authorized_for_system_commands=nagiosadmauthorized_for_all_services=nagiosadmin,nagiosadm  authorized_for_all_hosts=nagiosadmin,nagiosadmauthorized_for_all_service_commands=nagiosadmin,nagiosadm  authorized_for_all_host_commands=nagiosadmin,nagiosadm
3. Modify Nagios.cfg:
vim nagios.cfg #将对象配置文件在Nagios.cfg文件中进行引用cfg_file=/usr/local/nagios/etc/objects/hosts.cfg    #添加cfg_file=/usr/local/nagios/etc/objects/services.cfg #添加command_check_interval=10s       #该变量用于设置nagios对外部命令检测的时间间隔
13. Check the configuration file syntax:
[[email protected] ]# /etc/init.d/nagios checkconfig Running configuration check... OK.
14. Visit Http://192.168.100.130/nagios:
systemctl restart nagios.service

Deployment Monitoring Three Musketeers Nagios server monitoring

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.