Nagios監控主機筆記(一)
參考資料
nagios 監控目的
即時瞭解服務器運行情況,服務運行狀況,經過mail、手機短信、聲音報警通知管理員,以便處理問題
。
1、nagios 監控分爲二個部份:
1)、nagios服務器端(如下簡稱server端)
server端所需軟件包:
Apache、nagios-3.0.六、nrpe-2.8.一、nagios-plugins-1.4.1三、sendmail、nagios-mysql-plugins、nagios-mysql-plugins-0.3.tar.gz、perl等
2)、監控服務器端(如下簡稱client端)
client端所需軟件包:
nrpe-2.8.一、nagios-plugins-1.4.13等
NRPE
是
nagios
的一個擴展,它被用於被監控的服務器上,向
nagios
監控平臺提供該服務器的一些本地的狀況。例如,
cpu
負載、內存使用、硬盤使用等等。
nagios-plugins是nagios監控服務器的插件
nagios-mysql-plugins、nagios-mysql-plugins 是監控mysql服務器的插件
2、nagios服務器的安裝
1
)、nagios安裝
mkdir /usr/local/nagios
tar zxvf nagios-3.0.6
cd nagios
./configure –prefix=/usr/local/nagios ----with-nagios-user=nag ios --with-nagios-group=nagios
make all
make install
make install-commandmode
make install-config
2)、Apache安裝與配置
tar zxvf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure --prefix=/usr/local/apache
make
make install
配置nagios以下
在apache的配置httpd.conf中加入
include conf/nagios.conf
nagios.conf內容以下
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DirectoryIndex index.html index.php
Alias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AddHandler cgi-script cgi pl
AllowOverride None
Order allow,deny
Allow from all
# AuthName "Nagios Access"
# AuthUserFile /usr/local/nagios/etc/htpasswd
# Require valid-user
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
# AuthName "nagios Access"
# AuthUserFile /usr/local/nagios/etc/htpasswd
# Require valid-user
</Directory>
</VirtualHost>
建立http驗證用戶htpasswd文件,用戶名爲test,密碼能夠隨便設置
root@nagios#htpasswd -c /usr/local/nagios/etc/htpasswd test
New password:
Re-type new password:
Adding password for user test
3)、nagios-plugins安裝
tar zxvf nagios-plugins-1.4.13
cd nagios-plugins
./configure --prefix=/usr/local/nagios
#安裝目錄選擇/usr/local/nagios,由於該目錄下的libexec目錄下的插件是nagios監控所須要的
make && make install
4)、檢查遠程服務器nrpe 鏈接,可顯示版本號。若是能正確顯示版本號,說明nrpe 服務能正常鏈接.
/usr/local/nrpe/libexec/check_nrpe -H 192.168.1.22
NRPE v2.12
3、client服務端的安裝與配置
1)、nagios-plugins安裝
tar zxvf nagios-plugins-1.4.13
cd nagios-plugins
./configure --prefix=/usr/local/nagios
make && make install
2)、nrpe安裝
root@client#mkdir /usr/local/nrpe
tar zxvf nrpe-2.8.1
cd nagios
./configure --prefix=/usr/local/nrpe
make && make install
3)、windows客戶端的安裝nsclient