Nagios監(jiān)控工具
創(chuàng)新互聯(lián)成立于2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站制作、網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元鉛山做網(wǎng)站,已為上家服務(wù),為鉛山各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108不會(huì)顯示具體的值,僅顯示主機(jī)或服務(wù)的狀態(tài)
強(qiáng)大的報(bào)警功能
高度插件化
Nagios監(jiān)控主機(jī)/服務(wù)顯示的4種狀態(tài)
OK
WARNING
CRITICAL
UNKNOWN
Nagios對(duì)象:
主機(jī),主機(jī)組
服務(wù)/資源,服務(wù)組
聯(lián)系人,聯(lián)系人組
時(shí)間段
命令(模板--->應(yīng)用到某個(gè)被監(jiān)控對(duì)象,以實(shí)現(xiàn)監(jiān)控)
Nagios實(shí)現(xiàn)監(jiān)控的方式:
check_by_ssh
check_by_nrpe:專用于監(jiān)控Linux或Unix主機(jī)
check_by_nsclient++:用于監(jiān)控Windows主機(jī)
check_by_snmp
check_by_nsca:實(shí)現(xiàn)被動(dòng)方式的nagios,由被監(jiān)控對(duì)象主動(dòng)向nagios發(fā)送狀態(tài)信息
check_by_xyz:自定義監(jiān)控方式/腳本
安裝nagios
1、安裝依賴的軟件
# yum install -y httpd php php-mysql mysql-devel mysql
2、創(chuàng)建nagios運(yùn)行需要的用戶和組
# groupadd nagcmd
# useradd -G nagcmd nagios
將運(yùn)行apache進(jìn)程的用戶加入到nagcmd組中
# usermod -a -G nagcmd apache
3、安裝nagios
# tar zxf nagios-3.3.1.tar.gz
# cd nagios
# ./configure --with-command-group=nagcmd --enable-event-broker --sysconfdir=/etc/nagios
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconf
創(chuàng)建一個(gè)登錄nagios web頁(yè)面的用戶,這個(gè)用戶賬號(hào)在以后通過web登錄nagios時(shí)使用
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
啟動(dòng)httpd服務(wù)
# service httpd start
4、安裝nagios-plugins插件
# tar zxf nagios-plugins-1.5.tar.gz
# cd nagios-plugins-1.5
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make && make install
5、啟動(dòng)nagios服務(wù)
# chkconfig --add nagios
# service nagios start
6、訪問nagios
http://10.1.1.2/nagios
配置nagios
nagios配置文件保存在/etc/nagios目錄下
nagios插件目錄
/usr/local/nagios/libexec
nagios監(jiān)控windows主機(jī)
SNMP
NSClient++
nagios通過check_nt插件與windows NSClient++通信
NSClient++可提供check_nt,check_nrpe及NSCA的能力
NSClient++監(jiān)聽在12489/tcp端口與check_nt插件通信
配置check_nt與NSClient++監(jiān)控windows主機(jī)
1、定義命令command
# vim /etc/nagios/objects/commands.cfg
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
}
2、定義主機(jī)host及服務(wù)service
# vim /etc/nagios/objects/windows.cfg
define host{
use windows-server ; Inherit default values from a template
host_name winhost; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 10.1.1.254 ; IP address of the host
}
define service{
use generic-service
host_name winhost
service_description Uptime
check_command check_nt!UPTIME
}
3、啟用主機(jī)配置文件
# vim /etc/nagios/nagios.cfg
cfg_file=/etc/nagios/objects/windows.cfg
4、檢測(cè)配置文件語(yǔ)法,并重啟nagios服務(wù)
# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
# service nagios restart
瀏覽器訪問http://10.1.1.2/nagios查看監(jiān)控狀態(tài)數(shù)據(jù)
配置check_nrpe監(jiān)控Linux及windows主機(jī)
監(jiān)控端通過check_nrpe與被監(jiān)控端nrpe進(jìn)程通信
nrpe監(jiān)聽在5666/tcp端口
監(jiān)控端、被監(jiān)控端都需要安裝nrpe addon,被監(jiān)控端需要啟動(dòng)nrpe服務(wù)
一、監(jiān)控Linux 主機(jī)10.1.1.1
1、在被監(jiān)控主機(jī)上安裝nrpe并配置
1)創(chuàng)建nagios用戶
# useradd -s /sbin/nologin nagios
2)nrpe依賴于nagios-plugins,安裝nagios-plugins
# tar zxf nagios-plugins-1.4.14.tar.gz
# cd nagios-plugins-1.4.14
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make all
# make install
3)安裝nrpe
# tar zxf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
4)配置nrpe
# vim /usr/local/nagios/etc/nrpe.cfg
log_facility=daemon
pid_file=/var/run/nrpe.pid
server_port=5666
server_address=10.1.1.1
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=10.1.1.2
command_timeout=60
定義監(jiān)控本地資源的命令
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda2
command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda3
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
5)編寫啟動(dòng)nrpe服務(wù)腳本
# vim /etc/rc.d/init.d/nrpe
#!/bin/bash
#
# chkconfig: 2345 88 12
# description: NRPE DAEMON
NRPE=/usr/local/nagios/bin/nrpe
NRPECONF=/usr/local/nagios/etc/nrpe.cfg
case $1 in
start)
echo -n "Starting NRPE damon...."
$NRPE -c $NRPECONF -d
echo "Done..."
;;
stop)
echo -n "Stopping NRPE daemon...."
pkill -u nagios nrpe
echo "Done...."
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: $0 { start | stop | restart }"
;;
esac
exit 0
# chmod +x /etc/rc.d/init.d/nrpe
# chkconfig --add nrpe
# service nrpe start
# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 10.1.1.1:5666 0.0.0.0:* LISTEN 6826/nrpe
2、在監(jiān)控端安裝nrpe
1)安裝nrpe
# tar zxf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
# make all
# make install-plugin
安裝完成后,在/usr/local/nagios/libexec目錄下會(huì)產(chǎn)生check_nrpe插件
通過以下命令可測(cè)試插件是否工作正常
# ./check_nrpe -H 10.1.1.1
NRPE v2.15
3、配置監(jiān)控Linux主機(jī)
1)定義命令command
# vim /etc/nagios/objects/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
2)定義主機(jī)host及服務(wù)service
# cp /etc/nagios/objects/windows.cfg /etc/nagios/objects/linux.cfg
# vim /etc/nagios/objects/linux.cfg
define host{
use linux-server ; Inherit default values from a template
host_name linuxhost; The name we're giving to this host
alias My Linux Server ; A longer name associated with the host
address 10.1.1.1 ; IP address of the host
}
define service{
use generic-service
host_name linuxhost
service_description Users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name linuxhost
service_description Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name linuxhost
service_description SDA1
check_command check_nrpe!check_sda1
}
define service{
use generic-service
host_name linuxhost
service_description SDA2
check_command check_nrpe!check_sda2
}
define service{
use generic-service
host_name linuxhost
service_description SDA3
check_command check_nrpe!check_sda3
}
define service{
use generic-service
host_name linuxhost
service_description Zombie procs
check_command check_nrpe!check_zombie_procs
}
define service{
use generic-service
host_name linuxhost
service_description total procs
check_command check_nrpe!check_total_procs
}
check_nrpe!check_total_procs
!后面為被監(jiān)控端定義好的命令名稱
3)啟用主機(jī)配置文件
# vim /etc/nagios/nagios.cfg
cfg_file=/etc/nagios/objects/linux.cfg
4)檢測(cè)配置文件語(yǔ)法,并重啟nagios服務(wù)
# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
# service nagios restart
在10.1.1.1上分別安裝web及mysql服務(wù),配置監(jiān)控端10.1.1.2監(jiān)控這兩個(gè)服務(wù)
1、在10.1.1.1上安裝web及mysql
# yum install -y httpd mysql-server
需要在mysql服務(wù)器上創(chuàng)建允許遠(yuǎn)程登錄的用戶
2、編輯command.cfg分別定義監(jiān)控web及mysql服務(wù)的命令
# vim /etc/nagios/objects/commands.cfg
define command{
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}
define command{
command_name check_mysql
command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$
}
3、編輯linux.cfg配置文件,定義web及mysql服務(wù)
# vim /etc/nagios/objects/linux.cfg
define service{
use generic-service
host_name linuxhost
service_description Web Server
check_command check_http
}
define service{
use generic-service
host_name linuxhost
service_description Mysql Server
check_command check_mysql!admin!redhat
}
4、檢測(cè)配置文件語(yǔ)法,并重啟nagios服務(wù)
# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
# service nagios restart
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
當(dāng)前名稱:Nagios監(jiān)控工具-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://muchs.cn/article20/cdscco.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營(yíng)銷、電子商務(wù)、響應(yīng)式網(wǎng)站、建站公司、企業(yè)網(wǎng)站制作、微信小程序
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)