大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Nagios+ PNP4nagios + rrdtool监控平台建立
我们提供的服务有:网站设计、成都网站建设、微信公众号开发、网站优化、网站认证、昆都仑ssl等。为上1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的昆都仑网站制作公司
一、Nagios安装
1,安装基础支持套件
yuninstall -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel httpd php*
2,创建nagios用户和用户组
useradd-s /sbin/nologin nagios
mkdir/usr/local/nagios
chown-R nagios.nagios /usr/local/nagios
3,编译安装Nagios
wgethttp://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz
tarzxvf nagios-3.5.0.tar.gz
cdnagios
./configure--prefix=/usr/local/nagios
makeall
makeinstall
makeinstall-init
makeinstall-config
makeinstall-commandmode
makeinstall-webconf
验证程序是否被正确安装
切换目录到安装路径(这里是/usr/local/nagios),看是否存在etc、bin、sbin、share、var这五个目录,如果存在则可以表明程序被正确的安装到系统了。Nagios各个目录用途说明如下:
binNagios可执行程序所在目录
etc Nagios配置文件所在目录
sbin NagiosCGI文件所在目录,也就是执行外部命令所需文件所在的目录
share Nagios网页文件所在的目录
libexecNagios外部插件所在目录
var Nagios日志文件、lock等文件所在的目录
var/archives Nagios日志自动归档目录
var/rw 用来存放外部命令文件的目录
4,安装Nagios plugins
wgethttp://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-2.0.2.tar.gz
tarzxvf nagios-plugins-2.0.2.tar.gz
cdnagios-plugins-2.0.2
./configure--prefix=/usr/local/nagios -with-nagios-user=nagios --with-nagios-group=nagios
make&& make install
5,安装NRPE
wgethttp://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.15.tar.gz
tarzxvf nrpe-2.15.tar.gz
cdnrpe-2.15
./configure
makeall
makeinstall-plugin
makeinstall-daemon
makeinstall-daemon-config
6,创建nagios web登陆账号
htpasswd-c /usr/local/nagios/etc/htpasswd.users test
7,检查其主配置文件的语法是否正确:
/usr/local/nagios/bin/nagios-v /usr/local/nagios/etc/nagios.cfg
二、安装 rrdtool+pnp4nagios
1,rrdtool安装
yum-y install http://support.mathias-kettner.de/1.2.2b4/omd-1.2.2b4.dmmk-rh70-30.x86_64.rpm
yum-y install perl-rrdtool rrdtool
yuminstall libxml2 libxml2-devel
2,查看http配置
greprewrite /etc/httpd/conf/httpd.conf
LoadModulerewrite_module modules/mod_rewrite.so
3,下载安装pnp4nagios
wgethttp://cdnetworks-kr-1.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.22.tar.gz
tarzxvf pnp4nagios-0.6.22.tar.gz
cdpnp4nagios-0.6.22
./configure--with-nagios-user=nagios --with-nagios-group=nagcmd
makeall
makeinstall
makeinstall-webconf
makeinstall-init
4,创建配置文件
cd/usr/local/pnp4nagios/etc
mvmisccommands.cfg-sample misccommands.cfg
mvnagios.cfg-sample nagios.cfg
mvnpcd.cfg-sample npcd.cfg
mvprocess_perfdata.cfg-sample process_perfdata.cfg
mvrra.cfg-sample rra.cfg
cdpages
mvweb_traffic.cfg-sample web_traffic.cfg
cd../check_commands
mvcheck_all_local_disks.cfg-sample check_all_local_disks.cfg
mvcheck_nrpe.cfg-sample check_nrpe.cfg
mvcheck_nwstat.cfg-sample check_nwstat.cfg
5,重启服务
/etc/init.d/npcdrestart
6,修改 nagios的配置文件
cd/usr/local/nagios/etc
vimnagios.cfg
打开注视项:
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
修改 commands.cfg
cd/usr/local/nagios/etc/objects
vimcommands.cfg
添加
'process-host-perfdata'command definition
definecommand{
command_name process-host-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
'process-service-perfdata'command definition
definecommand{
command_name process-service-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
添加小太阳模版
nagios$> vim templates.cfg
在最后添加
definehost {
name host-pnp
action_url/pnp4nagios/graph?host=$HOSTNAME$&srv
register 0
}
defineservice {
name srv-pnp
action_url/pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
7,修改 hosts.cfg和 services.cfg
cd/usr/local/nagios/etc/
修改hosts.cfg
nagios$> vim hosts.cfg
definehost{
use linux-server,host-pnp
host_name test
alias test
address 192.168.1.111
}
#修改 services.cfg
defineservice{
use local-service,srv-pnp
host_name test
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
8,重启 nagios服务
/etc/init.d/nagiosrestart