Sponsored Content
Top Forums Shell Programming and Scripting Pulling correct value from Mapfile Post 302330989 by MrKen on Friday 3rd of July 2009 02:13:11 AM
Old 07-03-2009
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
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Pulling out fields from a file

Hi, I have a file that contains 1400 lines similar to the one shown below: NAME=sara, TOWN=southampton, POSTCODE=SO18777, EMAIL=sara@hotmail.com, PASSWORD=asjdflkjds etc etc (note: this is one line). Each line has the same fields, but on each line they are in a different order. Eg. the line... (2 Replies)
Discussion started by: Saz
2 Replies

2. UNIX for Dummies Questions & Answers

pulling the following line from a file

I have return files from a process that has then original input record followed on the next line by a response record..either AA,........... for accepted or EE,.......... for errored. i.e 11,new,123 AA,accepted 12,exist,443 EE,rejected 13,old,223 AA,accepted I want to write a small... (4 Replies)
Discussion started by: peter.herlihy
4 Replies

3. Shell Programming and Scripting

Pulling data and following lines from file

I saw a few posts close to what i want to do, but they didn't look like they would work exactly.. or I need to think out of the box on this. I have a file that I keep server stats in for my own performance analysis. this file has the output from many commands in it (uptime, vmstats, ps, swap... (2 Replies)
Discussion started by: MizzGail
2 Replies

4. Shell Programming and Scripting

Pulling the first and last character/number from a string.

Let's say I have a word "foobar23" in a file, and I want to pull the first "f" and last "3" character out of the world, how would I accomplish that? # cat file foobar23 I want the output to be: f3 (3 Replies)
Discussion started by: LinuxRacr
3 Replies

5. Shell Programming and Scripting

Capacity of directory... Pulling hair out :-)

I am new to scripting and thought I was doing rather well however I ran into a issue and I am not sure how to fix it. I am using the following command to obtain the capacity percent of the directory listed however it seems that this command gets the capacity of the whole mount rather then just the... (8 Replies)
Discussion started by: LRoberts
8 Replies

6. Shell Programming and Scripting

pulling out the value from rows

Hi, I'm trying to pull all occurrence of value , for example "xy1234" from several rows, out of a file. The file might as well contain other different type of rows. 20100121 04:00:02 37a00452 <ABCN:ABXC> From MV Modify <uid=xy1234,ou=Internal2,ou=people,dc=abc,dc=example1,dc=com> I am trying... (4 Replies)
Discussion started by: john_prince
4 Replies

7. Shell Programming and Scripting

Pulling remote hostname into variable

I'm trying to write a shell script using bash that connects to a remote server, runs a command that generates a file, pulls the file over, then renames it with the hostname of the remote server and a an extension. So far, I'm able to everything but pull the hostname of the remote server into a... (2 Replies)
Discussion started by: hobbes80
2 Replies

8. Shell Programming and Scripting

Strange behavior with readarray (aka mapfile)

$ readarray list <<< "a b c d e f g" $ echo ${list} a b c d e f g $ echo "a b c d e f g" | readarray list2 $ echo ${list2} a blank lineI read a post the same thing happens with cat vs < on another forum but the poster did not know why. Any ideas? Mike (3 Replies)
Discussion started by: Michael Stora
3 Replies

9. Shell Programming and Scripting

Pulling data from xml

Hi there, Please could anyone help with this. I have an xml file that contains repeating values eg <Rule name> AAAAA <Action> BBBBB </Action> <Data> CCCCC </Data> <Type> DDDDD </Type> </Rule name> <Rule name> A1A1A1A1 <Action> B1B1B1B1 </Action> <Data> C1C1C1C </Data> <Type>... (4 Replies)
Discussion started by: ssideel
4 Replies

10. Shell Programming and Scripting

Partial file pulling

I am connecting to another server through sftp. I am running one batch script to pull file from another server. sometimes i am receiving partial files. I am using below commands in batch script. ls -ltr new.txt mget new.txt bye The file is of 1 MB only.In most of the cases , i received... (6 Replies)
Discussion started by: srinath01
6 Replies
BDB.DB0(5)							AFS File Reference							BDB.DB0(5)

NAME
bdb.DB0, bdb.DBSYS1 - Contain the Backup Database and associated log DESCRIPTION
The bdb.DB0 file contains the Backup Database, which records configuration information used by the AFS Backup System along with cross- indexed records of the tapes created and volumes dumped using the Backup System commands. The bdb.DBSYS1 file is a log file in which the Backup Server (buserver process) logs each database operation before performing it. When an operation is interrupted, the Backup Server replays the log to complete the operation. Both files are in binary format and reside in the /var/lib/openafs/db directory on each database server machine that runs the Backup Server. When the Backup Server starts or restarts on a given machine, it establishes a connection with its peers and verifies that its copy of the bdb.DB0 file matches the copy on the other database server machines. If not, the Backup Servers use AFS's distributed database technology, Ubik, to distribute to all of the machines the copy of the database with the highest version number. Use the commands in the backup suite to administer the Backup Database. It is advisable to create a backup copy of the bdb.DB0 file on tape on a regular basis, using the UNIX tar command or another local disk backup utility. SEE ALSO
backup(8), backup_savedb(8), buserver(8) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 BDB.DB0(5)
All times are GMT -4. The time now is 02:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy