Last active
November 2, 2015 19:34
-
-
Save charles-dyfis-net/5bfee9f721ec75ebee3e to your computer and use it in GitHub Desktop.
creating config files for nagios
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while IFS=, read -r host ip cont _ <&3; do | |
parent=${ip%.*}.1 | |
TMPL=HOST-TEST.tmpl | |
FILE=$host.cfg | |
awk \ | |
-v HOST="$host" \ | |
-v CONT="$cont" \ | |
-v PARENT="$parent" \ | |
-v IP="$ip" \ | |
'{ | |
sub("HOSTNAME", HOST, $0); | |
sub("CONTACTGROUP", CONT, $0); | |
sub("PARENT", PARENT, $0); | |
sub("IPADDR", IP, $0); | |
print $0; | |
}' <"$TMPL" >"$FILE" | |
done 3< servers.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment