服務(wù)端腳本:
創(chuàng)新互聯(lián)公司憑借在網(wǎng)站建設(shè)、網(wǎng)站推廣領(lǐng)域領(lǐng)先的技術(shù)能力和多年的行業(yè)經(jīng)驗,為客戶提供超值的營銷型網(wǎng)站建設(shè)服務(wù),我們始終認為:好的營銷型網(wǎng)站就是好的業(yè)務(wù)員。我們已成功為企業(yè)單位、個人等客戶提供了成都網(wǎng)站設(shè)計、成都網(wǎng)站制作服務(wù),以良好的商業(yè)信譽,完善的服務(wù)及深厚的技術(shù)力量處于同行領(lǐng)先地位。#!//bin/bash #nagios一鍵安裝腳本 path=`pwd` yum_user() { echo -e "\033[32m開始安裝基礎(chǔ)支持套件和添加用戶......\033[0m" yum -y install httpd gcc glibc glibc-common gd gd-devel if [ $? -ne 0 ] then echo -e "\033[31mYUM安裝失?。033[0m" exit 1 fi echo -e "\033[32mnagios依賴組件安裝完成!\033[0m" /usr/sbin/useradd -m nagios &&/usr/sbin/groupadd nagcmd /usr/sbin/usermod -a -G nagcmd nagios /usr/sbin/usermod -a -G nagcmd apache if [ $? -ne 0 ] then echo -e "\033[31m添加用戶失??!\033[0m" exit 2 fi echo -e "\033[32mnagios用戶組配置完成!\033[0m" } nagios_ins() { echo -e "\033[32m開始安裝nagios_cn程序......\033[0m" cd ${path}/download tar jxvf nagios-cn-*.tar.bz2 cd nagios-cn-* ./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode make install-webconf if [ $? -ne 0 ] then echo -e "\033[31mnagios_cn安裝失敗!\033[0m" exit 3 fi echo -e "\033[32mnagios_cn程序安裝成功!\033[0m" echo -e "\033[32m開始設(shè)置nagios_cn程序......\033[0m" echo -en "\033[32m請輸入nagiosadmin用戶密碼:\033[0m" read passwd htpasswd -cb /usr/local/nagios/etc/htpasswd.users nagiosadmin ${passwd} service httpd restart chkconfig --add httpd &&chkconfig httpd on chkconfig --add nagios &&chkconfig nagios on cat>>/root/.bashrc<<EOF alias check_nagios='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg' EOF service nagios restart if [ $? -ne 0 ] then echo -e "\033[31mnagios_cn設(shè)置失敗!\033[0m" exit 3 fi echo -e "\033[32mnagios_cn程序設(shè)置成功!\033[0m" } nagios_plugins_ins() { echo -e "\033[32m開始安裝nagios_plugins程序......\033[0m" cd ${path}/download tar zxvf nagios-plugins-*.tar.gz cd nagios-plugins-* ./configure --with-nagios-user=nagios --with-nagios-group=nagios make&&make install if [ $? -ne 0 ] then echo -e "\033[31mnagios_plugins安裝失敗!\033[0m" exit 2 fi echo -e "\033[32mnagios_plugins程序安裝成功!\033[0m" } nrpe_ins() { echo -e "\033[32m開始安裝nagios_plugins程序......\033[0m" cd ${path}/download tar zxvf nrpe-*.tar.gz cd nrpe-* ./configure --with-nagios-user=nagios --with-nagios-group=nagios make all make install-plugin make install-daemon make install-daemon-config if [ $? -ne 0 ] then echo -e "\033[31mnrpe安裝失敗!\033[0m" exit 2 fi echo -e "\033[32mnrpe程序安裝成功!\033[0m" echo -e "\033[32m開始設(shè)置nrpe程序......\033[0m" cat>>/usr/local/nagios/etc/objects/commands.cfg<<EOF define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ } EOF /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d cat >> /etc/rc.d/rc.local << EOF /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d EOF if [ $? -ne 0 ] then echo -e "\033[31mnrpe設(shè)置失敗!\033[0m" exit 2 fi echo -e "\033[32mnrpe程序設(shè)置成功!\033[0m" } echo -e "\033[33m開始安裝nagios......\033[0m" echo -e "\033[32m\n\t(1)基礎(chǔ)套件與用戶添加\n\t(2)安裝nagios-cn\n\t(3)安裝nagios-plugins\n\t(4)安裝nrpe\n\t(5)退出程序(exit)\033[0m" read -p "請輸入選擇:" choice case ${choice} in 1) yum_user;; 2) nagios_ins;; 3) nagios_plugins_ins;; 4) nrpe_ins;; 5) break;; *) echo -e "\033[31m您輸入了:$num,設(shè)定沒有此選項,請重輸 \033[0m" break;; esac
客戶端腳本:
#!/bin/bash path=`pwd` nagios_server="192.168.1.1" yum_user() { echo -e "\033[32m開始安裝基礎(chǔ)支持套件和添加用戶......\033[0m" yum -y install gcc if [ $? -ne 0 ] then echo -e "\033[31mYUM安裝失敗!\033[0m" exit 1 fi echo -e "\033[32mnagios依賴組件安裝完成!\033[0m" /usr/sbin/useradd -m nagios if [ $? -ne 0 ] then echo -e "\033[31m添加用戶失敗!\033[0m" exit 2 fi echo -e "\033[32mnagios用戶配置完成!\033[0m" } nagios_plugins_ins() { echo -e "\033[32m開始安裝nagios_plugins程序......\033[0m" cd ${path} tar zxvf nagios-plugins-*.tar.gz cd nagios-plugins-* ./configure --with-nagios-user=nagios --with-nagios-group=nagios make&&make install chown nagios.nagios /usr/local/nagios/ chown -R nagios.nagios /usr/local/nagios/libexec/ if [ $? -ne 0 ] then echo -e "\033[31mnagios_plugins安裝失??!\033[0m" exit 2 fi echo -e "\033[32mnagios_plugins程序安裝成功!\033[0m" } nrpe_ins() { echo -e "\033[32m開始安裝nagios_plugins程序......\033[0m" cd ${path} tar zxvf nrpe-*.tar.gz cd nrpe-* ./configure --with-nagios-user=nagios --with-nagios-group=nagios make all make install-plugin make install-daemon make install-daemon-config if [ $? -ne 0 ] then echo -e "\033[31mnrpe安裝失??!\033[0m" exit 2 fi echo -e "\033[32mnrpe程序安裝成功!\033[0m" echo -e "\033[32m開始設(shè)置nrpe程序......\033[0m" cat >> /etc/rc.d/rc.local << EOF >/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d EOF sed -i 's@allowed_hosts=127.0.0.1@allowed_hosts=192.168.1.1@' /usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d sleep 1 /usr/local/nagios/libexec/check_nrpe -H ${nagios_server} if [ $? -ne 0 ] then echo -e "\033[31mnrpe設(shè)置失??!\033[0m" exit 2 fi echo -e "\033[32mnrpe程序設(shè)置成功!\033[0m" } echo -e "\033[33m開始安裝nagios_client......\033[0m" echo -e "\033[32m\n\t(1)基礎(chǔ)套件與用戶添加\n\t(2)安裝nagios-plugins\n\t(3)安裝nrpe\n\t(4)退出程序(exit)\033[0m" read -p "請輸入選擇:" choice case ${choice} in 1) yum_user;; 2) nagios_plugins_ins;; 3) nrpe_ins;; 4) break;; *) echo -e "\033[31m您輸入了:$num,設(shè)定沒有此選項,請重輸 \033[0m" break;; esac
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
文章題目:nagios一鍵安裝腳本V1.0(客戶端+服務(wù)端)-創(chuàng)新互聯(lián)
分享鏈接:http://redsoil1982.com.cn/article44/dpooee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、品牌網(wǎng)站制作、網(wǎng)站排名、定制網(wǎng)站、服務(wù)器托管、網(wǎng)頁設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容