Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Needed

Status
Not open for further replies.

StickyBit

Technical User
Jan 4, 2002
264
CA
Folks,

I'm looking for a perl or shell script that will gather basic information about a sun server (hostid, ip address, installed memory, processor type, OS version, installed devices, etc). Does anyone know of any good scripts that I can use...?

Thanks,

Stickybit.
 
for memory ... you could try this thread:

thread60-337165
 
We use this script for disaster recovery, it is very detailed, just copy and paste, and modify for your version of solaris



#!/bin/ksh
#
######################################################################
## This script automatically creates the Disaster Recovery Binder.
## For Solaris 7
######################################################################
#
# To print:
#
# try: lp -d$PRINTER -ovm6 -op16 $FILENAME
# (vertical margin, font pitch)
#
# or try: lp -d$PRINTER -o nb -o fp18 -ovsi5 -olm5
# (no banner, font pitch, vertical spacing, left margin)
#
# or for std printers, change -l96 to -l60 on all "pr" statements.
#
# i.e. cat automate.sh | sed 's/-l96/-l60/g' > tempfile
# cp automate.sh automate.`date '+%y%m%d'`
# mv tempfile automate.sh
#
######################################################################
#
#

# Change number of lines per page
NLines=60
# Change line offset
LMargin=10

umask 027
dt=`date '+%m%d'`
NaMe=`uname -n`
mkdir TEMP

ls -lap /etc/ > ./TEMP/etc.$dt
pr -h "${NaMe}: ls -Rlap /etc/" -o$LMargin -l$NLines ./TEMP/etc.$dt > ./TEMP/Yetc.${dt}.pr

#ls -Rlap /dev/ > ./TEMP/dev.$dt
#pr -h "${NaMe}: ls -Rlap /dev/" -l$NLines -o$LMargin ./TEMP/dev.$dt > ./TEMP/Zdev.${dt}.pr

ls -lap /usr/local/ > ./TEMP/local.$dt
pr -h "${NaMe}: ls -lap /usr/local" -l$NLines -o$LMargin ./TEMP/local.$dt > ./TEMP/Z5local.${dt}.pr

ls -Rlap /usr/local/bin > ./TEMP/lbin.$dt
pr -h "${NaMe}: ls -Rlap /usr/local/bin" -l$NLines -o$LMargin ./TEMP/lbin.$dt > ./TEMP/Z7lbin.${dt}.pr

cat /etc/vfstab > ./TEMP/vfstab.$dt
pr -h "${NaMe}: vfstab" -l$NLines -o$LMargin ./TEMP/vfstab.$dt > ./TEMP/E2vfstab.${dt}.pr

if [ -x /usr/sbin/vxdisk ]
then
vxdisk list > ./TEMP/vxdisk.$dt
pr -h "${NaMe}: vxdisk list" -l$NLines -o$LMargin ./TEMP/vxdisk.$dt > ./TEMP/E5vxdisk.${dt}.pr

vxprint -ht > ./TEMP/vxprint.$dt
pr -h "${NaMe}: vxprint -ht" -l$NLines -o$LMargin ./TEMP/vxprint.$dt > ./TEMP/E6vxprint.${dt}.pr

for i in `vxprint -G | grep ^dg | cut -d" " -f2`
do
vxstat -g $i > ./TEMP/vxstat.${i}.$dt
pr -h "${NaMe}: vxstat -g $i" -l$NLines -o$LMargin ./TEMP/vxstat.${i}.$dt > ./TEMP/E8vxstat.${i}.${dt}.pr
done

for i in `ls /etc/vx/elm`
do
cat -vet /etc/vx/elm/${i}
echo "\n\n###END KEY###\n\n"
done > ./TEMP/vxlic.$dt
pr -h "${NaMe}: VX License Keys" -l$NLines -o$LMargin ./TEMP/vxlic.$dt > ./TEMP/E7vxlic.${dt}.pr
fi

