Click to See Complete Forum and Search --> : Documenting linux config
happybunny
08-11-2004, 06:25 PM
I built a RH box for our Oracle developers several months ago and have been making modifications to it ever since.
Since I am a horrible documentarion, and always assume I'll remember everything, can ya'll suggest a way to now capture the current setup?
I have thought of a few things, but if you have anything to add as far as being able to recreate the environment after a clean install, I'd greatly apreciate it.
# free>/memory.txt ( i put this here since I just had to increase the swap space for them)
# df -h > /hd.txt
# vgdisplay -v > /lvm.txt
# rpm -qa|sort > /rpms.txt
# cat /etc/passwd > /users.txt (UID's are important)
# uname -a > /uname.txt
# cp /etc/sysconfig/network /network.txt
# cp /etc/syconfig/network-scripts/ifcfg-ethx /ethx.txt
is there any more info that can/should be captured to be able to recreate this server short of a backup/restore?
I would like to be able to build a new clean system with the correct config (now that I have learned so much and after all of Oracle's "oh ya, we need this too!") to hand to the Oracle people and say "start again".
hard candy
08-11-2004, 06:37 PM
Take a look at Shivalek (http://www.tldp.org/linuxfocus/English/May2004/article337.shtml)
Works good on my system. And I'm sure Redhat must have something similiar.
GigaShadow
08-11-2004, 07:42 PM
Hard Candy, anything in particular that you do not like about Shivalek? I have got our network guys evaluating it, and it works as promised it should be great.....however, there are "some" who feel that SMS is the "only" answer!
G :)
hard candy
08-11-2004, 08:02 PM
It's pretty good and it works well, just remember to use it after any package upgrade. And save a copy on a disk.
GigaShadow
08-11-2004, 08:18 PM
Hard Candy: Thanks! I hope to resolve this issue by October 1 (start of federal fiscal year)...and, then we can move on to the implementation of either Remedy or Heat (not hijacking this thread, just an overall comment). Actually, I like the Shivalek product...however, since I am the deputy "contractor" running a government IT shop things do not always go the way I would want them!! :D
Thanks Again......G :cool:
happybunny
08-11-2004, 09:11 PM
I have a script from HP that I just found...i will try to attach it.
I haven't run it yet, but it looks pretty thurough...looks like the output is html.
looks like a regular shell script, but I take no credit nor any blaim for what it really does as I haven't run it myself yet.
The shivalek doesn't seem to report versions of lib's or rpm's, which I think would be important.
I cannot attach the script as it isn't a jpg.
I will post it in the next thread so it is clean.
happybunny
08-11-2004, 09:12 PM
#!/bin/bash
#Make sure root runs this script
PATH=/bin:/sbin:/usr/bin:/usr/sbin
if [ `id|cut -c5-11` != "0(root)" ]
then
echo You must be logged in as root to run this tool
exit
fi
VERSION="1.4"
#Get a filename generated by hostname-time
Report_Html_File=`hostname`_`eval date "+%Y-%m-%d@%H:%M:%S"`.html
#Get a temp file to write the text_file
text_file=/tmp/text_file$$
#Start the html writting
echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Report Generated for HP Support</TITLE>
<STYLE TYPE="text/css">
{font-family: lucida sans, helvetica, arial, sans-serif}
H1 {font-family: lucida sans, helvetica, arial, sans-serif;FONT-SIZE=24pt}
H2 {font-family: lucida sans, helvetica, arial, sans-serif;FONT-SIZE=16pt}
H3 {font-family: lucida sans, helvetica, arial, sans-serif;FONT-SIZE=14pt}
Pre {Font-Family: Courier-New, Courier;Font-Size: 12pt}
LI, UL {Font-Family: Courier-New, Courier;Font-Size: 12pt}
</STYLE>
</HEAD>" > $Report_Html_File
echo "<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#990200" VLINK="#006342">">> $Report_Html_File
echo "<h2><CENTER>Report for `hostname` on `date "+%m-%d-%Y %H:%M:%S"`</Center></h2>" >> $Report_Html_File
echo "<h2><CENTER>Produced by snapshot Version $VERSION </Center></h2><hr>" >> $Report_Html_File
touch $text_file
#write the main menu here
start_main()
{
echo Processing $1 information
echo "<h3><A NAME=\"$1_menu\"></A><A HREF=\"#$1_data\">$1</A></h3>" >> $Report_Html_File
echo "<ul>" >> $Report_Html_File
echo "<hr>" >> $text_file
echo "<h3><A NAME=\"$1_data\"></A><A HREF=\"#$1_menu\">$1</A></h3>" >> $text_file
}
end_main()
{
echo "</ul>" >> $Report_Html_File
echo "<hr>" >> $Report_Html_File
}
#Write Sub Menus
start_submain()
{
echo "<li><A NAME=\"$1_data\"></A><A HREF=\"#$1_menu\">$1</A>" >> $Report_Html_File
echo "<ul>" >> $Report_Html_File
echo "<h3><A NAME=\"$1_menu\"></A><A HREF=\"#$1_data\">$1</A></h3>" >> $text_file
}
end_submain()
{
echo "</ul>" >> $Report_Html_File
}
to_text() {
echo "<pre>" >> $text_file
eval $1 >> $text_file
echo "</pre>" >> $text_file
}
parse_command() {
if [ $3 ]
then
if [ -e $1 ]
then
#Do the html menu
echo "<li><a name=\"$2_menu\"></a> <a href=\"#$2_data\"> $2 </a>" >> $Report_Html_File
#Do the text file Menu
echo "<a name=\"$2_data\"></a><a href=\"#$2_menu\"><h3> $1 </h3></a>" >> $text_file
to_text "$3 $1" "$2"
fi
else
#Do the html Data
echo "<li><a name=\"$2_menu\"></a> <a href=\"#$2_data\"> $2 </a>" >> $Report_Html_File
#Do the text file Data
echo "<a name=\"$2_data\"></a><a href=\"#$2_menu\"><h3> $1 </h3></a>" >> $text_file
to_text "$1" "$2"
fi
}
#Reporting Hardware
start_main Hardware
#do subsection
parse_command "/proc/cpuinfo" "CPU-Info" "cat"
parse_command "/proc/meminfo" "Memory" "cat"
parse_command "/sbin/lspci" "PCI-Devices"
parse_command "/proc/ioports" "IoPorts" "cat"
parse_command "/proc/interrupts" "Interrupts" "cat"
parse_command "/proc/dma" "DMA-Devices" "cat"
parse_command "/proc/scsi/scsi" "SCSI-Disks" "cat"
parse_command "/proc/devices" "Devices" "cat"
start_submain "IDE-Devices"
if [ -d /proc/ide ]
then
for i in `ls /proc/ide | grep hd`
do
parse_command "/proc/ide/$i/model" "$i" "cat"
done
fi
end_submain
parse_command "dmesg" "Dmesg"
end_main
#Reporting System info
start_main System
#do subsection
parse_command "hostname" "Hostname"
parse_command "uname -a" "Uname"
parse_command "/etc/redhat-release" "Release" "cat"
parse_command "/etc/UnitedLinux-release" "Release" "cat"
parse_command "/proc/version" "Version" "cat"
parse_command "uptime" "Uptime"
parse_command "date" "System-Clock"
parse_command "hwclock" "Hardware-Clock"
parse_command "free" "Mem/Swap free"
parse_command "swapon -s" "Swap-Information"
parse_command "vmstat" "Vmstat"
end_main
#Reporting Kernel Info
start_main Kernel
#do subsection
parse_command "/boot/efi/efi/redhat/elilo.conf" "Elilo" "cat"
parse_command "/etc/lilo.conf" "Lilo" "cat"
parse_command "/boot/grub/grub.conf" "Grub" "cat"
parse_command "/etc/grub.conf" "Grub" "cat"
parse_command "/proc/cmdline" "Booted_as" "cat"
for i in `rpm -qa|grep kernel`
do
parse_command "rpm -qi $i" "$i"
done
parse_command "lsmod" "Loaded Modules"
parse_command "/etc/modules.conf" "Modules.conf" "cat"
parse_command "sysctl -a" "Configured-Kernel-Params"
end_main
#Reporting FileSystems info
start_main "File-Systems"
#do subsection
parse_command "/proc/partitions" "Proc-Partitions" "cat"
parse_command "fdisk -l" "Disks-Partitions"
parse_command "/etc/fstab" "Fstab" "cat"
parse_command "mount" "Mounted-File-Systems"
parse_command "/etc/exports" "Exported-File-Systems" "cat"
parse_command "df" "Disk-Free"
parse_command "iostat" "Iostat"
end_main
#Reporting Software Info
start_main Software
parse_command "ps -faxwl" "Running-Processes"
parse_command "pstree" "Pstree"
parse_command "ps -eo pid,stat,pcpu,nwchan,wchan=WIDE-WCHAN-COLUMN -o args" "Yet-Another-ps"
parse_command "rpm -qa|sort" "Installed-Software"
end_main
#Reporting Network Info
start_main Network
#do subsection
start_submain Interfaces
if [ -d /etc/sysconfig/networking/devices ]
then
for i in `ls /etc/sysconfig/networking/devices`
do
parse_command "/etc/sysconfig/networking/devices/$i" "$i" "cat"
done
fi
if [ -d /etc/sysconfig/network ]
then
for i in `ls /etc/sysconfig/network`
do
if [ -e $i ]
then
parse_command "/etc/sysconfig/network/$i" "$i" "cat"
fi
done
fi
end_submain
parse_command "ifconfig" "Ifconfig"
parse_command "/etc/nsswitch.conf" "Nsswitch.conf" "cat"
parse_command "/etc/resolv.conf" "Resolver" "cat"
parse_command "route" "Route-Table"
parse_command "netstat -a" "Netstat"
#parse_command "ipchains --list" "Ipchains"
end_main
start_main Services
start_submain "Inetd-Services-Enabled"
if [ -d /etc/xinetd.d ]
then
for i in `ls /etc/xinetd.d/*`
do
if [ `eval grep disable $i|grep no|awk '{print $3}'` ]
then
parse_command "$i" "`basename $i`" "cat"
if [ "$i" = "/etc/xinetd.d/wu-ftpd" ]
then
start_submain "Ftp-configuration-files"
for x in `ls /etc/ftp*`
do
parse_command "$x" "`basename $x`" "cat"
done
end_submain
else
parse_command "/etc/pam.d/`basename $i`" "Pam conf for `basename $i`" "cat"
fi
fi
done
fi
if [ -e /etc/inetd.conf ]
then
parse_command "/etc/inetd.conf" "inetd.conf" "cat"
fi
end_submain
end_main
#Reporting Log Files
start_main "Log-Files"
start_submain "Messages-Files"
parse_command "/var/log/messages" "messages" "cat"
parse_command "/var/log/messages.1" "messages.1" "cat"
end_submain
start_submain "Boot-Files"
parse_command "/var/log/boot.log" "boot.log" "cat"
parse_command "/var/log/boot.msg" "boot.msg" "cat"
parse_command "/var/log/boot.log.1" "boot.log.1" "cat"
end_submain
end_main
#Join the two files into one .html file
cat $text_file >> $Report_Html_File
#delete the text file
rm $text_file
echo "</Body>" >> $Report_Html_File
echo The file $Report_Html_File contains the report produced in html format
exit
hard candy
08-11-2004, 09:30 PM
But it looks like that script just gives a report. With shivalik I can restore my /etc (configuration). And I could include my package data base to be saved as well.
happybunny
08-11-2004, 10:19 PM
good point...i will delve deper into shivalek...thanks
happybunny
08-12-2004, 08:44 AM
I have added a line to capture all the rpm info now to my shivalik script, but wanted to know how to change the output file names to include the hostname of the machine its running on, rather than the word "backup".
I tried replacing backup- with $hostname, but that did not work at all.
Do you know how I can do that?
this is what I added :
echo "OK, creating $targetdir/backup-$dt/rpminfo.txt..."
rpm -qai>$targetdir/backup-$dt/rpminfo.txt
hard candy
08-12-2004, 08:54 AM
The easiest would be to rename the parent directory in the command:
"shivalik /usr/local/hostname/backupcfg/"
or "shivalik /usr/local/backupcfg/hostname/"