nagios監控搭建

系統:RHEL6.5php

環境:selinux—>disabled iptables-->stopmysql

軟件:nagios-3.3.1.tar.gz,nagios-plugins-1.4.15.tar.gz, nrpe-2.12.tar.gzlinux

準備:時間與標準時間服務器相同ios

依賴關係:web

yum install –y httpd gcc glibc glibc-common gd gd-devel php mysql mysql-server mysql-develsql

添加nagios運行所需的用戶和組:apache

groupadd nagcmdvim

useradd –G nagcmd nagios瀏覽器

passwd nagios服務器

添加apache到nagcmd組,以便經過web Interface操做nagios有足夠權限:

usermod -a –G nagcmd apache

編譯安裝nagios:

tar zxf nagios-3.3.1.tar.gz

cd nagios-3.3.1

./configure --sysconfdir=/etc/nagios --with-command-group=nagcmd --enable-event-broker #event-broker爲NDOUtils準備的。 #sysconfdir=/etc/nagios:配置文件放在/etc/nagios(自己在/usr/local下)

make all

make install ##安裝nagios

make isntall-int ##安裝nagios的init腳本

make install-commandmode ##設置權限

make install-config ##安裝生成配置文件

修改email接收nagios報警信息的郵件,默認本機nagios:

vim /etc/nagios/objects/contacts.cfg

email		nagios@localhost	##默認是這個設置。

在apache配置文件目錄(conf.d)中建立nagios的web程序配置文件:

make install-webconf

#在/etc/httpd/conf.d中生成nagios.conf,使apache識別nagios的目錄(/usr/local/nagios/share)

建立nagios登陸帳號程序,用於經過web登陸nagios認證:

htpasswd –c /etc/nagiso/htpasswd.users nagiosadmin #用戶名不要隨便改!

重啓httpd:

service httpd restart

編譯、安裝nagios-plugins:

tar zxf nagios-plugins-1.4.15.tar.gz

cd nagios-plugins-1.4.15

./configure --with-nagios-user=nagios --with-nagios-group=nagios

make

make install

重啓nagios:

service nagios restart

若是想在不關閉selinux時運行nagios,須執行:

chcon –R –t httpd_sys_content_t /usr/local/nagios/sbin

chcon –R –t httpd_sys_content_t /usr/local/nagios/share

#關閉了selinux就跳過這一步

在web中查看nagios:

瀏覽器輸入:localhost/nagios,輸入nagiosadmin密碼。

至此已實現監控本地主機!!!!

相關文章
相關標籤/搜索