标签:apache src dex 地址 服务 host baidu man 下载
NagiosNagios是一款LInux上成熟的监视系统运行状态和网络信息的开源IT基础设施监控系统。Nagios能够监控所指定的本地或远程主机及服务,同时提供异常通知、事件处理等功能。它可以运行在Linux平台,同时还提供了基于浏览器的web界面,以方便系统管理人员查看系统的运行状态,网络状态,各种系统问题及日志异常等。
Nagios的功能是监控服务和主机,但是其自身并不包含这些功能,所有的监控、检测功能都是通过各种插件来完成的。启动Nagios后,它会周期性地自动调用插件去检测服务器状态,同时Nagios会维持一个队列,所有插件返回的状态信息都进入队列,Nagios每次都从队列读取信息,进行处理后,再把状态结果通过Web界面显示出来,这是被动模式。常用于监控主机的系统资源,比如系统负载、磁盘使用率、内存使用率、网络状态、系统进程数等。另一种是主动模式,主要是Nagios服务器主动去获取数据,常用于探测URL的监控和服务的状态监控。
主机名 | 操作系统 | IP地址 | 服务名 |
---|---|---|---|
nagios | centos7.4 | 192.168.96.81 | nagios-4.3.4.tar.gz、nagios-cn.4.3.4.tar.gz、nagios-plugins-2.2.1.tar.gz、pnp4nagios-0.6.26.tar.gz |
www | centos7.4 | 192.168.96.11 | nrpe-3.1.0.tar.gz |
客户端 | windows 10 | 192.168.96.2 | 网页浏览器 |
nagios/www服务器均关闭防火墙及SElinux功能
setenforece 0
systemctl stop firewalld
软件包下载 密码:yfdi
yum install -y wget httpd php php-devel php-gd gcc glibc glibc-common gd gd-devel make net-snmp
useradd -s /sbin/nologin nagios
mkdir /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/
#解压
tar zxvf nagios-4.3.4.tar.gz
cd nagios-4.3.4
#配置
./configure --prefix=/nagios --with-command-group=nagios --with-nagios-group=nagios
#编译安装
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers /usr/local/nagios/libexec/
tar zxvf nagios-plugins-2.2.1.tar.gz
cd nagios-plugins-2.2.1/
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make && make install
tar zxvf nagios-cn.4.3.4.tar.gz
cd nagios-4.3.4/
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
vim /etc/httpd/conf/httpd.conf
Listen 192.168.96.81:80 #41行,监听地址及端口
#Listen 80 #42行,注释该行
User nagios #66行,用户为nagios
Group nagios #67行,用户组为nagios
ServerName www.test01.com:80 #95行,域名
DirectoryIndex index.html index.php #164行,主页类型添加index.php类型
AddType application/x-httpd-php .php #285行,添加php支持
systemctl enable httpd
systemctl start httpd
netstat -tunlp
systemctl enable nagios
systemctl start nagios
systemctl status nagios
yum install perl-Time-HiRes rrdtool rrdtool-perl -y
mkdir /usr/local/nagios/pnp4nagios
tar zxvf pnp4nagios-0.6.26.tar.gz
cd pnp4nagios-0.6.26/
./configure --prefix=/usr/local/nagios/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios
make all
make fullinstall
cp -R contrib/ssi /usr/local/nagios/pnp4nagios/share/
cd /usr/local/nagios/pnp4nagios/etc/
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
cd pages/
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands/
mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
mv check_nrpe.cfg-sample check_nrpe.cfg
mv check_nwstat.cfg-sample check_nwstat.cfg
chkconfig npcd on
service npcd start
cd /usr/local/nagios/pnp4nagios/etc/
vim /usr/local/nagios/pnp4nagios/etc/process_perfdata.cfg
#调整日志级别
LOG_LEVEL = 2
vim /usr/local/nagios/etc/nagios.cfg
process_performance_data=1
enable_environment_macros=1
增加如下(如果不直接增加也可以去掉注释自己改)
service_perfdata_command=process-service-perfdata
host_perfdata_command=process-host-perfdata
host_perfdata_file=/usr/local/nagios/pnp4nagios/var/host-perfdata
service_perfdata_file=/usr/local/nagios/pnp4nagios/var/service-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
host_perfdata_file_mode=a
service_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
service_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file
service_perfdata_file_processing_command=process-service-perfdata-file
vim /usr/local/nagios/etc/objects/commands.cfg
把原有的两个注释掉,加入下面的
define command{
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/nagios/pnp4nagios/libexec/process_perfdata.pl
}
define command{
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/nagios/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
define command{
command_name process-service-perfdata-file
command_line /usr/local/nagios/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/service-perfdata
}
define command{
command_name process-host-perfdata-file
command_line /usr/local/nagios/pnp4nagios/libexec/process_perfdata.pl --bulk=/usr/local/pnp4nagios/var/host-perfdata
}
vim /usr/local/nagios/etc/objects/templates.cfg
define host {
name host-pnp
action_url /pnp4nagios/share/index.php/graph?host=$HOSTNAME$
register 0
}
define service {
name srv-pnp
action_url /pnp4nagios/share/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
systemctl restart nagios
systemctl restart httpd
cd /usr/local/nagios/pnp4nagios/share/
rm -rf install.php
chown -R nagios.root /var/lib/php/session/
标签:apache src dex 地址 服务 host baidu man 下载
原文地址:http://blog.51cto.com/10316297/2167126