nagios

nagios 安装
https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source-96.html#CentOS

sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix

cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.2.tar.gz
tar xzf nagioscore.tar.gz

cd /tmp/nagioscore-nagios-4.4.1/
./configure


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: /var/run/nagios.lock
Check result directory: /usr/local/nagios/var/spool/checkresults
Init directory: /etc/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /usr/sbin/sendmail
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):

 

make all

*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with testing or installing Nagios as follows (type
'make' without any arguments for a list of all possible options):

make test
- This runs the test suite

make install
- This installs the main program, CGIs, and HTML files

make install-init
- This installs the init script in /etc/init.d

make install-daemoninit
- This will initialize the init script
in /etc/init.d

make install-groups-users
- This adds the users and groups if they do not exist

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


*** Support Notes *******************************************

If you have questions about configuring or running Nagios,
please make sure that you:

- Look at the sample config files
- Read the documentation on the Nagios Library at:
https://library.nagios.com

before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you. This might include:

- What version of Nagios you are using
- What version of the plugins you are using
- Relevant snippets from your config files
- Relevant error messages from the Nagios log file

For more information on obtaining support for Nagios, visit:

https://support.nagios.com

*************************************************************

Enjoy.

yum install httpd

make install-groups-users
groupadd -r nagios
useradd -g nagios nagios
usermod -a -G nagios apache

make install
*** Main program, CGIs and HTML files installed ***

You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

make install-init
- This installs the init script in /etc/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

===== CentOS 5.x / 6.x | RHEL 5.x / 6.x | Oracle Linux 5.x / 6.x =====
make install-daemoninit
chkconfig --level 2345 httpd on
===== CentOS 7.x | RHEL 7.x | Oracle Linux 7.x =====
make install-daemoninit
systemctl enable httpd.service


make install-commandmode
make install-config
make install-webconf


===== CentOS 5.x / 6.x | RHEL 5.x / 6.x | Oracle Linux 5.x / 6.x =====
iptables -I INPUT -p tcp --destination-port 80 -j ACCEPT
service iptables save
ip6tables -I INPUT -p tcp --destination-port 80 -j ACCEPT
service ip6tables save
===== CentOS 7.x | RHEL 7.x | Oracle Linux 7.x =====
firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --add-port=80/tcp --permanent

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
q123q123

Start Apache Web Server
===== CentOS 5.x / 6.x | RHEL 5.x / 6.x | Oracle Linux 5.x / 6.x =====
service httpd start
===== CentOS 7.x | RHEL 7.x | Oracle Linux 7.x =====
systemctl start httpd.service
Start Service / Daemon
This command starts Nagios Core.
===== CentOS 5.x / 6.x | RHEL 5.x / 6.x | Oracle Linux 5.x / 6.x =====
service nagios start
===== CentOS 7.x | RHEL 7.x | Oracle Linux 7.x =====
systemctl start nagios.service

 

nagios 插件下载

yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum install -y perl-Net-SNMP
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz

cd /tmp/nagios-plugins-release-2.2.1/
./tools/setup
./configure
make
make install


httpd服务监控处理
1添加index.html index.htm index.php之类的默认文件
2配置这个选项为 Options Indexs FollowSymLinks

nrpe安装

wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
tar xzf nrpe-3.2.1.tar.gz
cd nrpe-nrpe-3.2.1
./configure
make check_nrpe
make install-plugin
/usr/local/nagios/libexec/check_nrpe -H localhost

监控机配置

nagios 插件下载

yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release
yum install -y perl-Net-SNMP
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz

cd /tmp/nagios-plugins-release-2.2.1/
./tools/setup
./configure
make
make install


useradd nagios
groupadd nagios
usermod -a -G nagios nagios
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec

yum install xinetd -y

wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
tar xzf nrpe-3.2.1.tar.gz
cd nrpe-nrpe-3.2.1
./configure
make all
make install-groups-users
make install
make install-config
make install-inetd
make install-init

service xinetd restart
systemctl reload xinetd
systemctl enable nrpe && systemctl start nrpe
检查nrpe
netstat -ntlp|grep nrpe
/usr/local/nagios/libexec/check_nrpe -H localhost

iptables -I RH-Firewall-1-INPUT -p tcp -m tcp –dport 5666 -j ACCEPT
service iptables save

vi /usr/local/nagios/etc/nrpe.cfg
/usr/local/nagios/libexec/check_nrpe -H localhost
/usr/local/nagios/libexec/check_nrpe -H 10.10.6.51
/usr/local/nagios/libexec/check_nrpe -H 10.10.6.105 -c check_users
/usr/local/nagios/libexec/check_nrpe -H 10.10.6.105 -c check_load
/usr/local/nagios/libexec/check_nrpe -H 10.10.6.105 -c check_hda1
/usr/local/nagios/libexec/check_nrpe -H 10.10.6.105 -c check_total_procs
/usr/local/nagios/libexec/check_nrpe -H 10.10.6.105 -c check_zombie_procs

nrpe白名单设置
/usr/local/nagios/etc/nrpe.cfg
allowed_hosts=10.10.6.165
systemctl restart nrpe.service && systemctl restart xinetd.service


服务机配置添加主机

/usr/local/nagios/etc/objects/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}


/usr/local/nagios/etc/objects/templates.cfg
define host{
name ilannihost
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period workhours
notification_interval 120
notification_options d,u,r
contact_groups admins
register 0
}

define service{
name ilanniservice
use generic-service
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
register 0
}

 

mkdir /usr/local/nagios/etc/ilanni
vi /usr/local/nagios/etc/nagios.cfg
cfg_dir=/usr/local/nagios/etc/ilanni


vi 51.cfg
define host{
use ilannihost
host_name ilanni
alias test_NRPE
address 10.10.6.51
check_command check-host-alive
}

define service{
use ilanniservice
host_name ilanni
service_description nrpe_load
check_command check_nrpe!check_load
}

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios reload


https://www.cnblogs.com/ilanni/p/4366232.html

posted @ 2018-08-30 21:16  codeforu2  阅读(198)  评论(0编辑  收藏  举报