This is just a function of the monitoring side of the overall script installserver ()
The specific script is as follows:
#!/bin/bash #this is Nagios server or client install Shell #at 2012/10/29 path= ' pwd ' Httppath=/usr/lo Cal/apache2 mysqlpath=/usr/local/mysql Nagiospath=/usr/local/nagios installserver () {Yum install-y
xinetd useradd-m Nagios groupadd nagcmd useradd-a-G nagcmd nagios useradd-a-G nagcmd Apache CD $path tar-zxvf nagios-3.2.0.tar.gz cd nagios-3.2.0./configure--with-command-group=nagcmd--with-nagio
S-user=nagios--with-nagios-group=nagios make install make install-init make Install-config Make Install-commandmode make install-webconf echo ' ######################################## ' echo ' please Create the Nagios user for Apache "echo"----------------------------------------"Cat $path/http.txt >>/etc/http d/httpd.conf $httppath/bin/htpasswd-c $nagiospath/etc/htpasswd.users nagiosadmin chkconfig--add nagios C
Hkconfig Nagios onCD $path tar-zxvf nagios-plugins-1.4.14.tar.gz cd nagios-plugins-1.4.14./configure--prefix= $nagiospath- -with-nagios-user=nagios--with-nagios-group=nagios make make install CD $path TAR-ZXVF Nrpe-2.12.ta
r.gz CD nrpe-2.12./configure make all make install make install-plugin make Install-daemon
Make Install-daemon-config make install-xinetd read-p ' please input the Nagios server IP: ' ServerIP echo "Nrpe 5666/tcp #nrpe" >>/etc/services sed-i "s#only_from.* #only_from = 127.0.0.1 $serverip # "/etc/xinetd.d/nrpe chkconfig--add xinetd chkconfig xinetd on service xinetd Restart CD $path tar-zxvf check_mysql_health-2.1.tar.gz cd check_mysql_health-2.1./configure--prefi X=/usr/local/nagios--with-nagios-user=nagios--with-nagios-group=nagios--with-perl=/usr/bin/perl make I Nstall Yum InstallPERL-DBI perl-dbd-mysql-y cd $path tar-zxvf check_iftraffic.tar.gz chmod +x check_iftraffic chmod +x check_mem.sh chmod +x check_cpu.sh chmod +x CP ip_conn.sh CP C Heck_cpu.sh/usr/local/nagios/libexec CP check_iftraffic/usr/local/nagios/libexec CP Ip_conn.sh/usr/local/nagi Os/libexec mv $path/cfg/server/etc/*/usr/local/nagios/etc mv $path/cfg/server/objects/*/usr/local/nagios/etc/o bjects chown-r Nagios.nagios/usr/local/nagios Service httpd Restart service xinetd restart echo "###
################################ "echo" ######### The result ######## "Echo-----------------------------------"
/usr/sbin/lsof-i:5666 echo "-----------------------------------"/usr/local/nagios/libexec/check_nrpe-h localhost }