Merge the data from two servers into a single file

Hi All,

Need your inputs for the below.

I have 2 different servers 611 & 610, where i would be running two scripts. And would would be running one script from 611 at every 4 hours to merge the data from the 2 servers into 2 files and send a mail.

so below is the code snippet for 611:

#!/bin/bash
var1=`netstat | grep 16001 | wc -l`
var2=`date`
var3=`psme | grep -i DM_EAI | wc -l`
 
while true; do
    echo $var2 $var1
    sleep 1800
done  > eai_js_611.csv
 
while true; do
    echo $var2 $var3
    sleep 1800
done  > dm_eai_611.csv

code snippet for 610:

#!/bin/bash
var1=`netstat | grep 16001 | wc -l`
var2=`date`
var3=`psme | grep -i DM_EAI | wc -l`
 
while true; do
    echo $var2 $var1
    sleep 1800
done  > eai_js_610.csv
 
while true; do
    echo $var2 $var3
    sleep 1800
done  > dm_eai_610.csv

Now my question is how to merge the data from 611 & 610 in the below format:

eai_js_counts.csv
 
Timestamp                            BRM Servers 
                                          611       610
1/28/2013 2:00 AM PST          176       99
1/28/2013 6:00 AM PST          150       115
dm_eai_counts.csv
 
 
Timestamp                             BRM Servers 
                                           611       610
1/28/2013 2:00 AM PST           4           5
1/28/2013 6:00 AM PST           4           5

Please share your inputs.

Thanks!!

---------- Post updated at 11:32 PM ---------- Previous update was at 09:44 PM ----------

Can combine the data from 2 servers by using below:

final script on 611:

#!/bin/bash
paste -d '\n' eai_js_611.csv eai_js_610.csv > eai_js_counts.csv
paste -d '\n' dm_eai_611.csv dm_eai_610.csv > dm_eai_counts.csv

Also, from one server can read other server file using ftp, please correct me if I am wrong.

Now the only thing is left how to add the column names to the final output.

Thanks

ftp works, but scp and ssh with access keys are easier to script; rcp and rsh are earlier, less secure versions of scp/ssh -- not encrypted, no keyed access, not well thought of. Easiest of all is to mount one system's dir on the other with NFS.

Hi DGPickett,

Also, could you please me tell how can i use sudo user after logging to remote server.

Thanks

---------- Post updated at 07:04 AM ---------- Previous update was at 01:19 AM ----------

Hi All,

Could you please help me with the join command.

I am having 2 files as:

c1.csv
1/29/2013 01:00 AM PST  129     93
1/29/2013 01:30 AM PST  142     79
1/29/2013 02:00 AM PST  130     72
c2.csv
1/29/2012 09:00 PM PST  105     51
1/29/2012 11:00 PM PST  96      64
1/29/2012 11:30 PM PST  92      66

Using below join command:

join -a1 -a2 c1.csv c2.csv

And getting below output:

1/29/2012 09:00 PM PST 105 51
1/29/2012 11:00 PM PST 96 64
1/29/2012 11:30 PM PST 92 66
1/29/2013 01:00 AM PST 129 93
1/29/2013 01:30 AM PST 142 79
1/29/2013 02:00 AM PST 130 72

So wanted to check how can i modify the join command to add the column headings & proper spacing as below:

Timestamp                      610    611
1/29/2012 09:00 PM PST   105    51
1/29/2012 11:00 PM PST   96      64
1/29/2012 11:30 PM PST   92      66
1/29/2013 01:00 AM PST   129    93
1/29/2013 01:30 AM PST   142    79
1/29/2013 02:00 AM PST   130    72

Thanks.

Three questions should be three chains! We're roaming!