Nagios+PNP4nagios+rrdtool监控平台建立-创新互联
Nagios+ PNP4nagios + rrdtool 监控平台建立
我们提供的服务有:成都网站设计、成都网站制作、微信公众号开发、网站优化、网站认证、可克达拉ssl等。为上千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的可克达拉网站制作公司一、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
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站栏目:Nagios+PNP4nagios+rrdtool监控平台建立-创新互联
地址分享:http://azwzsj.com/article/dishci.html