|
Pulling correct value from Mapfile
Hi all,
I am trying to pull one value from a Mapfile, but the result is that I am getting all the values. The Mapfile maps the host name from the Backup Server to the host name in our Network Monitoring Server, as shown here:
Mapfile
Code:
cat zabbixhosts
Helpdesk-fd:Server_Helpdesk
Knowledge-fd:Server_Knowledge
BaculaServer-fd:Server_Bacula
Zabbix-fd:Server_Zabbix_1.4.2
The section of script that is failing is here:
Code:
client=$(tail -n 38 /var/lib/bacula/log | grep -m 1 -F "Client" | awk -F" " '{ print $2; }')
echo Client is $client
echo
# get hostname from the Hostsfile
ZABBIX_HOST=`grep "[$client]" $ZABBIX_HOSTSFILE`
if [ $? -eq 0 ]; then
hostname=`echo "$ZABBIX_HOST" | cut -f2 -d:`
else
hostname=""
fi
echo Hostname is $hostname
When I run that script the output is as follows:
Code:
./bacula2zabbix.sh
Client is "BaculaServer-fd"
Hostname is Server_Helpdesk Server_Knowledge Server_Bacula Server_Zabbix_1.4.2
Any advice would be greatly appreciated.
Thanks.
Last edited by MrKen; 07-03-2009 at 03:16 AM..
Reason: Bad cut n paste
|