Nagios是一款開源的免費網絡監視工具,能有效監控Windows、Linux和Unix的主機狀態,交換機路由器等網絡設備,打印機等。在系統或服務狀態異常時發出郵件或短信報警第一時間通知網站運維人員,在狀態恢復後發出正常的郵件或短信通知。php
NSClient:Windows 7監控插件mysql
NRPE是監控軟件nagios的一個擴展,它被用於被監控的服務器上,向nagios監控平臺提供該服務器的一些本地的狀況。例如,cpu負載、內存使用、硬盤使用等等。NRPE能夠稱爲nagios的for linux 客戶端。linux
1.安裝軟件:ios
yum install -y gcc*web
yum install -y httpd mysql mysql-server mysql-devel php php-mysql glibc glibc-common *gd*sql
2.添加用戶:瀏覽器
3.編譯安裝nagios:服務器
這次安裝使用的軟件包是 nagios.iso網絡
tar -xvf nagios-3.3.1.tar.gz -C /root/運維
而後進入nagios目錄下
./configure --with-command-group=nagcmd --enable-event-broker
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
4.生成密碼配置文件:
開啓Apache服務
5.瀏覽器查看:
6.安裝插件管理器nagios-plugins:
tar -xvf nagios-plugins-1.4.14.tar.gz -C /root/
進入目錄編譯安裝(nagios-plugins-1.4.14)
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-mysql --enable-perl-modules
make && make install
檢查配置文件是否有錯誤:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重啓nagios服務
此時再去瀏覽器檢查:
Windows主機的監控:
7.Windows安裝NSClient:
服務器設置監控Windows:
檢測並從新啓動nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios restart
瀏覽器再查看:
Linux客戶機監控:
8.Linux客戶端的監控:
在Linux客戶的上面:
安裝環境支持:
yum install -y gcc* openssl openssl-devel
編譯安裝nagios-plugins
tar -xvf nagios-plugins-1.4.14.tar.gz
須要建立用戶
useradd nagios
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
編譯安裝nrpe-2.8.1.tar.gz
./configure --enable-ssl --with-ssl-lib=/usr/lib
回到服務器端:
安裝nagios-plugins(已安裝)
安裝nrpe
tar -xvf nrpe-2.8.1.tar.gz -C /root/
./configure --enable-ssl --with-ssl-lib=/usr/lib
make all
make install-plugin
不用啓用daemon和daemon-config
define host{
use linux-server
host_name nagios
address 192.168.115.174
}
define service{
use generic-service
host_name nagios
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name nagios
service_description check-users
check_command check_nrpe!check_users
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios restart
再檢查瀏覽器:
9.服務的監控:
Linux客戶端:
安裝軟件:
yum install -y mysql mysql-server
service mysqld start
mysqladmin -uroot password ‘123456’
服務器端:
測試鏈接:
/usr/local/nagios/libexec/check_mysql -H 192.168.115.174 -u nagios -d nagios -p 123456
define host{
use linux-server
host_name Mysql
address 192.168.115.174
}
define service{
host_name Mysql
check_period 24x7
max_check_attempts 2
normal_check_interval 1
retry_check_interval 1
contact_groups admins
notification_interval 5
notification_period 24x7
notification_options w,u,c,r
check_command check_mysql
service nagios restart