Script to compare all the config files in a cluster of servers.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to compare all the config files in a cluster of servers.
# 1  
Old 02-15-2009
Script to compare all the config files in a cluster of servers.

Hello Lads!

Climbing the shell scripting learning curve, i am faced with yet another obstacle! Here's the challenge in front of me :

1) I have 15 servers in a cluster,all of them have the same config files by name : /home/apps/xrm/App_B.cfg

2) The developers change the entries in the config files as and when required, and this is done on all the servers in the cluster.They take a backup of the original backup config before modifying it. Something like this: App_B.cfg.021509

3) I am trying to come up with a script which can be run on any one of the servers in the cluster which can do a comparision between the new config file (modified) and the old backup and put the result in a log, it should do this on all the 15 servers without me having to run the script on all boxes :

Code:
Example : 

The server names are :bpon03,bpon04,bpon05...bpon15

I would like to run the script on bpon03, and ideally would like the result to be in a log :

diff_log.txt with results in it as :

bpon03 :

diff App_B.cfg App_B.cfg.021509

xxx..xxx..

bpon04:

diff App_B.cfg App_B.cfg.021509

xxx..xxx..


bpon05:

diff App_B.cfg App_B.cfg.021509

xxx...xxxxx

and so on.

I know this must sound pretty silly for the experts here, but i am unable to come up with a solution with my very elementary scripting skills. Help would be greatly appreciated, and oh, the SSH keys are shared on all the servers,so thats not a problem. Thanks.
# 2  
Old 02-15-2009
Code:
hostlist='bpon01 bpon02 bpon03 bpon04 bpon05
bpon06 bpon07 bpon08 bpon09 bpon10 bpon11
bpon12 bpon13 bpon14 bpon15'

for host in $hostlist
do
   ssh "$host" "diff App_B.cfg App_B.cfg.021509 >> logfile"
done

# 3  
Old 02-16-2009
Thank you Sir ! It works well! Just that it ends up creating a logfile on all the boxes,which means i'll have to login to all 15 boxes in the cluster to check the diff results. Is it possible that all the results are put in just 1 logfile from where the script is being run? ( In our case,bpon03), with the server names appended above each diff result?
# 4  
Old 02-16-2009

This will create a separate file on the local machine for each host:

Code:
for host in $hostlist
do
   ssh "$host" "diff App_B.cfg App_B.cfg.021509" >> $host.logfile
done

# 5  
Old 02-16-2009
Thank you. I think thats a good idea,although it'll end up creating 15 logs on the server each time i run the script, but i should be able to live with that.
# 6  
Old 02-16-2009
Quote:
Originally Posted by rdlover
Thank you. I think thats a good idea,although it'll end up creating 15 logs on the server each time i run the script, but i should be able to live with that.

If you don't want 15 log files, redirect them all to one file, e.g.:

Code:
for host in $hostlist
do
   ssh "$host" "diff App_B.cfg App_B.cfg.021509"
done > logfile-$(date +%Y-%m-%d)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with shell script to compare values between servers

Hi I am a beginner in UNIX and shell scripting and i have a requirement as stated below, requirement Login to a unix server 1 1. connect to a database mysql -uUsername -pPassword 2. Select a Schema : "Use Schemaname1" 3. query for a particular record ... (2 Replies)
Discussion started by: Hamdul
2 Replies

2. Shell Programming and Scripting

Compare files in 2 servers

I need to compare same set of files in 2 different servers and generate a list (in STDOUT) which contain all the files that have changed. I don't have permission to create any temp files or folders in either servers. - One option is to use ' if '. But for this I need to move file1 to one server... (1 Reply)
Discussion started by: vskr72
1 Replies

3. Shell Programming and Scripting

Compare the files in 2 different servers for change or modification

I have the following requirement; I need to compare set of files in 2 different servers A and B. Both have same sets of files and directory structure First I need to move the files from Server A to server B Compare the corresponding file in B server and see if it has modified (not... (1 Reply)
Discussion started by: vskr72
1 Replies

4. Shell Programming and Scripting

List and Compare Files accross different servers.

Hi all, This is my situation. First thing is I cannot use rsync to accomplish this. I don't have on my systems and we can't put it on. I run HP-UX 11v3. I have a list of files generated every day which tells me which files are not in sync with the rest of the servers.I want to ls -l the... (1 Reply)
Discussion started by: zixzix01
1 Replies

5. Shell Programming and Scripting

Help related to Script to move files depending on config values

Hi All, I am new to Unix scripting, I have requirement where I need to read the key value pair from config file. Sample Config file: Key(File Pattern) Value(File Directory location) test /Users/Bkumar/Downloads/testdir prod ... (1 Reply)
Discussion started by: sbpkumar7
1 Replies

6. Shell Programming and Scripting

Script to login to several servers and get files

Hi ppl, I am looking out for a shell script a. That would have to login(from a main server) to say 16 servers individually. b.On each server go to a particular location, check if a particular file is generated on a date(say every sunday it gets generated and i would be interested in the latest... (8 Replies)
Discussion started by: yohasini
8 Replies

7. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

8. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

9. Web Development

bash script editing my apache config files

okay i'm going to try to say this uber-simple: I use dropbox (file-sync service). in order for dropbox sync files, they must be its children eg. somewhere under /home/jzacsh/Dropbox]. I want to now use it to keep my development files in sync across my machines: easy: just move my dev. files... (2 Replies)
Discussion started by: jzacsh
2 Replies

10. Shell Programming and Scripting

Need a sheel script to compare no of file on diffrent servers

i have serverA and serverB and i have a folder with same name an location in both servers.... Now i want to compare files in folder(serverA) with folder (serverB) if there are files missing in folderB then copy those files from folder(serverA) to folder(serverB) (1 Reply)
Discussion started by: ashahzad
1 Replies
Login or Register to Ask a Question