Server 端 —

需要套件

yum install -y libmcrypt-devel.x86_64

下載安裝

wget https://downloads.sourceforge.net/project/nagios/nsca-2.x/nsca-2.9.1/nsca-2.9.1.tar.gz?r=&ts=1384410873&use_mirror=nchc
tar zxvf nsca-2.9.1.tar.gz
cd nsca-2.9.1
./configure
make all

複製設定

yes|cp -rp ./init-script /etc/init.d/nsca
chmod +x /etc/init.d/nsca
yes|cp -rp ./src/nsca /usr/local/nagios/bin
chown nagios.nagcmd /usr/local/nagios/bin/nsca
yes|cp -rp ./sample-config/nsca.cfg /usr/local/nagios/etc/
chown nagios.nagcmd /usr/local/nagios/etc/nsca.cfg
chmod g+r /usr/local/nagios/etc/nsca.cfg

編輯 /usr/local/nagios/etc/nagios.cfg

check_external_commands = 1
command_check_interval = -1

編輯 /usr/local/nagios/etc/nsca.cfg

aggregate_writes=1          # support 大量監控
password=XXX_same_as_client # 驗證碼,這邊設了 client 也要

編輯 /usr/local/nagios/etc/localhost_nsca.cfg

define service {
 host_name localhost
 service_description nsca
 use global-service
 active_checks_enabled 0  # 關閉,不然 nagios server 就會主動
 passive_checks_enabled 1 # 要作被動就打開 
 check_period 24x7
 max_check_attempts 6
 normal_check_interval 5
 retry_check_interval 1
 contact_groups admins-test
 notification_options c,r,w
 notification_period 24x7
 check_command check_dummy!0
 notification_interval 25
 servicegroups nsca
 }

編輯 /usr/local/nagios/etc/commands.d/commands.cfg

define command{
 command_name check_dummy
 command_line $USER1$/check_dummy $ARG1$
 }

驗證並啟動服務

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 
service nagios reload
service nsca start

Client 端  —

(我直接把 Server 當成 Client 端)

編輯 send_nsca.cfg

password=XXX_same_as_server # 驗證碼,這邊設了 server 也要

測試

#     host:service:status:msg                      serverIP
echo "localhost;nsca;0;testOK" |./src/send_nsca -H localhost -d ";" -c sample-config/send_nsca.cfg

 

Related posts 相關文章
簡單容易自己架設的監控平台-Uptime Kuma
More...
監控系統 icinga (nagios 的分支) 安裝 icinga-web 時遇到 500 internal server error
More...
監控系統 icinga (nagios 的分支) Q&A 篇
More...
監控系統 icinga (nagios 的分支) icinga-mobile 篇
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。