您好,登錄后才能下訂單哦!
Nagios+ PNP4nagios + rrdtool 監控平臺建立
一、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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。