DISKS=`df -k | awk -F/ '$4 ~ /^c/ {print $4}' | cut -d"s" -f1 | sort | uniq`
if [ "s$DISKS" != "s" ]
then
for i in $DISKS
do
prtvtoc /dev/rdsk/${i}s2 > ./TEMP/vtoc_${i}.$dt
pr -h "${NaMe}: prtvtoc $i" -l$NLines -o$LMargin ./TEMP/vtoc_${i}.$dt > ./TEMP/E9vtoc_${i}.${dt}.pr
done
fi

/usr/platform/sun4u/sbin/prtdiag -v > ./TEMP/diag.$dt
pr -h "${NaMe}: prtdiag" -l$NLines -o$LMargin ./TEMP/diag.$dt > ./TEMP/B2diag.${dt}.pr

cat /etc/system > ./TEMP/kern.$dt
pr -h "${NaMe}: /etc/system" -l$NLines -o$LMargin ./TEMP/kern.$dt > ./TEMP/C0kern.${dt}.pr

eeprom > ./TEMP/eeprom.$dt
pr -h "${NaMe}: eeprom" -l$NLines -o$LMargin ./TEMP/eeprom.$dt > ./TEMP/C3eeprom.${dt}.pr

cat /etc/.serial_number > ./TEMP/serial.$dt
pr -h "${NaMe}: serial number" -l$NLines -o$LMargin ./TEMP/serial.$dt > ./TEMP/AAserial.${dt}.pr

prtconf | grep -v instance > ./TEMP/conf.$dt
pr -h "${NaMe}: prtconf" -l$NLines -o$LMargin ./TEMP/conf.$dt > ./TEMP/B4conf.${dt}.pr

sysdef | grep -v instance > ./TEMP/sysdef.$dt
pr -h "${NaMe}: sysdef" -l$NLines -o$LMargin ./TEMP/sysdef.$dt > ./TEMP/B6sysdef.${dt}.pr

dmesg > ./TEMP/dmesg.$dt
pr -h "${NaMe}: dmesg " -l$NLines -o$LMargin ./TEMP/dmesg.$dt > ./TEMP/B8dmesg.${dt}.pr

if [ -x /usr/local/bin/sysinfo ]
then
/usr/local/bin/sysinfo > ./TEMP/sysinfo.$dt
pr -h "${NaMe}: sysinfo" -l$NLines -o$LMargin ./TEMP/sysinfo.$dt > ./TEMP/B9sysinfo.${dt}.pr
fi

cat /etc/inittab > ./TEMP/inittab.$dt
pr -h "${NaMe}: inittab" -l$NLines -o$LMargin ./TEMP/inittab.$dt > ./TEMP/H4inittab.${dt}.pr

for i in rc1 rc2 rc3
do
ls -lap /etc/${i}.d > ./TEMP/${i}.$dt
pr -h "${NaMe}: ls -lap /etc/"${i}".d" -o$LMargin -l$NLines ./TEMP/${i}.$dt > ./TEMP/H7${i}.${dt}.pr
done

cat /etc/inet/hosts > ./TEMP/hosts.$dt
pr -h "${NaMe}: hosts" -l$NLines -o$LMargin ./TEMP/hosts.$dt > ./TEMP/K1hosts.${dt}.pr

cat /etc/hosts.allow > ./TEMP/hallow.$dt
pr -h "${NaMe}: hosts.allow" -l$LMargin -o$NLines ./TEMP/hallow.$dt > ./TEMP/K3hallow.${dt}.pr

cat /etc/hosts.deny > ./TEMP/hdeny.$dt
pr -h "${NaMe}: hosts.deny" -l$NLines -o$LMargin ./TEMP/hdeny.$dt > ./TEMP/K5hdeny.${dt}.pr

cat /etc/inet/inetd.conf > ./TEMP/inetd.$dt
pr -h "${NaMe}: inetd.conf" -l$NLines -o$LMargin ./TEMP/inetd.$dt > ./TEMP/L2inetd.${dt}.pr

