used script below in order to change host_name so it uses short name (no realm/domain name), plus to insert alias line with FQDN of the host in nagios host's cfg files where file name format was $hostname.$realm.cfg.
#!/bin/bash
realm=some.domain.dotsometing
hostname=( ` grep host_name *.$realm.cfg | sed s/.$realm.cfg://g | awk '{print $1}'` )
for i in ${hostname[@]}
do
sed -i "s/$i.$realm/$i/g" $i.$realm.cfg
sed -i "3a\ \talias \t\t\t\t$i.$realm" $i.$realm.cfg
done
## script - end ###
example...
bofore:
scavara@xyz:/path/to/nagios$ cat hostname.realm.cfg
define host{
host_name hostname.realm
address 123.123.123.123
use some-group
contact_groups some-contacts
}
after:
scavara@xyz:/path/to/nagios$ cat hostname.realm.cfg
define host{
host_name hostname
address 123.123.123.123
alias hostname.realm
use some-group
contact_groups some-contacts
}
2.11.10
Subscribe to:
Post Comments (Atom)




0 comments:
Post a Comment