您好,登錄后才能下訂單哦!
完成了nagios的服務器端的設置后,則需要在被監控主機端做相關設置,設定一些監控參數值。
完整的配置腳本如下:
- #!/bin/bash
- #auto configure nagios linux client side
- #2012-12-05
- nagios_dir="/usr/local/nagios"
- nagiosrv="192.168.0.50"
- function Install_nagios()
- {
- yum -y install install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl* openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers libxslt-devel libevent-devel ntp libtool-ltdl bison libtool vim-enhanced gd*
- useradd nagios
- cd /usr/local/src
- tar zxvf nagios-plugins-1.4.16.tar.gz
- tar zxvf nrpe-2.13.tar.gz
- cd /usr/local/src/nagios-plugins-1.4.16 #編譯安裝nagios插件包
- ./configure --prefix=$nagios_dir
- make;make install
- chown -R nagios:nagios $nagios_dir
- cd /usr/local/src/nrpe-2.13 #編譯安裝nrpe包
- ./configure
- make all
- make install-plugin
- make install-daemon
- make install-daemon-config
- }
- function Set_nagios()
- {
- cd $nagios_dir/etc/
- sed -i.bak '/server_address/ s/^#//' nrpe.cfg #修改主機的nrpe配置文件
- sed -i '/server_address/ s/=.*$/=0.0.0.0/' nrpe.cfg
- sed -i '/allowed_hosts/ s/^.*$/&, '$nagiosrv'/' nrpe.cfg
- sed -i '205acommand[check_disk]=/usr/local/nagios/libexec/check_disk -w 15% -c 5% -p / -p /boot' nrpe.cfg #追加監控磁盤容量的命令
- sed -i '206acommand[check_swap]=/usr/local/nagios/libexec/check_swap -w 30% -c 10%' nrpe.cfg #追加監控swap容量的命令
- }
- function Restart_nagios() #重啟nrpe服務
- {
- kill -9 `cat /var/run/nrpe.pid` > /dev/null 2>&1
- $nagios_dir/bin/nrpe -c $nagios_dir/etc/nrpe.cfg -d
- }
- case $1 in
- install)
- Install_nagios
- ;;
- config)
- Set_nagios
- ;;
- restart)
- Restart_nagios
- ;;
- *)
- echo "Usage sh nagiosclient.sh {install|config|restart}"
- ;;
- esac
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。