cat /etc/syslog.conf > ./TEMP/syslog.$dt
pr -h "${NaMe}: /etc/syslog.conf" -l$NLines -o$LMargin ./TEMP/syslog.$dt > ./TEMP/L4syslog.${dt}.pr

cat /etc/passwd > ./TEMP/passwd.$dt
pr -h "${NaMe}: /etc/passwd" -l$NLines -o$LMargin ./TEMP/passwd.$dt > ./TEMP/I2passwd.${dt}.pr

cat /etc/group > ./TEMP/group.$dt
pr -h "${NaMe}: /etc/group" -l$NLines -o$LMargin ./TEMP/group.$dt > ./TEMP/I6group.${dt}.pr

cat /etc/mail/aliases > ./TEMP/aliases.$dt
pr -h "${NaMe}: /etc/mail/aliases" -l$NLines -o$LMargin ./TEMP/aliases.$dt > ./TEMP/I8aliases.${dt}.pr

cat /etc/shadow > ./TEMP/shadow.$dt
pr -h "${NaMe}: /etc/shadow" -l$NLines -o$LMargin ./TEMP/shadow.$dt > ./TEMP/I4shadow.${dt}.pr

pkginfo -x > ./TEMP/pkginfo.$dt
pr -h "${NaMe}: pkginfo" -l$NLines -o$LMargin ./TEMP/pkginfo.$dt > ./TEMP/D1pkginfo.${dt}.pr

showrev -p > ./TEMP/showrev.$dt
pr -h "${NaMe}: showrev -p" -l$NLines -o$LMargin ./TEMP/showrev.$dt > ./TEMP/D2showrev.${dt}.pr

if [ -d /usr/local/sbin/patchdiag ]
then
/usr/local/sbin/patchdiag/patchdiag > ./TEMP/patchdiag.$dt
pr -h "${NaMe}: patchdiag" -l$NLines -o$LMargin ./TEMP/patchdiag.$dt > ./TEMP/D3patchdiag.${dt}.pr
fi

swap -l > ./TEMP/swap.$dt
pr -h "${NaMe}: swap -l" -l$NLines -o$LMargin ./TEMP/swap.$dt > ./TEMP/D5swap.${dt}.pr

lpstat -v > ./TEMP/lpstat.$dt
pr -h "${NaMe}: lpstat -v" -l$NLines -o$LMargin ./TEMP/lpstat.$dt > ./TEMP/D9lpstat.${dt}.pr

ifconfig -a > ./TEMP/ifconfig.$dt
pr -h "${NaMe}: ifconfig -a" -l$NLines -o$LMargin ./TEMP/ifconfig.$dt > ./TEMP/V2ifconfig.${dt}.pr

netstat -nr > ./TEMP/netstat.$dt
pr -h "${NaMe}: netstat -nr" -l$NLines -o$LMargin ./TEMP/netstat.$dt > ./TEMP/V4netstat.${dt}.pr

cat /etc/resolv.conf > ./TEMP/resolv.$dt
pr -h "${NaMe}: /etc/resolv.conf" -l$NLines -o$LMargin ./TEMP/resolv.$dt > ./TEMP/V6resolv.${dt}.pr

cat /etc/nsswitch.conf > ./TEMP/nsswitch.$dt
pr -h "${NaMe}: /etc/nsswitch.conf" -l$NLines -o$LMargin ./TEMP/nsswitch.$dt > ./TEMP/V8nsswitch.${dt}.pr

df -k > ./TEMP/df_k.$dt
pr -h "${NaMe}: df -k" -l$NLines -o$LMargin ./TEMP/df_k.$dt > ./TEMP/Fdf_k.${dt}.pr

for i in `ls /usr/spool/cron/crontabs`
do
crontab -l $i > ./TEMP/cron_${i}.$dt
pr -h "${NaMe}: crontab -l "$i -l$NLines -o$LMargin ./TEMP/cron_${i}.$dt > ./TEMP/Scron_${i}.${dt}.pr
done

ss=`date +%C | cut -c5-13`

