您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關Redhat如何配置nagios的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
配置被監控機
本文講述的是:Redhat配置nagios。返回大綱。
配置linux被監控機(客戶端)
需要先安裝gcc、openssl、openssl-devel。
先添加一個用戶
[root@localhost ~]# useradd nagios [root@localhost ~]# passwd nagios //123456
Changing password for user nagios.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
安裝nagios-plugins-1.4.15.tar.gz
[root@localhost ~]# tar -zxvf nagios-plugins-1.4.15.tar.gz [root@localhost ~]# cd nagios-plugins-1.4.15 [root@localhost nagios-plugins-1.4.15]# ./configure --prefix=/usr/local/nagios [root@localhost nagios-plugins-1.4.15]# make [root@localhost nagios-plugins-1.4.15]# make install [root@localhost nagios-plugins-1.4.15]# chown nagios.nagios /usr/local/nagios [root@localhost nagios-plugins-1.4.15]# chown -R nagios.nagios /usr/local/nagios/libexec
安裝nrpe
[root@localhost ~]# tar -zxvf nrpe-2.8b1 [root@localhost ~]# cd nrpe-2.8b1 [root@localhost nrpe-2.8b1]# ./configure [root@localhost nrpe-2.8b1]# make all [root@localhost nrpe-2.8b1]# make install-plugin [root@localhost nrpe-2.8b1]# make install-daemon [root@localhost nrpe-2.8b1]# make install-daemon-config
編輯nrpe.cfg
[root@localhost ~]# vi /usr/local/nagios/etc/nrpe.cfg
查找如下加上nagios服務器ip地址
allowed_hosts=127.0.0.1,10.155.2.65
保存后,用如下命令啟動nrpe和添加到開機啟動中
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d echo '/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d &> /dev/null' >> /etc/rc.local
驗證
[root@localhost etc]# /usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.8b1
[root@localhost etc]# netstat -atulnp | grep 'nrpe'
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 24823/nrpe
如果不正常見文章***的問題和解決(1)
這里客戶端的配置已經完成,已經可以到nagios服務器配置command.cfg監控,但是這里介紹另一種方法在編輯nrpe.cfg配置命令,nagios服務器會調用客戶端的nrpe命令
vi /usr/local/nagios/etc/nrpe.cfg 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_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 command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
下面這條是自己添加
command[check_ping81]=/usr/local/nagios/libexec/check_ping -H 10.155.0.1 -w 100.0,20% -c 500.0,60%# command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1 #command[命令名稱]=命令定義
具體使用見幫助
[root@localhost nagios]# ls bin etc include libexec share [root@localhost nagios]# pwd /usr/local/nagios [root@localhost nagios]# libexec/check_ping -h check_ping v1.4.15 (nagios-plugins 1.4.15) Copyright (c) 1999 Ethan Galstad Copyright (c) 2000-2007 Nagios Plugin Development Team Use ping to check connection statistics for a remote host.
Usage: check_ping -H -w ,% -c ,% [-p packets] [-t timeout] [-4|-6] Options: -h, --help Print detailed help screen -V, --version Print version information -4, --use-ipv4 Use IPv4 connection -6, --use-ipv6 Use IPv6 connection -H, --hostname=HOST host to ping -w, --warning=THRESHOLD warning threshold pair -c, --critical=THRESHOLD critical threshold pair -p, --packets=INTEGER number of ICMP ECHO packets to send (Default: 5) -L, --link show HTML in the plugin output (obsoleted by urlize) -t, --timeout=INTEGER Seconds before connection times out (default: 10)
配置nrpe.cfg后,必須重啟nrpe。重啟方法(殺死進程,在重啟),否則更改不會生效
[root@localhost ~]# ps aux|grep nrpe nagios 3327 0.0 0.0 4880 924 ? Ss Sep02 0:03 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d root 22293 0.0 0.0 3908 648 pts/0 R+ 11:07 0:00 grep nrpe [root@localhost ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
服務器端
測試與客戶端連接,如下表示正常
[root@localhost nrpe-2.8b1]# /usr/local/nagios/libexec/check_nrpe -H 10.155.2.81 NRPE v2.8b1
下面表示不正常,見問題與解決(2)
[root@localhost nrpe-2.8b1]# /usr/local/nagios/libexec/check_nrpe -H 10.155.2.81 Connection refused by host
配置nagios.cfg,增加一條記錄
[root@localhost ~]# vi /usr/local/nagios/etc/nagios.cfg cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg cfg_file=/usr/local/nagios/etc/objects/commands.cfg ;此前面已經設置過
配置nagios.cfg,增加一條記錄
vi /usr/local/nagios/etc/objects/commands.cfg #在后面增加追加如下內容#check nrpedefine command{command_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}mylinux
.cfg在目錄中沒有,需要自己添加
[root@localhost ~]# touch /usr/local/nagios/etc/objects/mylinux.cfg
#---------------------------------------------此段定義主機--------------------------------------------------------
define host{ use linux-server host_name 10.155.2.81-cacti alias mylinux address 10.155.2.81 }
#--------------------------------下面定義服務器,也就是監控項------------------------------------------
define service{ use generic-service host_name 10.155.2.81-cacti service_description Swap Usage check_command check_nrpe!check_swap } define service{ use generic-service host_name 10.155.2.81-cacti service_description Current Load check_command check_nrpe!check_load } define service{ use generic-service host_name 10.155.2.81-cacti service_description Partition Usage check_command check_nrpe!check_hda1 } define service{ use generic-service host_name 10.155.2.81-cacti service_description Current Users check_command check_nrpe!check_users } define service{ use generic-service host_name 10.155.2.81-cacti service_description Total Processes check_command check_nrpe!check_total_procs } define service{ use generic-service host_name 10.155.2.81-cacti service_description PING check_command check_nrpe!check_ping81 }
重啟nagios,ie瀏覽(圖3)
感謝各位的閱讀!關于“Redhat如何配置nagios”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。