nagios 批量安裝客戶端

2022-03-21 18:56:43 字數 3317 閱讀 7048

2015-09-07

#nagios批量安裝客戶端

###在客戶端批量安裝nagios-plugin和nrpe

#!/bin/bash

host_list=`cat

nagios_hosts.txt`

for i in

$host_list

do#從跳板機將相關軟體複製到nagios客戶端

scp /data/home/cenliang/nagios/* $i:/root/

#新增nagios使用者

ssh -n $i "chattr -i /etc/fstab /etc/passwd /etc/group /etc/shadow /etc/sudoers"

ssh -n $i "useradd -m -s /sbin/nologin nagios"

ssh -n $i "chattr +i /etc/fstab /etc/passwd /etc/group /etc/shadow /etc/sudoers"

#安裝nrpe

ssh -n $i "yum install -y gcc glibc glibc-common gd gd-devel xinetd"

ssh -n $i "tar zxf nrpe-2.15.tar.gz"

ssh -n $i "cd /root/nrpe-2.15 && ./configure --prefix=/usr/local/nagios --enable-command-args"

ssh -n $i "cd /root/nrpe-2.15 && make all"

ssh -n $i "cd /root/nrpe-2.15 && make install-plugin"

ssh -n $i "cd /root/nrpe-2.15 && make install-daemon"

ssh -n $i "cd /root/nrpe-2.15 && make install-daemon-config"

ssh -n $i "cd /root/nrpe-2.15 && make install-xinetd"

ssh -n $i "rm -f /etc/xinetd.d/nrpe && cp /root/nrpe /etc/xinetd.d/nrpe"

ssh -n $i "echo 'nrpe 5666/tcp #nrpe'>>/etc/services"

ssh -n $i "chkconfig xinetd on && service xinetd restart"

ssh -n $i "netstat -an|grep 5666"

ssh -n $i "cd /usr/local/nagios/etc/ && mv nrpe.cfg nrpe.cfg.bak"

ssh -n $i "cp /root/nrpe.cfg /usr/local/nagios/etc/"

ssh -n $i "chown nagios:nagios nrpe.cfg"

#檢測nrpe命令

ssh -n $i "/usr/local/nagios/libexec/check_nrpe -h localhost"

#安裝nagios-plugin

ssh -n $i "yum -y install perl perl-devel nagios-plugins nagios-plugins-ntp-perl perl-cpan perl-nagios-plugin perl-regexp-common"

ssh -n $i "tar -zxf nagios-plugins-2.0.3.tar.gz"

ssh -n $i "cd /root/nagios-plugins-2.0.3 && ./configure --prefix=/usr/local/nagios/ --enable-perl-modules"

ssh -n $i "cd /root/nagios-plugins-2.0.3 && make && make install"

ssh -n $i "rm -rf /usr/local/nagios/libexec/"

ssh -n $i "tar -zxf /root/libexec.tar.gz -c /usr/local/nagios/"

ssh -n $i "chown nagios:nagios /usr/local/nagios"

ssh -n $i "chown -r nagios:nagios /usr/local/nagios/libexec"

#檢測iostat命令

ssh -n $i "/usr/local/nagios/libexec/check_iostat -w 15"

#檢測cpu命令

ssh -n $i "/usr/local/nagios/libexec/check_cpu.sh -w 85 -c 95"

#檢測memory命令

ssh -n $i "/usr/local/nagios/libexec/check_memory.sh -w 85 -c 90"

#檢測disk命令

ssh -n $i "/usr/local/nagios/libexec/check_disk -w 20 -c 15"

#檢測nrpe呼叫cpu命令

ssh -n $i "/usr/local/nagios/libexec/check_nrpe -h localhost -c 'check_cpu!85!95'"

#檢測nrpe呼叫memory命令

ssh -n $i "/usr/local/nagios/libexec//check_nrpe -h localhost -c 'check_memory!85!90'"

#檢測nrpe呼叫disk命令

ssh -n $i "/usr/local/nagios/libexec/check_nrpe -h localhost -c 'check_disk!20%!15%!/boot!/!/data'"

#在nagios伺服器上測試nrpe命令與客戶端通訊

#[root@chery-manage-srv1 ~]# /usr/local/nagios/libexec/check_nrpe -h 10.105.48.107

#nrpe v2.15

#在nagios伺服器上新增監控主機和服務項

#[root@chery-manage-srv1 ~]# cd /usr/local/nagios/services/

#[root@chery-manage-srv1 services]# vim 2civi_services.cfg

done

nagios 客戶端安裝

安裝到 被監控的機器上 新增使用者和組 useradd nagios groupadd nagcmd 如果安裝中報沒有c編譯器,就 yum install gcc wget tar xzvf nagios plugins 1.4.15.tar.gz cd nagios plugins 1.4.15 ...

linux安裝nagios客戶端

安裝到 被監控的機器上 新增使用者和組 useradd nagios groupadd nagcmd usermod a g nagcmd nagios 如果安裝中報沒有c編譯器,就 yum install gcc wget tar xzvf nagios plugins 1.4.15.tar.gz...

nagios客戶端安裝與配置windows篇

一 被監控的windows xp客戶端的配置 nsclient 0.3.8 win32.msi nsclient 0.3.8 x64.msi 2 安裝nsclient 雙擊安裝 next 同意 next next next 設定允許ip,設定密碼 這裡密碼一般可以不設定 modules to loa...