print "\n\n\n\t TABLE OF CONTENTS " > ${NaMe}.toc
print "\t"$NaMe "("`date`")" >> ${NaMe}.toc
print "\n\tSerial Numbers(/etc/.serial_number)" >> ${NaMe}.toc
print "\tConfiguration (prtdiag, prtconf, sysdef, hostid, dmesg)" >> ${NaMe}.toc

if [ -x /usr/local/bin/sysinfo ]
then
print "\tSystem Information (sysinfo)" >> ${NaMe}.toc
fi

print "\tKernel Configuration (/etc/system)" >> ${NaMe}.toc
print "\tFirmware Configuration (eeprom)" >> ${NaMe}.toc
print "\tPackages Installed (pkginfo)" >> ${NaMe}.toc
print "\tPatches Installed (showrev -p)" >> ${NaMe}.toc
print "\tPatches Needed (patchdiag)" >> ${NaMe}.toc
print "\n\tSwap Space (swap -l)" >> ${NaMe}.toc
print "\tPrinter Configuration (lpstat -v)" >> ${NaMe}.toc
print "\tFree Space on all File Systems (df -k)" >> ${NaMe}.toc
print "\tFile Systems Mount Points (/etc/vfstab)" >> ${NaMe}.toc

if [ -x /usr/sbin/vxdisk ]
then
print "\tVeritas Disk Layout & Stats (vxdisk, vxprint, vxstat, vx license keys)" >> ${NaMe}.toc
fi

if [ "s$DISKS" != "s" ]
then
print "\tUnix Disk Layout (prtvtoc)" >> ${NaMe}.toc
fi

print "\n\tInitialization Processes (/etc/inittab)" >> ${NaMe}.toc
print "\tStartup Scripts (/etc/rc*d)" >> ${NaMe}.toc
print "\tPassword File (/etc/passwd)" >> ${NaMe}.toc
print "\tShadow File (/etc/shadow)" >> ${NaMe}.toc
print "\tGroup File (/etc/group)" >> ${NaMe}.toc
print "\tMail Aliases File (/etc/mail/aliases)" >> ${NaMe}.toc
print "\n\tHosts File (/etc/inet/hosts)" >> ${NaMe}.toc
print "\tHosts.Allow File (/etc/hosts.allow)" >> ${NaMe}.toc
print "\tHosts.Deny File (/etc/hosts.deny)" >> ${NaMe}.toc
print "\tInetd Configuration File (/etc/inet/inetd.conf)" >> ${NaMe}.toc
print "\tSyslog Configuration (/etc/syslog.conf)" >> ${NaMe}.toc
print "\n\tAll Crontabs (/usr/spool/cron/crontabs/*)" >> ${NaMe}.toc
print "\tInterface Configuration (ifconfig -a)" >> ${NaMe}.toc
print "\tRouting Table (netstat -nr)" >> ${NaMe}.toc
print "\tResolve Configuration (/etc/resolv.conf)" >> ${NaMe}.toc
print "\tNIS Configuration (/etc/nsswitch.conf)" >> ${NaMe}.toc
print "\n\tListing of /etc (ls -l)" >> ${NaMe}.toc
print "\tListing of /usr/local (ls -l)" >> ${NaMe}.toc
print "\tRecursive Listing of /usr/local/bin (ls -Rl)" >> ${NaMe}.toc


cat TEMP/*.pr > ${NaMe}.${dt}
banner DONE!

#read wa

#cat TEMP/*.pr | sed "s/^$ss/ $ss/" > ${NaMe}.${dt}
# rm -r TEMP

#lp -daux1 -ovm6 -op16

 
Ok, so I modify this script for my environment, any ideas on how to execute this script for 50+ sun servers?

I was thinking about using rsh to execute a script or maybe scheduling a script to run on each server then using FTP, SCP or SMTP I would send the files to a centralized location.

I also thought about using a RDMS to collect 50+ records apposed to collecting 50+ files. I guess for this I would have to use something like Perl DBI and not a shell script...?

Is there a strait forward or best practice solution for something like this (collecting configuration information for 50+ servers)?

Thanks,

Stickybit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top