Source installation Nagios (CENTOS7)

Source: Internet
Author: User
Tags install openssl disk usage install perl

I. About Nagios
1, an open-source computer system and network monitoring tools, can effectively monitor the Windows, Linux and UNIX host status
, switches, routers, and other network settings. When the system or service status is abnormal, email or SMS alarm is sent, the first
The time notifies the fragmented personnel, sends the normal mail or the text message notification after the state restores.
2. Main functions
Network Service Monitoring (SMTP, POP3, HTTP, NNTP, ICMP, SNMP, FTP, SSH)
Host resource monitoring (CPU load, disk usage, system logs), also including Windows hosts (using nsclient++ plugin)
You can specify the plugin you write to collect data over the network to monitor any situation
Scripts can be executed remotely by configuring the Nagios remote execution plug-in
Remote monitoring supports SSH or SSL plus channel mode for monitoring
The simple plugin design allows users to easily develop their own inspection services, supporting many development languages
Contains many graphical data plugins (Nagiosgraph, Nagiosgrapher, Pnp4nagios, etc.)
Parallel service Check Available
Ability to define the hierarchy of network hosts, allowing for step-by-step checks, starting from the parent host
Notify when a problem occurs with a service or host, via email, pager, SMS or any user-defined plugin
Ability to customize the event handling mechanism to reactivate a faulty service or host
Automatic log Looping
Supports redundant monitoring
Includes web interface to view current network status, notifications, problem history, log files, etc.
Ii. working principle of Nagios
1, Nagios's function is to monitor the service and the host, but he does not include this part of the function, all the monitoring, detection functions are through a variety of plug-ins to complete.
2. NAGIOS4 Status Return information
0 (OK) indicates status OK/green
1 (WARNING) indicates a warning appears/***
2 (CRITICAL) indicates a very serious error/red
3 (UNKNOWN) indicates unknown error/deep * * *
3, Nagios through Nrpe to remote management services
Nagios executes the Check_nrpe plugin installed inside it and tells Check_nrpe to detect which services.
Connecting the Nrpe on the remote machine via the Ssl,check_nrpe daemon
NRPE running various local plugins to detect local service and status (Check_disk)
Finally, NRPE passes the result of the test to the Check_nrpe,check_nrpe of the host side and sends the result to the Nagios state queue.
Nagios reads the information in the queue, then displays the results.
Iii. Nagios Installation (CentOS7)
1, Lamp environment construction
(1) Source code installation apr-1.5.2 and apr-util-1.5.4
CD apr-1.5.2
./configure && make && make install
CD apr-util-1.5.4
./configure--with-apr=/usr/local/apr/&& make && make install


(2) Installation Openssl-devel
#mod_ssl has been requested
Yum-y Install Openssl-devel


(3) Source code installation httpd-2.4.17
#./configure--prefix=/usr/local/apache2--sysconfdir=/etc/httpd/--enable-so--enable-ssl=static--with-ssl=/usr/ local/ssl/--enable-mods-shared=all--with-apr=/usr/local/apr/--with-apr-util=/usr/local/apr/--enable-cgi-- Enable-suexec
./configure--prefix=/usr/local/apache2--sysconfdir=/etc/httpd/--enable-so--enable-ssl=static--with-ssl=/usr/ local/ssl/--enable-mods-shared=all--with-apr=/usr/local/apr/--with-apr-util=/usr/local/apr/--enable-cgi
Make && make install


(4) Source code installation mysql-5.6.27-linux-glibc2.5-x86_64
#FATAL Error:please Install the following Perl modules before executing scripts/mysql_install_db:data::D umper
Yum-y Install Perl-data-dumper

Tar zxvf mysql-5.6.27-linux-glibc2.5-x86_6.tar.gz-c/uar/local/
Cd/usr/local
Ln-s Mysql-5.6.27-linux-glibc2.5-x86_64/mysql
CD MySQL


#添加mysql用户和群组
Groupadd MySQL
Useradd-r-G MySQL MySQL


#修改相关目录和文件属主和所属群组
Chown-r MySQL.
Chgrp-r MySQL.
Or: Chown-r mysql:mysql.

#将目录属主更改为root to prevent MySQL users from deleting directories
Chown-r Root.
Chown-r MySQL Data

#使用mysql用户权限来初始化数据库
scripts/mysql_install_db--user=mysql


#将mysql添加为服务
CP Support-files/mysql.server/etc/init.d/mysqld
Chkconfig--add mysqld

#将mysql的bin目录加入到PATH环境变量
#在/etc/profile The last side to add
echo "path= $PATH:/usr/local/mysql/bin" >>/etc/profile
Source/etc/profile

#脚本初始化已经添加mysqld脚本, if there is no direct cp/etc/init.d/mysqld
/etc/rc.d/init.d/mysqld

#启动mysql
Mkdir-p/var/run/mysqld/
Chown-r mysql:mysql/var/run/mysqld/
#/var/log/mariadb/mariadb.log No such file or directory
Mkdir-p/var/log/mariadb//var/run/mariadb/
Touch/var/log/mariadb/mariadb.log
Chown root:mysql/var/log/mariadb/mariadb.log/var/run/mariadb/
Chmod-r 774/var/log/mariadb/mariadb.log/var/run/mariadb/

/usr/local/mysql/bin/mysqld_safe &
Ln-s/var/lib/mysql/mysql.sock/tmp/mysql.sock

#在/etc/my.cnf File The socket parameter is specified as/tmp/mysql.sock
echo "Socket=/tmp/mysql.sock" >>/etc/my.cnf
#修改root密码为love
#mysqladmin-u root-p password Love--socket=/var/lib/mysql/mysql.sock
Mysqladmin-u root-p Password Love


(4) Source code installation php-5.6.15
#apxs是在安装php时生成动态连接模块工具, if you do not specify a path, Apache cannot invoke PHP
#一定要添加--with-apxs2=/usr/local/apache2/bin/apxs
#php安装完成后, you can see that the "LoadModule php5_module modules/libphp5.so" is added in the httpd.conf file

#安装依赖包libxml2-devel
#error: Xml2-config not found. Please check your LIBXML2 installation
Yum-y Install Libxml2-devel

#libzip: Not Found
Yum-y Install Libzip-devel

#动态加载php来完成解析
#./configure--prefix=/usr/local/php--with-config-file-path=/etc--with-mysql=/usr/local/mysql/--with-apxs2=/usr /local/apache2/bin/apxs
./configure--prefix=/usr/local/php--with-config-file-path=/etc--with-mysql=/usr/local/mysql/--with-apxs2=/usr/ Local/apache2/bin/apxs--enable-mbstring--with-libzip--enable-zip
Make && make install

CP Php.ini-development/etc/php.ini
#不需要进行手动更改就可以让apache调用php
#php在编译的时候会修改httpd the. conf configuration file, add the following line
LoadModule Php5_module modules/libphp5.so
#如果在编译的时候没有指定--WITH-APXS2=/USR/LOCAL/APACHE2/BIN/APXS, Apache cannot load PHP

(5) Lamp connection test
#设置service方式启动apache
#将启动脚本复制为/etc/init.d/httpd
Cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd

#可以这样来停止, start, and restart Apache
Service httpd Stop/start/restart
/ETC/INIT.D/HTTPD Stop/start/restart
/usr/local/apache2/bin/apachectl Stop/start/restart


#或许是因为兼容性不好, unable to set boot boot with chkconfig
Chkconfig–add httpd

#但是可以修改/etc/rc.local set Apache on boot
#在/etc/rc.local Add
/usr/local/apache2/bin/apachectl start

#修改httpd. conf:
#如果使用yum安装apache, the configuration file is stored in the
/etc/httpd/conf/httpd.conf

#DocumentRoot为
/var/www/html

#如果是使用源码方法安装, the configuration file is stored in the
/usr/local/apache2/conf/httpd.conf

#DocumentRoot为
/usr/local/apache2/htdocs

#在 <IfModule></IfModule> Add the following two lines so Apache knows how to parse PHP files
AddType application/x-httpd-php. php. phtml
AddType Application/x-httpd-php-source. Phps

#修改ServerName
ServerName 192.168.137.40:80

#在htdocs目录添加文件index. PHP, the content is as follows
#读取mysql数据库中的数据表user内容
<?php
$con =mysql_connect ("localhost", "root", "Love");
$sql = "Select User,password from User";
$db _select=mysql_select_db ("MySQL", $con);
$result =mysql_query ($sql, $con);
while ($row =mysql_fetch_array ($result))
{
echo $row ["User"]. " ". $row [" Password "];
echo "<br/>";
}
Mysql_close ($con);
?>
#从mysql数据库中读取数据表user并显示

#加载cgi解析
Added after #在 "LoadModule php5_module modules/libphp5.so"
LoadModule Cgi_module modules/mod_cgi.so



2, Installation nagios-4.1.1
CD nagios-4.1.1
Useradd nagios-m-s/sbin/nologin

#unzip: Command not found
Yum-y Install Unzip

./configure--prefix=/usr/local/nagios--with-nagios-group=nagios
Make install && do all && make Install-init && make Install-commandmode && make install- Config
CP sample-config/httpd.conf/etc/httpd/nagios.conf

#make Install-exfoliation, failed because the directory could not be found
#cp: Target/usr/local/nagios/share/stylesheetsis Not a directory
Mkdir-p/usr/local/nagios/share/stylesheetsis
CP-RF contrib/exfoliation/stylesheets/*/usr/local/nagios/share/stylesheetsis/

