您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
完成了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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。