linux下有2大監(jiān)控神器cacti+nagios,下面我把我自己搭建nagios的步驟記錄下來,以便以后需要的時候看。
首先安裝依賴包
#yum install -y httpd MySQL mysql-devel mysql-server php php-mysql gcc gcc-c++ gblic gblic-devel gd gd-devel openssl-devel
添加nagios用戶,用戶組
#groupadd nagcmd
#useradd nagios
#usermod -a -G nagcmd nagios
#usermod -a -G nagcmd daemon(http的user)
下載nagios安裝包,解壓
開始編譯
#./configure --prefix=/etc/nagios \
>--with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--enable-event-broker
#make all
#make install
#make install-init
#make install-commandmode
#make install-config
#make install-webconf(編譯安裝的httpd會出現(xiàn)錯誤)
安裝nagios-plugins
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-mysql=/path/to/mysql(監(jiān)控mysql必須添加此選項)
#make && make install
下面開始安裝nrpe
首先確定開發(fā)環(huán)境
#yum grouplist
確定有Development tools和Development Libraries
如果沒有就安裝
#yum groupinstall -y "Development tools" "Development Libraries"
開始安裝nrpe
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-nrpe-user=nagios \
>--with-nrpe-group=nagios \
>--enable-command-args \
>--enable-ssl
#make all
#make install-plugin
服務器端不需要開始nrpe服務
下面開始配置客戶端
nrpe依賴于nagios-plugins,首先安裝nagios-plugins
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-mysql=/path/to/mysql(監(jiān)控mysql必須添加此選項)
#make && make instal
下面開始安裝nrpe
#./configure --with-nagios-user=nagios \
>--with-nagios-group=nagios \
>--with-nrpe-user=nagios \
>--with-nrpe-group=nagios \
>--enable-command-args \
>--enable-ssl
#make all
#make install-plugin
#make install-daemon(安裝守護進程)
#make install-daemon-config(安裝守護進程配置文件)
修改nrpe.cfg文件
找到allowed_hosts添加你的服務器的IP
啟動nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
下面就可以在服務器端定義主機,定義命令開始監(jiān)控
定義命令
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$(-c表示在遠程執(zhí)行命令)
}
定義主機
define host {
use linux-server
host_name webserver
alias web-server
address 192.168.0.4
}
定義服務
define service {
use linux-service
host_name webserver
service_description PING
check_command check_nrpe!check_ping
}
想要監(jiān)控什么就在客戶端上定義命令,在服務器上填寫檢測內(nèi)容就可以了
下面附上nrpe的啟動腳本
#!/bin/sh
#
# Source function library
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/functions ]; then
. /etc/rc.d/functions
fi
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
NrpeBin=/usr/local/nagios/bin/nrpe
NrpeCfg=/usr/local/nagios/etc/nrpe.cfg
LockFile=/var/lock/subsys/nrpe
# See how we were called.
case "$1" in
start)
# Start daemons.
echo -n "Starting nrpe: "
daemon $NrpeBin -c $NrpeCfg -d
echo
touch $LockFile
;;
stop)
# Stop daemons.
echo -n "Shutting down nrpe: "
killproc nrpe
echo
rm -f $LockFile
;;
restart)
$0 stop
$0 start
;;
status)
status nrpe
;;
*)
echo "Usage: nrpe {start|stop|restart|status}"
exit 1
esac
exit 0
網(wǎng)站建設公司,為您提供網(wǎng)站建設,網(wǎng)站制作,網(wǎng)頁設計及定制網(wǎng)站建設服務,專注于企業(yè)網(wǎng)站制作,高端網(wǎng)頁制作,對資質(zhì)代辦等多個行業(yè)擁有豐富的網(wǎng)站建設經(jīng)驗的網(wǎng)站建設公司。專業(yè)網(wǎng)站設計,網(wǎng)站優(yōu)化推廣哪家好,專業(yè)seo優(yōu)化排名優(yōu)化,H5建站,響應式網(wǎng)站。
網(wǎng)站標題:centos安裝nagios+nrpe
分享網(wǎng)址:http://chinadenli.net/article6/joieog.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導航、云服務器、網(wǎng)站改版、網(wǎng)頁設計公司、網(wǎng)站排名、用戶體驗
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)