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