十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
完成了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