nagios.htmlphp
主程序Nagios+插件Nagios-plugins和一些可选的附加程序(NRPE、NSClient++、NSCA)等css
Nagios 经过NRPE 来远端管理服务html
Nagios 执行安装在它里面的check_nrpe 插件,并告诉check_nrpe 去检测哪些服务。java
经过SSL,check_nrpe 链接远端机子上的NRPE daemonnode
NRPE 运行本地的各类插件去检测本地的服务和状态(check_disk,..etc)mysql
最后,NRPE 把检测的结果传给主机端的check_nrpe,check_nrpe 再把结果送到Nagios状态队列中。linux
Nagios 依次读取队列中的信息,再把结果显示出来。ios
[root@localhost ~]# yum install gcc php httpd php-gd gd gd-devel mysql* -y
[root@localhost ~]# ntpdate cn.pool.ntp.org 2 Aug 21:34:56 ntpdate[1533]: step time server 110.75.186.249 offset 2631012.350036 sec
[root@localhost ~]# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel unzip
(由于nagios配置文件中默认安装目录是/usr/local/nagios为了不没必要要的修改)nginx
[root@localhost ~]# mkdir /usr/local/nagios [root@localhost ~]# useradd nagios -s /sbin/nologin -M [root@localhost ~]# chown nagios:nagios /usr/local/nagios/ [root@localhost ~]# ll -d /usr/local/nagios/ drwxr-xr-x 2 nagios nagios 4096 Jul 3 10:41 /usr/local/nagios/
[root@localhost ~]# tar zxvf nagios-4.2.0.tar.gz [root@localhost nagios-4.2.0]# ./configure --prefix=/usr/local/nagios/ *** Configuration summary for nagios 4.2.0 08-01-2016 ***: General Options: ------------------------- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagios Event Broker: yes Install ${prefix}: /usr/local/nagios Install ${includedir}: /usr/local/nagios/include/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/rc.d/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu IOBroker Method: epoll Web Interface Options: ------------------------ HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): Review the options above for accuracy. If they look okay, type 'make all' to compile the main program and CGIs. [root@localhost nagios-4.2.0]# make all #此过程当中报错记得安装unzip *** Compile finished *** If the main program and CGIs compiled without any errors, you can continue with installing Nagios as follows (type 'make' without any arguments for a list of all possible options): make install - This installs the main program, CGIs, and HTML files make install-init - This installs the init script in /etc/rc.d/init.d make install-commandmode - This installs and configures permissions on the directory for holding the external command file make install-config - This installs *SAMPLE* config files in /usr/local/nagios/etc You'll have to modify these sample files before you can use Nagios. Read the HTML documentation for more info on doing this. Pay particular attention to the docs on object configuration files, as they determine what/how things get monitored! make install-webconf - This installs the Apache config file for the Nagios web interface make install-exfoliation - This installs the Exfoliation theme for the Nagios web interface make install-classicui - This installs the classic theme for the Nagios web interface ###### 整个安装过程以下: ./configure --prefix=/usr/local/nagios/ make all make all make install make install-init make install-commandmode make install-config make install-webconf
[root@localhost ~]# ls -al /etc/httpd/conf.d/ total 24 drwxr-xr-x 2 root root 4096 Aug 2 21:41 . drwxr-xr-x 4 root root 4096 Jul 3 10:37 .. -rw-r--r-- 1 root root 1679 Aug 2 21:41 nagios.conf -rw-r--r-- 1 root root 674 May 10 17:42 php.conf -rw-r--r-- 1 root root 392 May 11 15:29 README -rw-r--r-- 1 root root 299 Feb 4 02:40 welcome.conf
登录名最好设置为nagios默认的nagiosadmin,文件为htpasswd.usersgit
[root@localhost ~]# vim /etc/httpd/conf.d/nagios.conf # SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER # # This file contains examples of entries that need # to be incorporated into your Apache web server # configuration file. Customize the paths, etc. as # needed to fit your system. ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" <Directory "/usr/local/nagios/sbin"> # SSLRequireSSL Options ExecCGI AllowOverride None <IfVersion >= 2.3> <RequireAll> Require all granted # Require host 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </RequireAll> </IfVersion> <IfVersion < 2.3> [root@localhost ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin
tar zxvf nagios-plugins-2.1.2.tar.gz cd nagios--p cd nagios-plugins-2.1.2 ./configure --prefix=/usr/local/nagios/ make && make install
[root@localhost ~]# /etc/init.d/httpd start [root@localhost ~]# /etc/init.d/nagios start [root@localhost ~]# chkconfig httpd on [root@localhost ~]# chkconfig nagios on
登录网页localhost/nagios输入用户名和密码进入网站
./configure make all make install-plugin make install-daemon make install-daemon-config make install-xinetd
在only from处添加监控主机的IP地址
[root@localhost nrpe-2.13]# vim /etc/xinetd.d/nrpe # default: on # description: NRPE (Nagios Remote Plugin Executor) service nrpe { flags = REUSE socket_type = stream port = 5666 wait = no user = nagios group = nagios server = /usr/local/nagios/bin/nrpe server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd log_on_failure += USERID disable = no only_from = 127.0.0.1,192.168.10.7 }
[root@localhost nrpe-2.13]# /etc/init.d/xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] [root@localhost nrpe-2.13]# netstat -lntup | grep 5666 tcp 0 0 :::5666 :::* LISTEN 26483/xinetd
[root@server2 ~]# yum install gcc openssl openssl-devel xinetd unzip -y
[root@server2 ~]# ntpdate cn.pool.ntp.org 2 Aug 22:18:37 ntpdate[1466]: step time server 120.25.108.11 offset 146310.412101 sec
[root@server2 ~]# mkdir /usr/local/nagios [root@server2 ~]# useradd nagios -s /sbin/nologin -M [root@server2 ~]# chown nagios:nagios /usr/local/nagios/ [root@server2 ~]# ll -d /usr/local/nagios/ drwxr-xr-x 2 nagios nagios 4096 Aug 2 22:19 /usr/local/nagios/
[root@server2 nagios-plugins-2.1.2]# tar zxvf nagios-plugins-2.1.2.tar.gz [root@server2 nagios-plugins-2.1.2]# cd nagios-plugins-2.1.2 [root@server2 nagios-plugins-2.1.2]# ./configure --prefix=/usr/local/nagios/ [root@server2 nagios-plugins-2.1.2]# make && make install
./configure make all make install-plugin make install-daemon make install-daemon-config make install-xinetd
在only from处添加监控主机的IP地址
[root@localhost nrpe-2.13]# vim /etc/xinetd.d/nrpe # default: on # description: NRPE (Nagios Remote Plugin Executor) service nrpe { flags = REUSE socket_type = stream port = 5666 wait = no user = nagios group = nagios server = /usr/local/nagios/bin/nrpe server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd log_on_failure += USERID disable = no only_from = 192.168.10.7 }
[root@localhost nrpe-2.13]# /etc/init.d/xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] [root@localhost nrpe-2.13]# netstat -lntup | grep 5666 tcp 0 0 :::5666 :::* LISTEN 26483/xinetd
generated by haroopad