nagios 大量建立主機

來源:互聯網
上載者:User

標籤:nagios 監控

伺服器:192.168.21.133一、主機列表[[email protected] nagios]# cat host.list lvs-01 192.168.1.1lvs-02 192.168.1.2mysql-01 192.168.1.3mysql-02 192.168.1.4web-01 192.168.1.5web-02 192.168.1.6二、部署指令碼[[email protected] nagios]# cat create_host.sh #!/bin/shHOSTFILE=‘/usr/local/nagios/etc/objects‘cat >>$HOSTFILE/host_test.cfg<<EOF####################################################### HOST DEFINITION BY ZHANGYILING AT 20190816######################################################EOFexec <host.listwhile read linedo        echo "#host:`echo $line|awk ‘{print $1}‘`|ip:`echo $line|awk ‘{print $2}‘`">>$HOSTFILE/host_test.cfg        echo "define host {" >>$HOSTFILE/host_test.cfg        echo "                  use                             linux-server">>$HOSTFILE/host_test.cfg        echo "                  hostnmae                `echo $line|awk ‘{print $1}‘`">>$HOSTFILE/host_test.cfg        echo "                  alias               `echo $line|awk ‘{print $1}‘`">>$HOSTFILE/host_test.cfg        echo "                  address             `echo $line|awk ‘{print $2}‘`">>$HOSTFILE/host_test.cfg        echo "}">>$HOSTFILE/host_test.cfg        echo >>$HOSTFILE/host_test.cfgdone>tmp.hostexec <host.listi=1while read linedo        if [ $i -eq 6 ];then                echo -n "`echo $line|awk ‘{print $1}‘`" >>tmp.host        else                echo -n "`echo $line|awk ‘{print $1}‘`", >>tmp.host        fi        ((i++))donemembers=`head -1 tmp.host`cat >>$HOSTFILE/host_test.cfg<<EOF####################################################### HOST GROUP DEFINITION BY ZHANGYILING AT 20190816######################################################define hostgroup{                        hostgroup_name  linux-servers                        alias           Linux Servers                        members         $members}EOF


本文出自 “randolph” 部落格,轉載請與作者聯絡!

nagios 大量建立主機

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.