Operating System - HP-UX
1830945 Members
2090 Online
110017 Solutions
New Discussion

data collection script needed

 
SOLVED
Go to solution
Ferdinand_2
Advisor

data collection script needed

Hi there,

I'd like to have a script which will copy collected data from one server to my admin server. I have to submit the output from a check script to HP.
I looked up and tried several recommended scripts in the forum, but I couldn't get them to work.

I would like to use a file containing all machine names.

something like

#############
for server in server_list.txt
do
remsh server rcp -p collected_data_file admin_server:/collection_dir/
done
cd /pub more beer
6 REPLIES 6
Chris Wilshaw
Honored Contributor
Solution

Re: data collection script needed

Try running the following from your admin server

for server in `cat server_list.txt`
do
rcp -p $server:collected_data_file /collection_dir
done

You'll just need to put in the full path to your collected data file. I assume that the files have unique names so that they don't overwrite one another when you copy them to your admin server.

Chris
Ferdinand_2
Advisor

Re: data collection script needed

Thanks Chris,
but
Doesn't the collection_dir need a machine name to copy to?

cd /pub more beer
harry d brown jr
Honored Contributor

Re: data collection script needed


rcp -rp $server:/directory/to/copy RECEIVINGhostname:/directory2put_itin


ie: If I am on serverA and I want to copy files from serverK to serverU, I would do this:

[serverA:root]# rcp -rp serverK:/var/datafiles serverU:/var/collectionpoint


live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: data collection script needed

and I could do from serverA:

rcp -rp serverK:/var/datafiles serverA:/var/collectionpoint

OR

rcp -rp serverK:/var/datafiles /var/collectionpoint

OR

cd /var/collectionpoint
rcp -rp serverK:/var/datafiles .

OR


cd /var/collectionpoint
rcp -rp serverK:/var/datafiles serverA:.


live free or die
harry
Live Free or Die
someone_4
Honored Contributor

Re: data collection script needed

Here is the script it runs from the admin server and will work as long as you have remsh access to the other servers.

#!/bin/sh
exec > /home/richard/bin/nick.txt 2> /home/richard/bin/nick_err.txt
echo 'starting time'
date
REMOTES=/home/richard/cron/hostnames1
for REMOTE in $(cat $REMOTES)
do
echo '#####################'
rcp -p -r root@${REMOTE}:/path/to/data/you/want.* /path/on/admin/server
done

Ok here is how you get the script to work.

exec > /home/richard/bin/nick.txt 2> /home/richard/bin/nick_err.txt
This will produce a log with error and output. Change the path to where you want the script to log or comment this part out if you dont care about logs.

REMOTES=/home/richard/cron/hostnames1
the hostnames1 file is a file with a list of hostnames or IPaddress you want to get the information from change this to the path where you want to run the script from. the file should look like this:

hosta
hostb
hostc

rcp -p -r root@${REMOTE}:/path/to/data/you/want.* /path/on/admin/server
This command goes out to the "remote" host from the hostnames list and goes to the
path of the data you want and puts it in the path on the admin server.


~Richard
Ferdinand_2
Advisor

Re: data collection script needed

Thanks very much for all your input. It is all really appriciated.

I have printed this stuff and will keep it in my little admin library.

I didn't give out any 10's because I didn't want to close the tread.



:wq!
cd pub
more beer
cd /pub more beer