• nagios 批量安装客户端


    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
  • 相关阅读:
    Jdbc 事务
    Spring
    【Java集合的详细研究1】Collections类常用方法总结
    Java Number类
    Java中值类型和引用类型的区别
    Java常量池的理解
    Java重写与重载之间的区别
    Java中Animal b = new Dog();Dog c = new Dog();的区别
    java类构造器的理解
    Javascript history pushState onpopstate方法做AJAX SEO
  • 原文地址:https://www.cnblogs.com/cenliang/p/4788856.html
Copyright © 2020-2023  润新知