服務器監控-nagios安裝篇

一:安裝前準備

nagios server:192.168.1.10

nagios client:192.168.1.11

該博文安裝nagios只使用nagios郵件報警功能,如需畫圖另外安裝cacti,或其他插件


二:安裝服務

在nagios server上操作:

安裝Apache+php

yum install httpd httpd-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml gcc glibc glibc-common gd gd-devel openssl openssl-devel


groupadd nagios

useradd nagios

useradd -G nagios nagios

usermod -G nagios apache


wget http://sourceforge.net/projects/nagios/?source=directory

tar zxvf nagios-3.2.0.tar.gz

cd nagios-3.2.0

./configure --prefix=/usr/local/nagios --with-command-group=nagios

make all

make install

make install-init

make install-config

make install-commandmode

make install-webconf


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

service httpd restart


nagios-plugins下載地址:www.nagios.org

tar zxvf nagios-plugins-1.4.14.tar.gz

cd nagios-plugins-1.4.14

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios

make && make install


wget http://sourceforge.net/projects/nagios-cn/files/latest/download

tar -xjf nagios-cn-3.2.3.tar.bz2

cd nagios-cn-3.2.3

 ./configure 

make all

make install


http://sourceforge.net/projects/nagios/files/nrpe-2.x/

tar zxvf nrpe-2.13.tar.gz 

cd nrpe-2.13

./configure

make all

make install-plugin


vi /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/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


在被監控主機上操作:

useradd -s /sbin/nologin nagios

tar zxvf nagios-plugins-1.4.14.tar.gz

cd nagios-plugins-1.4.14

./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios

make && make install


tar zxvf nrpe-2.13.tar.gz 

cd nrpe-2.13

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

make install-xinetd


yum install xinetd

vim /etc/xinetd.d/nrpe

將only_from = 後面加上監控端的地址192.168.1.10

確保/etc/services有nrpe 5666/tcp #NRPE這一行,沒有則添加

重啓xinetd服務,至此被監控端配置完畢

/usr/local/nagios/libexec/check_nrpe -H 被監控端的地址

如能顯示 “NRPE v2.12”,表明NRPE可以和被監控端正常通信


安裝完畢,接下來開始配置。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章