Old boy Education teaches you how to build the Nagios configuration file in batches

Source: Internet
Author: User

Can expand into a more detailed configuration, such as menu, if you work hard enough, you can do one-click deployment of hundreds of server service monitoring, there is no problem (including host.cfg,service.cfg, etc.), if the configuration support directory is simpler.

1. Set up the machine name and IP Correspondence list
Cat >host.list <<eofoldboy
oldboyVM-001 192.168.1.1
oldboyVM-002 192.168.1.2
oldboyVM-003 192.168.1.3
oldboyVM-004 192.168.1.4
Eofoldboy
#提示: The above list can be edited manually or the script will be taken in bulk

2. Batch build Nagios Host configuration file
Rm-f New.host
EXEC
While Read line
Do
Echo ' Define host {' >>new.host
echo ' Use Linux-server ' >>new.host
echo "Host_name echo $line|awk ‘{print $1}‘ " >>new.host
echo "Alias echo $line|awk ‘{print $1}‘ " >>new.host
echo "Address echo $line|awk ‘{print $2}‘ " >>new.host
echo "}" >>new.host
Done
3. Final host Content
$ cat New.host
Define host {
Use Linux-server
HOST_NAME oldboyVM-001
Alias oldboyVM-001
Address 192.168.1.1
}
Define host {
Use Linux-server
HOST_NAME oldboyVM-002
Alias oldboyVM-002
Address 192.168.1.2
}
Define host {
Use Linux-server
HOST_NAME oldboyVM-003
Alias oldboyVM-003
Address 192.168.1.3
}
Define host {
Use Linux-server
HOST_NAME oldboyVM-004
Alias oldboyVM-004
Address 192.168.1.4
}

Old boy Education teaches you how to build the Nagios configuration file in batches

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.