#make Install-classicui
#cp: Target usr/local/nagios/share/stylesheetsis not a directory
CP-RF html/stylesheets/*/usr/local/nagios/share/stylesheets

#安装插件
CD nagios-plugins-2.1.1
./configure--with-gnutls--enable-perl-modules--enable-libtap--with-openssl--with-gnutls && Make & & Make Install

#Can ' t locate extutils/makemaker.pm
Yum-y Install Perl-cpan
Cpan-i Extutils::makemaker
#或者
Yum-y Install Perl-extutils-makemaker.noarch

#添加nagios管理用户
/usr/local/apache2/bin/htpasswd-c/usr/local/nagios/etc/htpasswd.users Nagiosadmin

#检查配置文件
/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg

#下面的是因为nagios没有启动, you can start Nagios
#Error: Could Not read object configuration data!
/usr/local/nagios/bin/nagios-d/usr/local/nagios/etc/nagios.cfg

#打开浏览器访问, IP is the actual IP or domain name, if the domain name must be able to parse
Http://ip/nagios

3. Later supplement

(1), monitoring Windows host
(2), monitoring the Linux host

(3), e-mail notice
(4), SMS Notice


This article is from the "Love On Action" blog, please be sure to keep this source http://1055745601.blog.51cto.com/5003160/1717268

Source installation Nagios (CENTOS7)

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.