Here is some code that you should be able to easily adapt, this was one of the subroutines used to collect data from over 600 servers prior to a DCM - just adapt and substitute your own bits.
for HOST in `cat ${CONFDIR}/svr-access.conf | grep -v '^#'`
do
OUTFILE=details-${HOST}.csv
echo "checking ${HOST}"
MSG "checking ${HOST}"
HOSTNAME=`ssh ${HOST} "uname -n"`
OS=`ssh ${HOST} "uname"`
# ssh_get_os_details ${HOST} ${OS}
MSG "Found ${HOSTNAME} running ${OS}"
MSG "JOB STEP 2"
if [ ${OS} = "AIX" ]
then
MSG "JOB STEP 3"
if [ `echo ${OSVER} | cut -c1` -ne 4 ]
then
ssh_get_aix56_getdetails ${HOST} > ${DATADIR}/${OUTFILE}
fi
elif [ ${OS} = "SunOS" ]
then
MSG "JOB STEP 4"
${FUNCDIR}/ssh_solaris_getdetails ${HOST} > ${DATADIR}/${OUTFILE}
fi
done
Regards
Gull04
---------- Post updated at 12:51 PM ---------- Previous update was at 12:35 PM ----------
Hi,
Just for some more information, here is one of the more simple routines that are called in the ssh calling script.
writes to a different file for each host. If you want all of the output in a single file and you want to trim off the first part of the lsb_release output you need something more like:
clearing the output file before you start your loop with:
>"$tmpdir/alluserhosts"
unless you want the output in that file to grow each time you invoke your script.
Since I don't have access to a system with lsb_release installed, the above is totally untested. But, in theory, it should come close to what you seem to want.
Note that in the code I suggested in post #8, the output to the single log file is produced by a single invocation of the printf utility that uses an append redirection operator ( >> ) instead of the overwrite redirection operator ( > ) that was in the original code. Although not required by the standards, I would expect the output of that invocation of printf to be produced by a single write() system call, which, when writing the amount of data shown in the examples to a regular file, should be an atomic operation. Using the append redirection should prevent the concurrent background processes from overwriting each other's output and the single printf instead of multiple echo s should keep the output from the various background processes from being intermixed.