#!/bin/bash
# @(#) $Id: cfg2html-linux,v 2.37 2011-12-28 10:52:58 ralproth Exp $
# -----------------------------------------------------------------------------------------
# (c) 1997 - 2012 by Ralph Roth  -*- http://come.to/rose_swe -*-

#  If you change this script, please mark your changes with for example
#  ## <username> and send your diffs from the actual version to my email
#  address: cfg2html*hotmail.com -- details see in the documentation

CFGSH=$_
# unset "-set -vx" for debugging purpose, after the exec 2> statement all debug infos will go the errorlog file (*.err)
#set -vx
#*vim:numbers:ruler

# ---------------------------------------------------------------------------
#        __       ____  _     _             _       _ _
#   ___ / _| __ _|___ \| |__ | |_ _ __ ___ | |     | (_)_ __  _   ___  __
#  / __| |_ / _` | __) | '_ \| __| '_ ` _ \| |_____| | | '_ \| | | \ \/ /
# | (__|  _| (_| |/ __/| | | | |_| | | | | | |_____| | | | | | |_| |>  <
#  \___|_|  \__, |_____|_| |_|\__|_| |_| |_|_|     |_|_|_| |_|\__,_/_/\_\
#           |___/
#  HP Proliant Edition script
#
# ---------------------------------------------------------------------------

## /usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
PATH=$PATH:/sbin:/bin:/usr/sbin:/opt/omni/bin:/opt/omni/sbin  ## this is a fix for wrong su root (instead for su - root)

VER=$(echo "$Id: cfg2html-linux,v 2.37 2011-12-28 10:52:58 ralproth Exp $"|awk '{print $3"-"$4;}')
if [ -z "$VER" ]		# no awk, e.g. my Linux router // OpenWRT
then
	VER="$Revision: 2.37 $";
fi;
VERSION="cfg2html-linux version $VER "  # this a common stream so we dont need the "Proliant stuff"

# Must be started under BASH - this needs reworking!

# if [ "$CFGSH" != "/bin/bash" ]
# then
# 	echo "WARNING!"
# 	echo "This script should be executed with the Bash Shell, not with $CFGSH"
# 	echo "Hint: Use ./$0 NOT sh $0"
# fi

#
# use "no" to disable a collection
#
CFG_ALTIRISAGENTFILES="yes"  # Added by jeroen kleen HP ISS CC Engineer
CFG_APPLICATIONS="yes"
CFG_CRON="yes"
CFG_ENHANCEMENTS="yes"
CFG_FILESYS="yes"
CFG_HARDWARE="yes"
CFG_KERNEL="yes"
CFG_LVM="yes"
CFG_NETWORK="yes" # <-- Network security, collecting tcpd and ip filter settings
CFG_SOFTWARE="yes"
CFG_STINLINE="yes"
CFG_SYSTEM="yes"
CFG_PLUGINS="no"
CFG_HPPROLIANTSERVER="no"

## Jeroen Kleen HP ISS GCC added to detect HP Proliant Server at beginning.
DMIDECODE=$(which dmidecode 2>/dev/null)
if [ -x "$DMIDECODE" ]
then
  echo
  # if [[ "$($DMIDECODE | grep "Product Name")" =~ ProLiant ]]        ## regex works here? rr, no according to 2.21 bug reports! #  28.11.2011, 13:17 modified by Ralph Roth #* rar *#
  if [ $($DMIDECODE | grep "Product Name" | grep -c ProLiant) -gt 0 ]
  then
    CFG_HPPROLIANTSERVER="yes"
    echo "**  HP Proliant Server detected; executing with HP Proliant Server logs  **"
  else
    CFG_HPPROLIANTSERVER="no"
    # if [[ "$($DMIDECODE | grep "Vendor")" =~ HP ]]                  ## regex works here? rr // Vendor: // Vendor Syndrome
    if [ $($DMIDECODE | grep "Vendor" | grep -c HP) -gt 0 ]
    then
        echo "HP server detected but no Proliant Server; to enable Proliant logs manually use -p argument"
    fi
  fi
fi

if [ "$OUTDIR" = "" ] ; then
  OUTDIR="."
fi
#
#
usage() {
  echo "WARNING, use this script AT YOUR OWN RISK"
  echo
  echo "    Usage: `basename $0` [OPTIONS]"
  echo "    creates a HTML and plain ASCII host documentation"
  echo
  echo "    -o      set directory to write or use the environment"
  echo "            variable OUTDIR=\"/path/to/dir\" (directory must exist)"
  echo "    -v      output version information and exit"
  echo "    -h      display this help and exit"


  echo "    use the following options to disable / enable collections:"
  echo
  echo "    -s      disable: System"
  echo "    -c      disable: Cron"
  echo "    -S      disable: Software"
  echo "    -f      disable: Filesystem"
  echo "    -l      disable: LVM"
  echo "    -L      disable: Screen tips inline"
  echo "    -k      disable: Kernel/Libraries"
  echo "    -e      disable: Enhancements"
  echo "    -n      disable: Network"
  echo "    -a      disable: Applications"
  echo "    -H      disable: Hardware"
  echo "    -p      enable: HP Proliant Server log files and settings" # Added by jeroen kleen HP ISS CC Engineer
  echo "    -A      disable: Altiris ADL agent log files and settings" # Added by jeroen kleen HP ISS CC Engineer
  echo "    -P      enable: cfg2html plugin architecture" # anaumann 2009/07/10
  #echo
}
#
# getopt
#
#
#NO_ARGS=0
#if [ $# -eq "$NO_ARGS" ]  # Script invoked with no command line args?
#then
#  usage
#  exit 1          # Exit and explain usage, if no argument(s) given.
#fi

while getopts ":o:shcSflkenaHLvhpPA" Option
do
  case $Option in
    o     ) OUTDIR=$OPTARG;;
    v     ) echo $VERSION; exit 0;;
    h     ) echo $VERSION; usage; exit 0;;
    s     ) CFG_SYSTEM="no";;
    c     ) CFG_CRON="no";;
    S     ) CFG_SOFTWARE="no";;
    f     ) CFG_FILESYS="no";;
    l     ) CFG_LVM="no";;
    k     ) CFG_KERNEL="no";;
    e     ) CFG_ENHANCEMENTS="no";;
    n     ) CFG_NETWORK="no";;
    a     ) CFG_APPLICATIONS="no";;
    H     ) CFG_HARDWARE="no";;
    L     ) CFG_STINLINE="no";;
    p     ) CFG_HPPROLIANTSERVER="yes";;
    P     ) CFG_PLUGINS="yes";;
    A     ) CFG_ALTIRISAGENTFILES="no";;
    *     ) echo "Unimplemented option chosen. Try -h for help!"; exit 1;;   # DEFAULT
  esac
done

shift $(($OPTIND - 1))
# Decrements the argument pointer so it points to next argument.

#
# linux port
MAILTO="&#106;&#101;&#114;&#111;&#101;&#110;&#46;&#107;&#108;&#101;&#101;&#110;&#64;&#104;&#112;&#46;&#99;&#111;&#109;"
MAILTORALPH="cfg2html&#64;&#104;&#111;&#116;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;"
# changed/added 08.07.2003 (13:04) by Ralph Roth


#####################################################################
# @(#)Cfg2Html (c) by ROSE SWE, Dipl.-Ing. Ralph Roth, cfg2html@hotmail.com
# HP Proliant Server Module Integrated by Jeroen.Kleen@hp.com
#####################################################################

# cfg2html-linux ported (c) by Michael Meifert, SysAdm from HP-UX version
# using debian potato, woody

# This is the "swiss army knife" for the ASE, CE, sysadmin etc. I wrote it to
# get the needed information to plan an update, to perform basic trouble
# shooting or performance analysis. As a bonus cfg2html creates a nice HTML and
# plain ASCII documentation. If you are missing something, let me know it!

# History
#####################################################################
# 28-jan-1999  initial creation, based on get_config, check_config
#              nickel, snapshoot, vim and a idea from a similar
#              script i have seen on-site.
#####################################################################
# 11-Mar-2001  initial creation for debian GNU Linux i386
#              based on Cfg2Html Version 1.15.06/HP-UX by
#              by ROSE SWE, Dipl.-Ing. Ralph Roth
#              ported to Linux  by Michael Meifert
#####################################################################
# 15-May-2006  Common stream for cfg2html-linux and the Proliant version


line ( ) {
echo --=[ http://come.to/cfg2html ]=-----------------------------------------------
}

echo -e "\n"

## test if user = root
#
#if [ `id|cut -c5-11` != "0(root)" ] ; then
# Apparently they did away with the cut convention of interpreting -c0 the same as -c1. In fact c0 now produces an error.
# This can be found/tested on Fedora 9 and Ubuntu 8.04 if anyone cares.

if [ `id|cut -c1-6` != "uid=0(" ] ; then	# 140906 rar, 160608 johnamurf
  if [ -x /usr/bin/banner ] ; then
    banner "Sorry!"
  else
	echo " ____                        _"
	echo "/ ___|  ___  _ __ _ __ _   _| |"
	echo "\___ \ / _ \| '__| '__| | | | |"
	echo " ___) | (_) | |  | |  | |_| |_|"
	echo "|____/ \___/|_|  |_|   \__, (_)"
	echo "                       |___/"
  fi
  line
  echo $0:$VERSION
  echo -e "You must run this script as Root\n"
  exit 1
fi
#
BASEFILE=`hostname||uname -n`		# 26.01.2001  uname -n, fixed 0205-2006rr for OpenWRT
HTML_OUTFILE=$OUTDIR/$BASEFILE.html
HTML_OUTFILE_TEMP=/tmp/$BASEFILE.html.$$
TEXT_OUTFILE=$OUTDIR/$BASEFILE.txt
TEXT_OUTFILE_TEMP=/tmp/$BASEFILE.txt.$$
ERROR_LOG=$OUTDIR/$BASEFILE.err
if [ ! -d $OUTDIR ] ; then
  echo "can't create $HTML_OUTFILE, $OUTDIR does not exist - stop"
  exit 1
fi
touch $HTML_OUTFILE
#echo "Starting up $VERSION\r"
[ -s "$ERROR_LOG" ] && rm -f $ERROR_LOG 2> /dev/null
DATE=`date "+%Y-%m-%d"` # ISO8601 compliant date string
DATEFULL=`date "+%Y-%m-%d %H:%M:%S"` # ISO8601 compliant date and time string

exec 2> $ERROR_LOG

if [ ! -f $HTML_OUTFILE ]  ;
then
  if [ -x /usr/bin/banner ] ; then
        banner "Error"
  else
        echo "E R R O R"
  fi
  line
  echo -e "You have not the rights to create the file $HTML_OUTFILE! (NFS?)\n"
  exit 1
fi

logger "Start of $VERSION"
RECHNER=$(hostname)			# `hostname -f`
VERSION_=`echo $VERSION/$RECHNER|tr " " "_"`
typeset -i HEADL=0                      # Headinglevel

#
# check Linux distribution
#
distrib="unknown"

## rr, 15.12.2004 - "robertfantini"
if [ -f /etc/gentoo-release ] ; then
	distrib="`head -1 /etc/gentoo-release`"
	GENTOO="yes"
else
	GENTOO="no"
fi

if [ -f /etc/slackware-version ] ; then
	distrib="`cat /etc/slackware-version`"
	SLACKWARE="yes"
else
	SLACKWARE="no"
fi

# if [ -f /etc/debian_version ] ; then
# 	distrib="Debian GNU/Linux Version `cat /etc/debian_version`"
# 	DEBIAN="yes"
# else
# 	DEBIAN="no"
# fi

## fix suggested by  thomas bludau @ Dienstag, 19. Januar 2010
# fix suggested by MiMe/Donnerstag, 21. Januar 2010 - could you make it please easier:
# -UBUNTU_VERSION="`cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | grep Ubuntu | sed \"s/DISTRIB_DESCRIPTION=//\" | sed \"s/\\\"//g\"`"
# +UBUNTU_VERSION=$(awk -F\" '/DISTRIB_DESCRIPTION/ {print $2}' /etc/lsb-release)

if [ -f /etc/debian_version ] ; then
        if [ -f /etc/lsb-release ] ; then
        	# UBUNTU_VERSION="`cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | grep Ubuntu | sed \"s/DISTRIB_DESCRIPTION=//\" | sed \"s/\\\"//g\"`"
        	UBUNTU_VERSION=$(awk -F\" '/DISTRIB_DESCRIPTION/ {print $2}' /etc/lsb-release)
        fi
        if  [ "$UBUNTU_VERSION" ]; then
	        distrib=$UBUNTU_VERSION
	        UBUNTU="yes"
        else
	        distrib="Debian GNU/Linux Version `cat /etc/debian_version`"
	        UBUNTU="no"
        fi
        DEBIAN="yes"
else
        DEBIAN="no"
fi

if [ -f /etc/SuSE-release ] ; then
	distrib="`head -1 /etc/SuSE-release`"
	SUSE="yes"
else
	SUSE="no"
fi

if [ -f /etc/mandrake-release ] ; then
        distrib="`head -1 /etc/mandrake-release`"
        MANDRAKE="yes"
else
        MANDRAKE="no"
fi

if [ -f /etc/redhat-release ] ; then
        distrib="`head -1 /etc/redhat-release`"
        REDHAT="yes"
else
        REDHAT="no"
fi

# MiMe: for UnitedLinux
if [ -f /etc/UnitedLinux-release ] ; then
        distrib="`head -1 /etc/UnitedLinux-release`"
        UNITEDLINUX="yes"
else
        UNITEDLINUX="no"
fi

# i am looking for other distribution tests



####################################################################
# needs improvement!
# trap "echo Signal: Aborting!; rm $HTML_OUTFILE_TEMP"  2 13 15

####################################################################
####################################################################
#  Header of HTML file
####################################################################

open_html() {
UNAMEA=$(uname -a)
echo -e " \
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML> <HEAD>
 <META NAME="GENERATOR" CONTENT="Selfmade-$VERSION">
 <META NAME="AUTHOR" CONTENT="Ralph Roth, Michael Meifert, Jeroen Kleen">
 <META NAME="CREATED" CONTENT="Ralph Roth, Michael Meifert, Jeroen Kleen">
 <META NAME="CHANGED" CONTENT="`id;date` ">
 <META NAME="DESCRIPTION" CONTENT="$Header: /cygdrive/e/CVSROOT/cfg2html_linux/cfg2html-linux,v 2.37 2011-12-28 10:52:58 ralproth Exp $">
 <META NAME="subject" CONTENT="$VERSION on $RECHNER by $MAILTO and $MAILTORALPH">
<style type="text/css">
/* (c) 2001- 2012 by ROSE SWE, Ralph Roth - http://come.to/rose_swe
 * CSS for cfg2html.sh, 12.04.2001, initial creation
 */

Pre		{Font-Family: Courier-New, Courier;Font-Size: 10pt}
BODY		{FONT-FAMILY: Arial, Verdana, Helvetica, Sans-serif; FONT-SIZE: 12pt;}
A		{FONT-FAMILY: Arial, Verdana, Helvetica, Sans-serif}
A:link 		{text-decoration: none}
A:visited 	{text-decoration: none}
A:hover 	{text-decoration: underline}
A:active 	{color: red; text-decoration: none}

H1		{FONT-FAMILY: Arial, Verdana, Helvetica, Sans-serif;FONT-SIZE: 20pt}
H2		{FONT-FAMILY: Arial, Verdana, Helvetica, Sans-serif;FONT-SIZE: 14pt}
H3		{FONT-FAMILY: Arial, Verdana, Helvetica, Sans-serif;FONT-SIZE: 12pt}
DIV, P, OL, UL, SPAN, TD
		{FONT-FAMILY: Arial, Verdana, Helvetica, Sans-serif;FONT-SIZE: 11pt}

</style>

<TITLE>${RECHNER} - System Documentation - $VERSION</TITLE>
</HEAD><BODY>
<BODY LINK="#0000ff" VLINK="#800080" BACKGROUND="cfg2html_back.jpg">
<H1><CENTER><FONT COLOR=blue>
<P><hr><B>$RECHNER - System Documentation</P></H1>
<hr><FONT COLOR=blue><small>Created "$DATEFULL" with " $VERSION "</font></center></B><P>
$UNAMEA
</small>

<HR><H1>Contents\n</font></H1>\n\
" >$HTML_OUTFILE

(line
if [ -x /usr/bin/banner ] ; then
  banner $RECHNER
else
  echo
  echo "                       "$RECHNER
  echo
fi;line) > $TEXT_OUTFILE
echo -e "\n" >> $TEXT_OUTFILE
echo -e "\n" > $TEXT_OUTFILE_TEMP
}

######################################################################
#  Increases the headling level
######################################################################

inc_heading_level() {
HEADL=HEADL+1
	# echo -e "<UL>\n" >> $HTML_OUTFILE
	echo -e "<UL type='square'>\n" >> $HTML_OUTFILE
}

######################################################################
#  Decreases the heading level
######################################################################

dec_heading_level() {
HEADL=HEADL-1
echo -e "</UL>" >> $HTML_OUTFILE
}

######################################################################
#  Creates an own paragraph, $1 = heading
######################################################################

paragraph() {
if [ "$HEADL" -eq 1 ] ; then
    echo -e "<HR>" >> $HTML_OUTFILE_TEMP
fi

echo "<A NAME=\"$1\">" >> $HTML_OUTFILE_TEMP
echo "<A HREF=\"#Inhalt-$1\"><H${HEADL}> $1 </H${HEADL}></A><P>" >> $HTML_OUTFILE_TEMP

# commented to eliminate the need of the gif
#echo "<IMG SRC="profbull.gif" WIDTH=14 HEIGHT=14>" >> $HTML_OUTFILE
echo "<A NAME=\"Inhalt-$1\"></A><A HREF=\"#$1\">$1</A>" >> $HTML_OUTFILE
echo -e "\nCollecting: " $1 " .\c"
echo "    $1 ---- " >> $TEXT_OUTFILE
}

######################################################################
#  Documents the single commands and their output
#  $1  = unix command,  $2 = text for the heading
######################################################################

exec_command() {

echo -e ".\c"

echo -e "\n---=[ $2 ]=----------------------------------------------------------------" | cut -c1-74 >> $TEXT_OUTFILE_TEMP
echo "       - $2" >> $TEXT_OUTFILE
######the working horse##########
TMP_EXEC_COMMAND_ERR=/tmp/exec_cmd.tmp.$$
## Modified 1/13/05 by marc.korte@oracle.com, Marc Korte, TEKsystems (150 -> 250)
EXECRES=`eval $1 2> $TMP_EXEC_COMMAND_ERR | expand | cut -c 1-250`


########### test it ############
# Gert.Leerdam@getronics.com
# Convert illegal characters for HTML into escaped ones.
#CONVSTR='
#s/</\&lt;/g
#s/>/\&gt;/g
#s/\\/\&#92;/g
#'
#EXECRES=$(eval $1 2> $TMP_EXEC_COMMAND_ERR | expand | cut -c 1-150 | sed +"$CONVSTR")

if [ -z "$EXECRES" ]
then
        EXECRES="n/a or not configured"
fi
if [ -s $TMP_EXEC_COMMAND_ERR ]
then
	echo "stderr output from \"$1\":" >> $ERROR_LOG
        cat $TMP_EXEC_COMMAND_ERR | sed 's/^/    /' >> $ERROR_LOG
fi
rm -f $TMP_EXEC_COMMAND_ERR

	## echo -e "\n" >> $HTML_OUTFILE_TEMP
	## echo -e "<A NAME=\"$2\"></A> <A HREF=\"#Inhalt-$2\"><H${HEADL}> $2 </H${HEADL}></A>\n" >>$HTML_OUTFILE_TEMP
	## echo -e "<PRE><B>$EXECRES</B></PRE>\n"  >>$HTML_OUTFILE_TEMP
	## #echo "<PRE><SMALL><B>$EXECRES</B></SMALL></PRE>\n"  >>$HTML_OUTFILE_TEMP
	## echo -e "<LI><A NAME=\"Inhalt-$2\"></A><A HREF=\"#$2\">$2</A>\n" >> $HTML_OUTFILE
	## echo -e "\n$EXECRES\n" >> $TEXT_OUTFILE_TEMP

#### new ###  #  13.08.2007, 13:28 modified by Ralph Roth

	if [ "$CFG_STINLINE" = "no" ]
	then
		## screen tips like cfg2html 1.20 when dragging mouse over link?
		echo -e "<A NAME=\"$2\"></A> <H${HEADL}><A HREF=\"#Inhalt-$2\" title=\"$1\"> $2 </A></H${HEADL}>" >>$HTML_OUTFILE_TEMP #orig screen tips by Ralph
	else
		## or more netscape friendly inline?
		echo -e "<A NAME=\"$2\"></A> <A HREF=\"#Inhalt-$2\"><H${HEADL}> $2 </H${HEADL}></A>" >>$HTML_OUTFILE_TEMP

		if [ "X$1" = "X$2" ]
			then    : #no need to duplicate, do nothing
		else
		        echo "<h6>$1</h6>">>$HTML_OUTFILE_TEMP
		fi

	fi      # screen tips inline???

        ###  Put the result out in proportional font
	echo -e "<PRE>$EXECRES</PRE>"  >>$HTML_OUTFILE_TEMP

	echo -e "<LI><A NAME=\"Inhalt-$2\"></A><A HREF=\"#$2\" title=\"$1\">$2</A>" >> $HTML_OUTFILE
	echo "$EXECRES" >> $TEXT_OUTFILE_TEMP

}

################# Schedule a job for killing commands which ###############
################# may hang under special conditions. <mortene@sim.no> #####
# Argument 1: regular expression to search process list for. Be careful
# when specifying this so you don't kill any more processes than
# those you are looking for!
# Argument 2: number of minutes to wait for process to complete.

KillOnHang() {
        TMP_KILL_OUTPUT=/tmp/kill_hang.tmp.$$
        at now + $2 minutes 1>$TMP_KILL_OUTPUT 2>&1 <<EOF
# ps -ef | grep root | grep -v grep | grep $1 | awk '{print \$2}' | sort -n -r | xargs kill
# ps -ef | grep $1 | awk '/root/ && !/grep/ {print $2}' | sort -n -r | xargs kill
ps -ef | grep $1 | awk '/root/ && !/grep/ {print $2}' | sort -n -r | xargs kill
EOF
        AT_JOB_NR=`awk ' /^job/ {print $2}' $TMP_KILL_OUTPUT`
        rm -f $TMP_KILL_OUTPUT
}

# You should always match a KillOnHang() call with a matching call
# to this function immediately after the command which could hang
# has properly finished.
CancelKillOnHang() {
        at -r $AT_JOB_NR
}

################# adds a text to the output files, rar, 25.04.99 ##########

AddText() {

        echo "<p>$*</p>" >> $HTML_OUTFILE_TEMP
        echo -e "$*\n" >> $TEXT_OUTFILE_TEMP
}
######################################################################
#  Ende des Dokumentes
######################################################################
#  end of the html document
######################################################################

close_html() {

echo "<hr>" >> $HTML_OUTFILE
echo -e "</P><P>\n<hr><FONT COLOR=blue>Created "$DATEFULL" with " $VERSION "</font>" >> $HTML_OUTFILE_TEMP
echo -e "</P><P>\n<FONT COLOR=blue>Copyright and maintained by <A HREF="mailto:$MAILTORALPH?subject=$VERSION_">Ralph Roth, ROSE SWE, </A></P></font>" >> $HTML_OUTFILE_TEMP
#echo -e " <FONT COLOR=blue>Maintained by <A HREF="mailto:$MAILTO?subject=$VERSION_">Jeroen Kleen, EMEA ISS CC Engineer</A></P></font>" >> $HTML_OUTFILE_TEMP
echo -e "<hr><center> <A HREF="http://come.to/cfg2html">[ Download cfg2html from external home page ]</b></A></center></P><hr></BODY></HTML>\n" >> $HTML_OUTFILE_TEMP
cat $HTML_OUTFILE_TEMP >>$HTML_OUTFILE
cat $TEXT_OUTFILE_TEMP >> $TEXT_OUTFILE
rm $HTML_OUTFILE_TEMP $TEXT_OUTFILE_TEMP
echo -e "\n\nCreated "$DATEFULL" with " $VERSION " \n" >> $TEXT_OUTFILE
echo -e "(c) 1998- 2012 by ROSE SWE, Ralph Roth" >> $TEXT_OUTFILE
}

my_bdf() {
# bdf summary for HPUX, Ralph Roth, 5-feb-2001
#                 Linux, dk3hg

df -k | awk '/\// \
{
	alloc += $2;
	used  += $3;
	avail += $4;

}

END {
	print  "Allocated\tUsed \t \tAvailable\tUsed (%)";
	printf "%ld \t%ld \t%ld\t \t%3.1f\n", alloc, used, avail, (used*100.0/alloc);
	}'
}

PVDisplay ( ) {
	#function used in LVM-section
	# for disk in $(strings /etc/lvmtab.d/* |grep -e hd -e sc) ;

	for disk in $(vgdisplay -v 2> /dev/null | awk -F\ + '/PV Name/ {print $4}');    # fix by Alvaro Jimenez Cabrera, Mittwoch, 5. November 2008
	do
	        pvdisplay -v $disk; 							# due to PATH problems; A. Kumpf, 21.07.06???
	done
}

#
######################################################################
# Hauptprogramm mit Aufruf der obigen Funktionen und deren Parametern
#############################  M A I N  ##############################
#

line
echo "Starting          "$VERSION       ## "/"$(arch) - won't work under Debian 5.0.8 ## /usr/bin/cfg2html-linux: line 597: arch: command not found
echo "Path to Cfg2Html  "$0
echo "HTML Output File  "$HTML_OUTFILE
echo "Text Output File  "$TEXT_OUTFILE
echo "Partitions        "$OUTDIR/$BASEFILE.partitions.save
echo "Errors logged to  "$ERROR_LOG
echo "Started at        "$DATEFULL
echo "WARNING           USE AT YOUR OWN RISK!!! :-))           <<<<<"        
line
logger "Start of $VERSION"
open_html
inc_heading_level

#
# CFG_SYSTEM
#


if [ "$CFG_SYSTEM" != "no" ]
then # else skip to next paragraph

paragraph "Linux System $distrib"
inc_heading_level

if [ -f /etc/cfg2html/systeminfo ] ; then
  exec_command "cat /etc/cfg2html/systeminfo" "System description"
fi

exec_command "cat /proc/cpuinfo; echo;" "CPU and Model info"
[ -x /usr/bin/cpufreq-info ] && exec_command cpufreq-info "CPU Freq Kernel Information"

HostNames() {
	uname -a
	echo  "DNS Domainname  = "`dnsdomainname `
	echo  "NIS Domainname  = "`domainname 2>/dev/null `
	echo  "Hostname (short)= "`hostname`
	echo  "Hostname (FQDN) = "`hostname -f`
}
exec_command  HostNames "uname & hostname"
exec_command "uname -n" "Host alias"
exec_command "uname -sr" "OS, Kernel version"
[ -x /usr/bin/lsb_release ] && exec_command "/usr/bin/lsb_release -a" "Linux Standard Base Version"
for i in /etc/*-release
do
	[ -r $i ] && exec_command "cat $i" "OS Specific Release Information ($i)"
done

posixversion() {

# wie findet man das bei Linux raus?
#echo "POSIX Version:  \c"; getconf POSIX_VERSION
#echo "POSIX Version:  \c"; getconf POSIX2_VERSION
#echo "X/OPEN Version: \c"; getconf XOPEN_VERSION
echo "LANG setting:   "$LANG
[ -r /etc/sysconfig/i18n ] && cat /etc/sysconfig/i18n
}

if [ -x /usr/bin/locale ] ; then
  exec_command posixversion "POSIX Standards/Settings"
  exec_command "locale" "locale specific information"
  export LANG="C"
  export LANG_ALL="C"
fi

exec_command "ulimit -a" "System ulimit"							#  13.08.2007, 14:24 modified by Ralph Roth
exec_command "getconf -a" "System Configuration Variables"        	## at least SLES11, #  14.06.2011, 18:53 modified by Ralph Roth #* rar *#
##### 19-Sept-2006, Ralph #####
if [ -x /usr/bin/vmstat ] ; then        ## <c/m/a>  14.04.2009 - Ralph Roth
  exec_command "vmstat 1 10" "VM-Statistics 1 10"
  exec_command "vmstat -dn;vmstat -f" "VM-Statistics (Summary)"
fi
if [ -x /usr/bin/mpstat ] ; then
  exec_command "mpstat 1 5" "MP-Statistics"
fi
if [ -x /usr/bin/iostat ] ; then
  exec_command "iostat" "IO-Statistics"
fi

# In "used memory.swap" section I would add :
# free -tl     (instead of free, because it gives some more useful infos, about HighMem and LowMem memory regions (zones))
# cat /proc/meminfo (in order to get some details of memory usage)

exec_command "free -toml;echo;free -tm;echo; swapon -s" "Used Memory and Swap"  #  04.07.2011, 16:13 modified by Ralph Roth #* rar *#
exec_command "cat /proc/meminfo" "Detailed memory usage"

# sysutils
exec_command "uptime" "Uptime"
# exec_command "sar 1 9" "System Activity Report"
# exec_command "sar -b 1 9" "Buffer Activity"

[ -x /usr/bin/procinfo ] && exec_command "procinfo -a" "System status from /proc" #  15.11.2004, 14:09 modified by Ralph Roth
# usage: pstree [ -a ] [ -c ] [ -h | -H pid ] [ -l ] [ -n ] [ -p ] [ -u ]
#               [ -G | -U ] [ pid | user]

#### 20070228 Oliver Schwabedissen, RH4/SLES9 don't support -A, RHEL 5.6 supports -A (#  08.04.2011, 11:31 modified by Ralph Roth #* rar *#)
# if [ "$REDHAT" = "yes" ] ; then ## 20100914 Alfred Menken SLES10/SLESS11 support -A
# 	exec_command "pstree -p -a -l -G" "Active Process Overview" # 090102006
# else
	exec_command "pstree -p -a  -l -G -A" "Active Process - Tree Overview" #  15.11.2004/2011, 14:09 modified by Ralph.Roth
# fi
exec_command "ps -ef | cut -c39- | sort -nr | head -25 | awk '{ printf(\"%10s   %s\\n\", \$1, \$2); }'" "Top load processes"
exec_command "ps -e -o 'vsz pid ruser cpu time args' |sort -nr|head -25" "Top memory consuming processes"

exec_command "last| grep boot" "reboots"
exec_command "alias"  "Alias"
[ -r /etc/inittab ] && exec_command "grep -vE '^#|^ *$' /etc/inittab" "inittab"
## This may report NOTHING on RHEL 3+4 ##
[ -x /sbin/chkconfig ] && exec_command "/sbin/chkconfig" "Services Startup"
[ -x /sbin/chkconfig ] && exec_command "/sbin/chkconfig --list" "Services Runlevel" # rar, fixed 2805-2005 for FC4
[ -x /sbin/chkconfig ] && exec_command "/sbin/chkconfig -l --deps" "Services Runlevel and dependencies" #*# Alexander De Bernardi 25.02.2011
[ -x /usr/sbin/service ] && exec_command "/usr/sbin/service --status-all" "Services - Status"   #  09.11.2011, 21:59 modified by Ralph Roth #* rar *#
[ -x  /usr/sbin/sysv-rc-conf ] && exec_command " /usr/sbin/sysv-rc-conf --list" "Services Runlevel" # rr, 1002-2008

if [ "$GENTOO" = "yes" ] ; then   ## 2007-02-27 Oliver Schwabedissen
  [ -x /bin/rc-status ]  && exec_command "/bin/rc-status --list" "Defined runlevels"
  [ -x /sbin/rc-update ] && exec_command "/sbin/rc-update show --verbose" "Init scripts and their runlevels"
fi

if [ -d /etc/rc.config.d ] ; then
  exec_command " grep -v ^# /etc/rc.config.d/* | grep '=[0-9]'" "Runlevel Settings"
fi
[ -r /etc/inittab ] && exec_command "awk '!/#|^ *$/ && /initdefault/' /etc/inittab" "default runlevel"
exec_command "/sbin/runlevel" "current runlevel"

##
## we want to display the Boot Messages too
## 30Jan2003 it233 FRU
if [ -e /var/log/boot.msg ] ; then
  exec_command "grep 'Boot logging' /var/log/boot.msg" "Last Boot Date"
  exec_command "grep -v '|====' /var/log/boot.msg " "Boot Messages, last Boot"
fi

# MiMe: SUSE && UNITEDLINUX
# MiMe: until SuSE 7.3: params in /etc/rc.config and below /etc/rc.config.d/
# MiMe; since SuSE 8.0 including UL: params below /etc/sysconfig
if [ "$SUSE" = "yes" ] || [ "$UNITEDLINUX" = "yes" ] ; then
  if [ -d /etc/sysconfig ] ; then
    # MiMe:
    exec_command "find /etc/sysconfig -type f -not -path '*/scripts/*' -exec grep -vE '^#|^ *$' {} /dev/null \; | sort" "Parameter /etc/sysconfig"
  fi
  if [ -e /etc/rc.config ] ; then
    # PJC: added filters for SuSE rc_ variables
    # PJC: which were in rc.config in SuSE 6
    # PJC: and moved to /etc/rc.status in 7+
    exec_command "grep -vE -e '(^#|^ *$)' -e '^ *rc_' -e 'rc.status' /etc/rc.config | sort" "Parameter /etc/rc.config"
  fi
  if [ -d /etc/rc.config.d ] ; then
    # PJC: added filters for SuSEFirewall and indented comments
    exec_command "find /etc/rc.config.d -name '*.config' -exec grep -vE -e '(^#|^ *$)' -e '^ *true$' -e '^[[:space:] ]*#' -e '[{]|[}]' {} \; | sort" "Parameter /etc/rc.config.d"
  fi
fi

if [ "$GENTOO" = "yes" ] ; then	## 2007-02-28 Oliver Schwabedissen
  exec_command "grep -vE '^#|^ *$' /etc/rc.conf | sort" "Parameter /etc/rc.conf"
  exec_command "find /etc/conf.d -type f -exec grep -vE '^#|^ *$' {} /dev/null \;" "Parameter /etc/conf.d"
fi

if [ -e /proc/sysvipc ] ; then
  exec_command "ipcs" "IPC Status"
  exec_command "ipcs -u" "IPC Summary"
  exec_command "ipcs -l" "IPC Limits"
  ## ipcs -ma ???
fi

if [ -x /usr/sbin/pwck ] ; then
  exec_command "/usr/sbin/pwck -r && echo Okay" "integrity of password files"
fi

if [ -x /usr/sbin/grpck ] ; then
  exec_command "/usr/sbin/grpck -r && echo Okay" "integrity of group files"
fi

dec_heading_level

fi # terminates CFG_SYSTEM wrapper

#
# CFG_CRON
#
if [ "$CFG_CRON" != "no" ]
then # else skip to next paragraph
paragraph "Cron and At"
inc_heading_level

for FILE in cron.allow cron.deny
	do
		if [ -r /etc/$FILE ]
		then
		exec_command "cat /etc/$FILE" "$FILE"
		else
		exec_command "echo /etc/$FILE" "$FILE not found!"
		fi
	done

## Linux SuSE user /var/spool/cron/tabs and NOT crontabs
## 30jan2003 it233 FRU
##  SuSE has the user crontabs under /var/spool/cron/tabs
##  RedHat has the user crontabs under /var/spool/cron
##  UnitedLinux uses /var/spool/cron/tabs (MiMe)
if [ "$SUSE" == "yes" ] ; then
  usercron="/var/spool/cron/tabs"
fi
if [ "$REDHAT" == "yes" ] ; then
  usercron="/var/spool/cron"
fi
if [ "$SLACKWARE" == "yes" ] ; then
  usercron="/var/spool/cron/crontabs"
fi
if [ "$DEBIAN" == "yes" ] ; then
  usercron="/var/spool/cron/crontabs"
fi
if [ "$GENTOO" == "yes" ] ; then	## 2007-02-27 Oliver Schwabedissen
  usercron="/var/spool/cron/crontabs"
fi
if [ "$UNITEDLINUX" == "yes" ] ; then
  usercron="/var/spool/cron/tabs"
fi
##
ls $usercron/* > /dev/null 2>&1
if [ $? -eq 0 ]
then
        echo -e "\n\n<B>Crontab files:</B>" >> $HTML_OUTFILE_TEMP
        for FILE in $usercron/*
        do
                exec_command "cat $FILE | grep -v ^#" "For user `basename $FILE`"
        done
else
        echo "No crontab files for user.<br>" >> $HTML_OUTFILE_TEMP
fi

##
## we do also a listing of utility cron files
## under /etc/cron.d 30Jan2003 it233 FRU
ls /etc/cron.d/* > /dev/null 2>&1
if [ $? -eq 0 ]
then
        echo -e "\n\n<br><B>/etc/cron.d files:</B>" >> $HTML_OUTFILE_TEMP
        for FILE in /etc/cron.d/*
        do
                exec_command "cat $FILE | grep -v ^#" "For utility `basename $FILE`"
        done
else
        echo "No /etc/cron.d files for utlities." >> $HTML_OUTFILE_TEMP
fi

if [ -f /etc/crontab ] ; then
  exec_command "echo -e 'Crontab:\n';cat /etc/crontab | grep -vE '^#|^ *$'" "/etc/crontab"
fi

atconfigpath="/etc"
if [ "$GENTOO" == "yes" ] ; then	## 2007-02-27 Oliver Schwabedissen
	atconfigpath="/etc/at"
fi

for FILE in at.allow at.deny

	do
		if [ -r $atconfigpath/$FILE ]
		then
			exec_command "cat $atconfigpath/$FILE " "$atconfigpath/$FILE"
		else
			exec_command "echo $atconfigpath/$FILE" "No $atconfigpath/$FILE"
		fi
	done

## work around by Ralph for missing at
#(whereis at > /dev/null) || exec_command "at -l" "AT Scheduler"
# sorry - don't work here (Michael)
# now we try this
if [ -x /usr/bin/at ] ; then
  exec_command "at -l" "AT Scheduler"
fi

#exec_command "echo -e 'Crontab:\n';cat /etc/crontab | grep -vE '#|^ *$';echo -e '\nAT Scheduler:\n';at -l" "/etc/crontab and AT Scheduler"

dec_heading_level
fi #terminate CFG_CRON wrapper
#
# CFG_HARDWARE
#
if [ "$CFG_HARDWARE" != "no" ]
then # else skip to next paragraph

paragraph "Hardware"
inc_heading_level

RAM=`awk -F': *' '/MemTotal/ {print $2}' /proc/meminfo`
# RAM=`cat /proc/meminfo | grep MemTotal | awk -F\: '{print $2}' | awk -F\  '{print $1 " " $2}'`
exec_command "echo $RAM" "Physical Memory"

## Murray Barton, 14/4/2010
DMIDECODE=`which dmidecode`; if [ -n "$DMIDECODE" ] && [ -x $DMIDECODE ] ; then exec_command "$DMIDECODE 2> /dev/null" "DMI Table Decoder"; fi

# if [ -e /usr/sbin/dmidecode ]           ## this could be moved out to common stuff (e.g. useful to get serial number, # 26.03.2010 Ralph Roth)
# then
# 	exec_command "dmidecode" "/usr/sbin/dmidecode output"
# fi

HWINFO=`which hwinfo`; if [ -n "$HWINFO" ] && [ -x $HWINFO ] ; then exec_command "$HWINFO 2> /dev/null" "Hardware List (hwinfo)"; fi
LSHW=`which lshw`; if [ -n "$LSHW" ] && [ -x $LSHW ] ; then exec_command "$LSHW" "Hardware List (lshw)"; fi ##  13.12.2004, 15:53 modified by Ralph Roth
LSDEV=`which lsdev`; if [ -n "$LSDEV" ] && [ -x $LSDEV ] ; then exec_command "$LSDEV" "Hardware List (lsdev)"; fi
LSHAL=`which lshal`; if [ -n "$LSHAL" ] && [ -x $LSHAL ] ; then exec_command "$LSHAL" "List of Devices (lshal)"; fi
LSUSB=`which lsusb`; if [ -n "$LSUSB" ] && [ -x $LSUSB ] ; then exec_command "$LSUSB" "USB devices"; fi	## SuSE? #  12.11.2004, 15:04 modified by Ralph Roth

LSPCI=`which lspci`
if [ -n "$LSPCI" ] && [ -x $LSPCI ] ; then
  exec_command "$LSPCI -v" "PCI devices"
else
  if [ -f /proc/pci ] ; then
    exec_command "cat /proc/pci" "PCI devices"
  fi
fi

PCMCIA=`grep pcmcia /proc/devices | cut -d" " -f2`
if [ "$PCMCIA" = "pcmcia"  ] ; then
  if [ -x /sbin/cardctl ] ; then
    exec_command "/sbin/cardctl status;/sbin/cardctl config;/sbin/cardctl ident" "PCMCIA"
  fi
fi
[ -r /proc/acpi/info ] && exec_command "cat /proc/acpi/info" "ACPI" #  06.04.2006, 17:44 modified by Ralph Roth

if [ -f /etc/kbd/default.kmap.gz ] ; then
  exec_command "zcat /etc/kbd/default.kmap.gz | head -1 | sed s/#//" "Keymap"
fi
exec_command "cat /proc/ioports" "IoPorts"
exec_command "cat /proc/interrupts" "Interrupts"
if [ -f /proc/scsi/scsi ] ;then
  exec_command "find /proc/scsi" "SCSI Components" #  22.11.2004, 16:08 modified by Ralph.Roth
  exec_command "cat /proc/scsi/scsi" "SCSI Devices"
else
  [ -x /usr/bin/lsscsi ] && exec_command "/usr/bin/lsscsi -lpv" "SCSI Devices"  ## Alternate Method!, Mittwoch, 16. Mrz 2011
fi

#*#
#*# Alexander De Bernard 20100423
#*#

FDISKCMD=$( which fdisk )
SMARTCTL=$( which smartctl )
GREPCMD=$( which grep )
SEDCMD=$( which sed )
AWKCMD=$( which awk )

DoSmartInfo()
{
## Bundeled by Ralph Roth to avoid massive exec_command calls under Debian Linux!  #  18.07.2011, 14:40 modified by Ralph Roth #* rar *#

    echo "Overview:"
    $SMARTCTL --scan                    #  18.07.2011, 14:58 modified by Ralph Roth #* rar *#
    echo ""

    echo "Details:"
	PHYS_DRIVES=`${FDISKCMD} -l 2>&1 | sort -u | \
		${GREPCMD} "^Disk " | \
		${GREPCMD} -vE "md[0-9]|identifier:|doesn't contain a valid" | \
		${SEDCMD} -e "s/:.*$//" |  \
		${AWKCMD} '{print $2}'`

	for drive in ${PHYS_DRIVES}
	do
        echo "---- Drive="$drive
		$SMARTCTL -P show $drive      # "SMART features of drive $drive"
		$SMARTCTL --info $drive       # "SMART information of drive $drive"
		$SMARTCTL --xall $drive       # "SMART extended information of drive $drive"
        echo ""
	done

}
if [ -x "${FDISKCMD}" -a -x "${GREPCMD}" -a -x "${SEDCMD}" -a -x "${AWKCMD}" -a -x "${SMARTCTL}" ]
then
    exec_command DoSmartInfo "SMART disk drive features and information"
fi

## rar, 13.02.2004
## Changed 15.05.2006 (09:30) by Peter Lindblom, HP, STCC EMEA, changed title from SCSI Devices SCSI Disk Devices
[ -x /usr/sbin/lssd ] && exec_command "/usr/sbin/lssd" "SCSI Disk Devices"

## Added 15.05.2006 (09:30) by Peter Lindblom, HP, STCC EMEA
[ -x /usr/sbin/lssg ] && exec_command "/usr/sbin/lssg" "Generic SCSI Devices"

## rar, 13.02.2004
## Added 15.05.2006 (09:30) by Peter Lindblom, HP, STCC EMEA, Added the echo between the command to get a new line and move it down below lssg and lssd.
[ -x /usr/sbin/adapter_info ] && exec_command "/usr/sbin/adapter_info;echo;/usr/sbin/adapter_info -v" "Adapterinfo/WWN"
### ------------------------------------------------------------------------------

#### Start of Fibre HBA info. added 12.05.2006 (15:13) by Peter Lindblom, HP, STCC EMEA

 mcat()
 {
     echo "--- $1"
     cat $1
    # done
 }

 if [ -f /tmp/fibrehba.txt ]
 then
   rm /tmp/fibrehba.txt
 fi

 # capture /proc/scsi/qla2200

 if [ -d /proc/scsi/qla2200 ]
 then
   for file in /proc/scsi/qla2200/*
    do
      mcat $file >>/tmp/fibrehba.txt
    done
 fi

 # capture /proc/scsi/qla2300

 if [ -d /proc/scsi/qla2300 ]
 then
    for file in /proc/scsi/qla300/*
    do
      mcat $file >>/tmp/fibrehba.txt
     done
 fi

 # capture /proc/scsi/qla2xxx

 if [ -d /proc/scsi/qla2xxx ]
 then
    for file in /proc/scsi/qla2xxx/*
     do
      mcat $file >>/tmp/fibrehba.txt
     done
 fi


 # capture /proc/scsi/lpfc

 if [ -d /proc/scsi/lpfc ]
 then
    for file in /proc/scsi/lpfc/*
     do
      mcat $file >>/tmp/fibrehba.txt
     done
 fi

 if [ -f /tmp/fibrehba.txt ]
 then
   exec_command "cat /tmp/fibrehba.txt" "Fibre Channel Host Bus Adapters"
   rm /tmp/fibrehba.txt
 fi

#### End of Fibre HBA info.


## rar, 13.02.2004
[ -x /usr/sbin/spmgr ] && exec_command "/usr/sbin/spmgr display" "SecurePath - Manager"
[ -r /etc/CPQswsp/sppf ] && exec_command "cat /etc/CPQswsp/sppf" "SecurePath - Bindings"
[ -r /etc/CPQswsp/hsx.conf ] && exec_command "cat /etc/CPQswsp/hsx.conf" "SecurePath - Preferred Path Settings"
[ -r /etc/CPQswsp/swsp.conf ] && exec_command "cat /etc/CPQswsp/swsp.conf" "SecurePath - Path, Load Balance & Auto restore settings"
[ -r /etc/CPQswsp/notify.ini ] && exec_command "cat /etc/CPQswsp/notify.ini" "SecurePath - email address notification settings"
[ -r /etc/CPQswsp/spmgr_alias ] && exec_command "cat /etc/CPQswsp/spmgr_alias" "SecurePath - Alias Name file"
[ -r /etc/CPQswsp/spmgr_stop_list ] && exec_command "cat /etc/CPQswsp/spmgr_stop_list" "SecurePath - reserved key word settings file"
[ -r /etc/CPQswsp/clients ] && exec_command "cat /etc/CPQswsp/clients" "SecurePath - spmgr password information"

## Changed 15.05.2006 (09:30) by Peter Lindblom, HP, STCC EMEA, Moved from the Proliant section.
[ -f /var/log/sp_log ] && exec_command "cat /var/log/sp_log" "Secure path installation log"

## Changed 15.05.2006 (09:30) by Peter Lindblom, HP, STCC EMEA, Moved from the Proliant section.
[ -f /root/sp_install_results.log ] && exec_command "cat /root/sp_install_results.log" "Secure path installation log (backup)"
if [ -e /proc/sound ] ; then
  exec_command "cat /proc/sound" "Sound Devices"
fi
if [ -e /proc/asound ] ; then
  [ -f /proc/asound/version ] && exec_command "cat /proc/asound/version" "Asound Version"
  [ -f /proc/asound/modules ] && exec_command "cat /proc/asound/modules" "Sound modules"
  [ -f /proc/asound/cards ] && exec_command "cat /proc/asound/cards" "Sound Cards"
  [ -f /proc/asound/sndstat ] && exec_command "cat /proc/asound/sndstat" "Sound Stats"
  [ -f /proc/asound/timers ] && exec_command "cat /proc/asound/timers" "Sound Timers"
  [ -f /proc/asound/devices ] && exec_command "cat /proc/asound/devices" "Sound devices"
  [ -f /proc/asound/pcm ] && exec_command "cat /proc/asound/pcm" "Sound pcm"
fi
exec_command "cat /proc/dma" "DMA Devices"
if [ -f /proc/tty/driver/serial ] ; then
   exec_command "grep -v unknown /proc/tty/driver/serial" "Serial Devices"
fi
# test this - please report it
if [ -e /proc/rd ] ; then
  exec_command "cat /proc/rd/c*/current_status" "RAID controller"
fi

# get serial information

SETSERIAL=`which setserial`
if [ -n "$SETSERIAL" ] && [ -x $SETSERIAL ]; then
  exec_command "$SETSERIAL -a /dev/ttyS0" "Serial ttyS0"
  exec_command "$SETSERIAL -a /dev/ttyS1" "Serial ttyS1"
fi

# get IDE Disk information
HDPARM=`which hdparm`
# if hdparm is installed (DEBIAN 4.0)
# -i   display drive identification
# -I   detailed/current information directly from drive

#  -i   display drive identification (SuSE 10u1)
#  -I   detailed/current information directly from drive
#  --Istdin  reads identify data from stdin as ASCII hex
#  --Istdout writes identify data to stdout as ASCII hex

# Sep 23 19:12:47 hp02 root: Start of cfg2html-linux version 1.63-2009-08-27
# Sep 23 19:13:03 hp02 kernel: hda: drive_cmd: status=0x51 { DriveReady SeekComplete Error }
# Sep 23 19:13:03 hp02 kernel: hda: drive_cmd: error=0x04Aborted Command
# Sep 23 19:13:18 hp02 root: End of cfg2html-linux version 1.63-2009-08-27

# Anpassung auf hdparm -i wegen Fehler im Syslog (siehe oben, cfg1.63)
# Ingo Metzler 23.09.2009

if [ $HDPARM ]  && [ -x $HDPARM ]; then
  exec_command "\
	if [ -e /proc/ide/hda ] ; then echo -e -n \"read from drive\"; $HDPARM -i /dev/hda;fi;\
	if [ -e /proc/ide/hdb ] ; then echo; echo -e -n \"read from drive\"; $HDPARM -i /dev/hdb;fi;\
	if [ -e /proc/ide/hdc ] ; then echo; echo -e -n \"read from drive\"; $HDPARM -i /dev/hdc;fi;\
	if [ -e /proc/ide/hdd ] ; then echo; echo -e -n \"read from drive\"; $HDPARM -i /dev/hdd;fi;"\
  "IDE Disks"

  if [ -e /proc/ide/hda ] ; then
    if grep disk /proc/ide/hda/media > /dev/null ;then
      exec_command "$HDPARM -t -T /dev/hda" "Transfer Speed"
    fi
  fi
  if [ -e /proc/ide/hdb ] ; then
    if grep disk /proc/ide/hdb/media > /dev/null ;then
      exec_command "$HDPARM -t -T /dev/hdb" "Transfer Speed"
    fi
  fi
  if [ -e /proc/ide/hdc ] ; then
    if grep disk /proc/ide/hdc/media > /dev/null ;then
      exec_command "$HDPARM -t -T /dev/hdc" "Transfer Speed"
    fi
  fi
  if [ -e /proc/ide/hdd ] ; then
    if grep disk /proc/ide/hdd/media > /dev/null ;then
      exec_command "$HDPARM -t -T /dev/hdd" "Transfer Speed"
    fi
  fi
else
# if hdparm not available
  exec_command "\
    if [ -e /proc/ide/hda/model ] ; then echo -e -n \"hda: \";cat /proc/ide/hda/model ;fi;\
    if [ -e /proc/ide/hdb/model ] ; then echo -e -n \"hdb: \";cat /proc/ide/hdb/model ;fi;\
    if [ -e /proc/ide/hdc/model ] ; then echo -e -n \"hdc: \";cat /proc/ide/hdc/model ;fi;\
    if [ -e /proc/ide/hdd/model ] ; then echo -e -n \"hdd: \";cat /proc/ide/hdd/model ;fi;"\
 "IDE Disks"
fi

if [ -e /proc/sys/dev/cdrom/info ] ; then
  exec_command "cat /proc/sys/dev/cdrom/info" "CDROM Drive"
fi

if [ -e /proc/ide/piix ] ; then
   exec_command "cat /proc/ide/piix" "IDE Chipset info"
fi

# Test HW Health
# MiMe
if [ -x /usr/bin/sensors ] ; then
  if [ -e /proc/sys/dev/sensors/chips ] ; then
    exec_command "/usr/bin/sensors" "Sensors"
  fi
fi

if [ -x /usr/sbin/xpinfo ]
then
  XPINFOFILE=$OUTDIR/`hostname`_xpinfo.csv
  /usr/sbin/xpinfo -d";" | grep -v "Scanning" > $XPINFOFILE

  AddText "The XP-Info configuration was additionally dumped into the file <b>$XPINFOFILE</b> for further usage"

# remarked due to enhancement request by Martin Kalmbach, 25.10.2001
#  exec_command "/usr/sbin/xpinfo|grep -v Scanning" "SureStore E Disk Array XP Mapping (xpinfo)"

  exec_command "/usr/sbin/xpinfo -r|grep -v Scanning" "SureStore E Disk Array XP Disk Mechanisms"
  exec_command "/usr/sbin/xpinfo -i|grep -v Scanning" "SureStore E Disk Array XP Identification Information"
  exec_command "/usr/sbin/xpinfo -c|grep -v Scanning" "SureStore E Disk Array XP (Continuous Access and Business Copy)"
# else
# [ -x /usr/contrib/bin/inquiry256.ksh ] && exec_command "/usr/contrib/bin/inquiry256.ksh" "SureStore E Disk Array XP256 Mapping (inquiry/obsolete)"
fi

dec_heading_level

fi # terminates CFG_HARDWARE wrapper

######################################################################

##### ToDo: check for Distribution #####

if [ "$CFG_SOFTWARE" != "no" ]
then # else skip to next paragraph

  paragraph "Software"
  inc_heading_level

  # Debian
  if [ "$DEBIAN" = "yes" ] ; then
    dpkg --get-selections | awk '!/deinstall/ {print $1}' > /tmp/cfg2html-debian.$$
    exec_command "column /tmp/cfg2html-debian.$$" "Packages installed"
    rm -f /tmp/cfg2html-debian.$$
    AddText "Hint: to reinstall this list use:"
    AddText "awk '{print \$1\"\\n\"\$2}' this_list |  dpkg --set-selections"
    exec_command "dpkg -C" "Misconfigured Packages"
#   # { changed/added 25.11.2003 (14:29) by Ralph Roth }
    if [ -x /usr/bin/deborphan ] ; then
      exec_command "deborphan" "Orphaned Packages"
      AddText "Hint: deborphan | xargs aptitude -y purge"	# rar, 16.02.04
    fi
    exec_command "dpkg -l" "Detailed list of installed Packages"
    AddText "$(dpkg --version|grep program)"
    exec_command "grep -vE '^#|^ *$' /etc/apt/sources.list" "Installed from"
    [ -x /usr/bin/dpigs ] && exec_command "/usr/bin/dpigs" "Largest installed packages"
  fi
  # end Debian

  # SUSE
  # MiMe: --last tells date of installation
  if [ "$SUSE" = "yes" ] || [ "$UNITEDLINUX" = "yes" ] ; then
    exec_command "rpm -qa --last" "Packages installed (last first)"		#*#   Alexander De Bernardi //09.03.2010/rr
    exec_command "rpm -qa | sort -d -f" "Packages installed (sorted)"		#*#   Alexander De Bernardi //09.03.2010/rr
    exec_command "rpm -qa --queryformat '%{NAME}\n' | sort -d -f" "Packages installed, Name only (sorted)"		#*#   Alexander De Bernardi //21.04.2010/rr
    exec_command "rpm -qa --queryformat '%-50{NAME} %{VENDOR}\n' | sort -d -f" "Packages installed, Name and Vendor only (sorted)"		#*#   Alexander De Bernardi //21.04.2010/rr
    exec_command "rpm --querytags" "RPM Query Tags"		#*#   Alexander De Bernardi //21.04.2010/rr
    if [ -x /usr/bin/zypper ]
    then
        if [ -r /etc/zypp/zypp.conf ]       ## fix for JW's SLES 10
        then
            exec_command "zypper ls; echo ''; zypper pt" "zypper: Services and Patterns"        #*#   Ralph Roth, Mittwoch, 16. Mrz 2011
            exec_command "zypper ps" "zypper: Processes which need restart after update"	#*#   Alexander De Bernardi 17.02.2011
            exec_command "zypper lr --details" "zypper: List repositories"			#*#   Alexander De Bernardi 17.02.2011
            exec_command "zypper lu" "zypper: List pending updates"				#*#   Alexander De Bernardi 17.02.2011
            exec_command "zypper lp" "zypper: List pending patches"				#*#   Alexander De Bernardi 17.02.2011
            exec_command "zypper pa" "zypper: List all available packages"			#*#   Alexander De Bernardi 17.02.2011
            exec_command "zypper pa --installed-only" "zypper: List installed packages"		#*#   Alexander De Bernardi 17.02.2011
            exec_command "zypper pa --uninstalled-only" "zypper: List not installed packages"	#*#   Alexander De Bernardi 17.02.2011
        else
            AddText "zypper found, but it is not configured!"
        fi
    fi
  fi
  # end SUSE

  # REDHAT
  if [ "$REDHAT" = "yes" ] || [ "$MANDRAKE" = "yes" ] ; then
    exec_command "rpm -qia | grep -e Source -e Name" "Packages installed"
    exec_command "rpm -qa | sort -d -f" "Packages installed (sorted)"       #*#   Alexander De Bernardi //09.03.2010 12:31/rr
    exec_command "rpm -qa --queryformat '%{NAME}\n' | sort -d -f" "Packages installed, Name only (sorted)"		#*#   Alexander De Bernardi //21.04.2010/rr
    exec_command "rpm -qa --queryformat '%-50{NAME} %{VENDOR}\n' | sort -d -f" "Packages installed, Name and Vendor only (sorted)"		#*#   Alexander De Bernardi //21.04.2010/rr
    exec_command "rpm --querytags" "RPM Query Tags"		#*#   Alexander De Bernardi //21.04.2010/rr
    if [ -x /usr/bin/yum ]#
    then
        exec_command "yum history" "YUM: Last actions performed"
    fi  # yum
  fi
  # end REDHAT

  # SLACKWARE
  if [ "$SLACKWARE" = "yes" ] ; then
    exec_command "ls /var/log/packages " "Packages installed"
  fi
  # end SLACKWARE
  # GENTOO, rr, 15.12.2004, Rob
  if [ "$GENTOO" = "yes" ] ; then
    #exec_command "qpkg -I -v|sort" "Packages installed"
    #exec_command "qpkg -I -v  --no-color |sort" "Packages installed" ## Rob Fantini, 15122004
    exec_command "qlist -I -v --nocolor |sort" "Packages installed" ## 2007-02-21 Oliver Schwabedissen
  fi
  # end GENTOO
#### programming stuff ####
# plugin for cfg2html/linux/hpux #  22.11.2005, 16:03 modified by Ralph Roth
# @(#)$Id: cfg2html-linux,v 2.37 2011-12-28 10:52:58 ralproth Exp $

ProgStuff()
{
 for i in libtoolize libtool automake autoconf autoheader g++ gcc make flex sed
 do
  (which $i 2> /dev/null) && (echo -n "$i: ";$i --version | head -1)  #  09.01.2008, 14:49 modified by Ralph Roth
 done
}
 exec_command ProgStuff "Software Development: Programs and Versions"

  dec_heading_level

fi # terminates CFG_SOFTWARE wrapper

######################################################################
if [ "$CFG_FILESYS" != "no" ]
then # else skip to next paragraph

paragraph "Filesystems, Dump- and Swapconfiguration"
inc_heading_level


display_fs_param (  ) {
#function used in FILESYS added 2011.09.02 by Peter Boysen
 for fs in $(grep ext[2-4] /proc/mounts | awk '{print $1}' | sort -u)
 do 
   dumpe2fs -h $fs  2> /dev/null   ## -> dumpe2fs 1.41.3 (12-Oct-2008)
   echo
done
}

exec_command "grep -v '^#' /etc/fstab | column -t" "Filesystem Tab"  # 281211, rr
exec_command "df -k" "Filesystems and Usage"
exec_command "my_bdf" "All Filesystems and Usage"
if [ -x /sbin/dumpe2fs ]
then
   exec_command "display_fs_param" "Filesystems parameters"
fi 
exec_command "mount" "Local Mountpoints"
# ** rar **
PartitionDump()
{
	if [ -x /sbin/fdisk ]
	then
		if [ -x /sbin/parted ]
		then
			for i in $(fdisk -l| grep "^Disk " | grep "/dev/"|cut -f1 -d:|cut -f2 -d" ")    #  10.11.2011, 22:53 modified by Ralph Roth #* rar *#
			do
				/sbin/parted -s $i print # The -s option avoids prompts that cause parted to wait forever for user interaction.
			done
		else
			/sbin/fdisk -ul      ## -cul
		fi
	fi
}
exec_command PartitionDump "Disk Partition Layout"        #  30.03.2011, 20:00 modified by Ralph Roth #** rar **#
#
if [ -x /sbin/sfdisk ]
then
	sfdisk -d > $OUTDIR/$BASEFILE.partitions.save
	exec_command "cat $OUTDIR/$BASEFILE.partitions.save" "Disk Partitions to restore from"
	AddText "To restore your partitions use the saved file: $BASEFILE.partitions.save, read the man page for sfdisk for usage. (Hint: sfdisk --force /dev/device < file.save)"
fi
#*#
#*# Alexander De Bernard 20100310
#*#

MD_FILE="/etc/mdadm.conf"
MD_CMD="/sbin/mdadm"

if [ -f ${MD_FILE} ]
then
	exec_command "grep -vE '^#|^ *$' ${MD_FILE}" "MD Configuration File"
	if [ -x ${MD_CMD} ]
	then
		MD_DEV=$(grep "ARRAY" ${MD_FILE} | awk '{print $2;}')
		for d in "$MD_DEV"
		do
			exec_command "${MD_CMD} --detail ${d}" "MD Device setup of $d"
		done
	else
		AddText "${MD_FILE} exists but no ${MD_CMD} command"
	fi
fi

# for LVM using sed
exec_command "/sbin/fdisk -l|sed 's/8e \ Unknown/8e \ LVM/g'" "Disk Partitions"

if [ -f /etc/exports ] ; then
    exec_command "grep -vE '^#|^ *$' /etc/exports" "NFS Filesystems"
fi

dec_heading_level

fi # terminates CFG_FILESYS wrapper

###########################################################################
## 3/6/08 New: RedHat multipath config  by krtmrrsn@yahoo.com, Marc Korte.
if [ $REDHAT = "yes" ] && [ -n $(ps -ef | awk '/\/sbin\/multipathd/ {print $NF}') ] ; then
#FIXME#if [ $REDHAT = "yes" ] && [ $(pgrep multipathd) ] ; then
    if [ -x /sbin/multipath ]   #  10.11.2011, 22:50 modified by Ralph Roth #* rar *#
    then
      paragraph "Multipath Configuration"
      inc_heading_level

      exec_command "rpm -qa | grep multipath" "Multipath Package Version"
      exec_command "chkconfig --list multipathd" "Multipath Service Status"
      exec_command "/sbin/multipath -v2 -d -ll" "Multipath Devices Basic Information"
      exec_command "/sbin/multipath -v3 -d -ll" "Multipath Devices Detailed Information"
      exec_command "grep -vE '^#|^ *$' /etc/multipath.conf" "Multipath Configuration File"
      exec_command "for MultiPath in \$(/sbin/multipath -v1 -d -l); do ls -l /dev/mapper/\${MultiPath}; done" "Device Mapper Files"
      exec_command "cat /var/lib/multipath/bindings" "Multipath Bindings"

      dec_heading_level
    fi
fi

###########################################################################
if [ "$CFG_LVM" != "no" ]
then # else skip to next paragraph

	paragraph "LVM"
	inc_heading_level

    [ -x /sbin/blkid ] && exec_command "blkid" "Block Device Attributes"    #  07.11.2011, 21:42 modified by Ralph Roth #* rar *#
    [ -x /sbin/pvs ] && exec_command "pvs" "Physical Volumes"         # if LVM2 installed       #  07.11.2011, 21:45 modified by Ralph Roth #* rar *#

	# WONT WORK WITH HP RAID!
	LVMFDISK=$(/sbin/fdisk -l | grep "LVM$")

	if  [ -n "$LVMFDISK" -o -s /etc/lvmtab -o /etc/lvm/lvm.conf ]
    then # <m>  11.03.2008, 1158 -  Ralph Roth
    	vgdisplay -s > /dev/null 2>&1 #  10032008 modified by Ralph.Roth
    	# due to LVM2 (doesn't use /etc/lvmtab anymore), but should be compatible to LVM1; A. Kumpf
    	if [ "$?" = "0" ] ; then
    	      AddText "The system file layout is configured using the LVM (Logical Volume Manager)"
    	# choose between LVM1 and LVM2 because of different syntaxes; A. Kumpf, 21.07.06
    	     if [ -x "/sbin/lvm" ]; then
    	       LVM_VER=2
    	     else
    	       LVM_VER=1
    	     fi
    	    #
    		    case "$LVM_VER" in
    		    "1")
    		      exec_command "lvscan --version" "LVM Version"
    		      exec_command "ls -la /dev/*/group" "Volumegroup Device Files"
    		      # { changed/added 29.01.2004 (11:15) by Ralph Roth } - sr by winfried knobloch for Serviceguard
    		      exec_command "cat /proc/lvm/global" "LVM global info"
    		      exec_command "vgdisplay -v | awk -F' +' '/PV Name/ {print \$4}'" "Available Physical Groups"
    		      exec_command "vgdisplay -s | awk -F\\\" '{print \$2}'" "Available Volume Groups"
    		      exec_command "vgdisplay -v | awk -F' +' '/LV Name/ {print \$3}'" "Available Logical Volumes"
    		      ;;
    		    "2")
    		      exec_command "ls -al /dev/mapper/*" "Volumegroup Device Files"
    		      exec_command "lvm version" "LVM global info"
    		      exec_command "vgdisplay -v | awk -F' +' '/PV Name/ {print \$4}'" "Available Physical Groups"
    		      exec_command "vgdisplay -s | awk -F\\\" '{print \$2}'" "Available Volume Groups"
    		      exec_command "vgdisplay -v | awk -F' +' '/LV Name/ {print \$4}'" "Available Logical Volumes"
                  [ -x /sbin/vgs ] && exec_command "/sbin/vgs -o vg_name,lv_name,devices" "Detailed Volume Groups Report" #  27.10.2011 #* rar *# EHR by Jim Bruce
                  exec_command "lvs -o +devices" "Logical Volumes"      #  07.11.2011, 21:46 modified by Ralph Roth #* rar *#
    		      ;;
                  *)
                  AddText "Unsupported (new) LVM version ($LVM_VER)!"
                  ;;
    		    esac
    	    #
    	      exec_command "vgdisplay -v" "Volumegroups"
    	      exec_command PVDisplay "Physical Devices used for LVM"
    	      AddText "Note: Run vgcfgbackup on a regular basis to backup your volume group layout"
    	    else
    	      # if vgdisplay exist, but no LV configured (dk3hg 21.02.03)
    	      AddText "LVM binaries found, but this system seems to be configured with whole disk layout (WDL)"
    	fi
	else
		AddText "This system seems to be configured with whole disk layout (WDL)"
	fi

	# MD Tools, Ralph Roth

	if [ -r /etc/raidtab ]
	then
		exec_command "cat /proc/mdstat" "Software RAID: mdstat"
		exec_command "cat /etc/raidtab" "Software RAID: raidtab"
		[ -r /proc/devices/md ] && exec_command "cat /proc/devices/md" "Software RAID: MD Devices"
	fi

	dec_heading_level

fi # terminates CFG_LVM wrapper

###########################################################################
if [ "$CFG_NETWORK" != "no" ]
then # else skip to next paragraph

  paragraph "Network Settings"
  inc_heading_level

  exec_command "/sbin/ifconfig" "LAN Interfaces Settings (ifconfig)"    #D011 -- 16. Mrz 2011,  28. Dezember 2011, ER by Heiko Andresen
  exec_command "ip addr" "LAN Interfaces Settings (ip addr)"            #D011 -- 16. Mrz 2011,  28. Dezember 2011, ER by Heiko Andresen
  exec_command "ip -s l" "Detailed NIC Statistics"                      #07.11.2011, 21:33 modified by Ralph Roth #* rar *#

  #exec_command "for interface in \$(lanscan|grep 'lan. '|awk '{print \$5}'|sort) ; do ifconfig \$interface; done" "LAN Interface Configuration"

    if [ -x /usr/sbin/ethtool ]     ###  22.11.2010, 23:44 modified by Ralph Roth
    then
    	LANS=$(ifconfig|grep ^[a-z]|grep -v ^lo|awk '{print $1;}')
    	for i in $LANS
    	do
    	 	exec_command "/usr/sbin/ethtool $i 2>/dev/null; /usr/sbin/ethtool -i $i" "Ethernet Settings for Interface "$i
    	done
    fi

      if [ $DEBIAN = "yes" ] ; then
        if [ -f /etc/network/interfaces ] ; then
          exec_command "grep -vE '(^#|^$)' /etc/network/interfaces" "Netconf Settings"
        fi
      fi

    ## Added 3/05/08 by krtmrrsn@yahoo.com, Marc Korte, display ethernet
    ##  LAN and route config files for RedHat.
  if [ $REDHAT = "yes" ] ; then
      ## There will always be at least ifcfg-lo.
    exec_command "for CfgFile in /etc/sysconfig/network-scripts/ifcfg-*; do printf \"\n\n\$(basename \${CfgFile}):\n\n\"; cat \${CfgFile}; done" "LAN Configuration Files"
      ## Check first that any route-* files exist ("grep  -q ''" exit status).
    exec_command "if grep -q '' /etc/sysconfig/network-scripts/route-*; then for RouteCfgFile in /etc/sysconfig/network-scripts/route-*; do printf \"\n\n\$(basename \${RouteCfgFile}):\n\n\"; cat \${RouteCfgFile}; done; fi" "Route Configuration Files"
  fi
    ## End Marc Korte display ethernet LAN config files.

  [ -x /sbin/mii-tool ] && exec_command "/sbin/mii-tool -v" "MII Status"
  [ -x /sbin/mii-diag ] && exec_command "/sbin/mii-diag -a" "MII Diagnostics"

    exec_command "ip route" "Network Routing"           #  07.11.2011, 21:37 modified by Ralph Roth #* rar *#
    exec_command "ip neigh" "Network Neighbourhood"     #  07.11.2011, 21:38 modified by Ralph Roth #* rar *#

  NETSTAT=`which netstat`
  if [ $NETSTAT ]  && [ -x $NETSTAT ]; then
    # test if netstat version 1.38, because some options differ in older versions
    # MiMe: '\' auf awk Zeile wichtig
    RESULT=`netstat -V | awk '/netstat/ {
        if ( $2 < 1.38 ) {
          print "NO"
        } else { print "OK" }
      }'`
    exec_command "netstat -r" "Routing Tables"
    #exec_command "if [ "$RESULT" = "OK" ] ; then netstat -gi; fi" "Interfaces"
    if [ "$RESULT" = "OK" ]
      then
       exec_command "netstat -gi" "Interfaces"
       exec_command "netstat -tlpn" "TCP Daemons acceppting connection"
       exec_command "netstat -ulpn" "UDP Daemons acceppting connection"
      fi
    ## Added 4/07/06 by krtmrrsn@yahoo.com, Marc Korte, probe and display
     ##        kernel interface bonding info.
     if [ -e /proc/net/bonding ]; then
       for BondIF in `ls -1 /proc/net/bonding`
       do
         exec_command "cat /proc/net/bonding/$BondIF" "Bonded Interfaces: $BondIF"
       done
     fi
     ## End Marc Korte kernel interface bonding addition.

    exec_command "netstat -s" "Summary statistics for each protocol"
    exec_command "netstat -i" "Kernel Interface table"
    # MiMe: iptables since 2.4.x
    # MiMe: iptable_nat realisiert dabei das Masquerading
    # MiMe: Details stehen in /proc/net/ip_conntrack
    if [ -e /proc/net/ip_masquerade ]; then
      exec_command "netstat -M" "Masqueraded sessions"
    fi
    if [ -e /proc/net/ip_conntrack ]; then
      exec_command "cat /proc/net/ip_conntrack" "Masqueraded sessions"
    fi
    exec_command "netstat -an" "list of all sockets"
  fi

  DIG=`which dig`
  if [ -n "$DIG" ] && [ -x $DIG ] ; then
    exec_command "dig `hostname -f`" "dig hostname"
  else
    NSLOOKUP=`which nslookup`
    if [ -n "$NSLOOKUP" ] && [ -x $NSLOOKUP ] ; then
      exec_command "nslookup `hostname -f`" "Nslookup hostname"
    fi
  fi

  exec_command "grep -vE '^#|^ *$' /etc/hosts" "/etc/hosts"
#
  if [ -f /proc/sys/net/ipv4/ip_forward ] ; then
    FORWARD=`cat /proc/sys/net/ipv4/ip_forward`
    if [ $FORWARD = "0" ] ; then
      exec_command "echo \"IP forward disabled\"" "IP forward"
    else
      exec_command "echo \"IP forward enabled\"" "IP forward"
    fi
  fi

  if [ -r /proc/net/ip_fwnames ] ; then
    if [ -x /sbin/ipchains ] ;then
      exec_command "/sbin/ipchains -n -L forward" "ipfilter forward settings"
      exec_command "/sbin/ipchains -L -v" "ip filter settings"
    fi
  fi

  if [ -r /proc/net/ip_tables_names ] ; then
    if [ -x /sbin/iptables ] ; then
      exec_command "/sbin/iptables -L -v --line-numbers" "Firewall: iptables rules and chains" ## rr, 030604 -v added, 101111, rar
      exec_command "/sbin/iptables-save -c" "Firewall: iptables saved rules" ## rr, 120704 added, -c 101111, rar
    fi
  fi

  if [ -x /usr/sbin/tcpdchk ] ; then
    exec_command "/usr/sbin/tcpdchk -v" "tcpd wrapper"
    exec_command "/usr/sbin/tcpdchk -a" "tcpd warnings"
  fi

  [ -f /etc/hosts.allow ] && exec_command "grep  -vE '^#|^ *$' /etc/hosts.allow" "hosts.allow"
  [ -f /etc/hosts.deny ] && exec_command "grep  -vE '^#|^ *$' /etc/hosts.deny" "hosts.deny"

  #exec_command "nettl -status trace" "Nettl Status"

  if [ -f /etc/gated.conf ] ; then
      exec_command "cat /etc/gated.conf" "Gate Daemon"
  fi

  if [ -f /etc/bootptab ] ; then
      exec_command "grep -vE '(^#|^ *$)' /etc/bootptab" "BOOTP Daemon Configuration"
  fi

  if [ -r /etc/inetd.conf ]; then
    exec_command "grep -vE '^#|^ *$' /etc/inetd.conf" "Internet Daemon Configuration"
  fi
  #  02.05.2005, 15:23 modified by Ralph Roth

  # RedHat default
  ## exec_command "grep -vE '^#|^ *$' /etc/inetd.conf" "Internet Daemon Configuration"
  if [ -d /etc/xinetd.d ]; then
    # mdk/rh has a /etc/xinetd.d directory with a file per service
    exec_command "cat /etc/xinetd.d/*|grep -vE '^#|^ *$'" "/etc/xinetd.d/ section"
  fi

  #exec_command "cat /etc/services" "Internet Daemon Services"
  if [ -f /etc/resolv.conf ] ; then
     exec_command "grep -vE '^#|^ *$' /etc/resolv.conf;echo; ( [ -f /etc/nsswitch.conf ] &&  grep -vE '^#|^ *$' /etc/nsswitch.conf)" "DNS & Names"
  fi
  [ -r /etc/bind/named.boot ] && exec_command "grep -v '^;' /etc/named.boot"  "DNS/Named"

	if [ -x /usr/sbin/nullmailer-send ]
	then
		:               ##  provides sendmail which NO options
	else
	  if [ ! -f /etc/sendmail.cf ] ; then
	    /usr/sbin/sendmail -bV 2> /dev/null > /dev/null && exec_command "/usr/sbin/sendmail -bV" "Sendmail/Exim Version" #  23.03.2006, 13:20 modified by Ralph Roth
	  else
	    ## exec_command "/usr/sbin/sendmail -bv -d0.1 testuser@test.host" "Sendmail Version" ## hangs Ubuntu 9.04/karmic
	    exec_command "echo \$Z | /usr/sbin/sendmail -bt -d" "Sendmail Version"               ## new workaround? #  28.01.2010, 21:24 modified by Ralph Roth
	  fi
	fi

  aliasespath="/etc"
  if [ "$GENTOO" == "yes" ] ;then	## 2007-02-27 Oliver Schwabedissen
    aliasespath="/etc/mail"
  fi
  if [ -f $aliasespath/aliases ] ; then
    exec_command "grep -vE '^#|^ *$' $aliasespath/aliases" "Email Aliases"
  fi
  #exec_command "grep -vE '^#|^$' /etc/rc.config.d/nfsconf" "NFS settings"
  exec_command "ps -ef|grep -E '[Nn]fsd|[Bb]iod'" "NFSD and BIOD utilization"	## fixed 2007-02-28 Oliver Schwabedissen

  # if portmap not available, do nothing
  RES=`ps xau | grep [Pp]ortmap`
  if [ -n "$RES" ] ; then
    exec_command "rpcinfo -p " "RPC (Portmapper)"
    # test if mountd running
    MOUNTD=`rpcinfo -p | awk '/mountd/ {print $5; exit}'`
  #  if [ "$MOUNTD"="mountd" ] ; then
    if [ -n "$MOUNTD" ] ; then
      exec_command "rpcinfo -u 127.0.0.1 100003" "NSFD responds to RPC requests"
      SHOWMOUNT=`which showmount`	## 2007-02-27 Oliver Schwabedissen
      if [ $SHOWMOUNT ] && [ -x $SHOWMOUNT ] ; then
        exec_command "$SHOWMOUNT -a" "Mounted NFS File Systems"
      fi
      # SUSE
      if [ -x /usr/lib/autofs/showmount ] ; then
        exec_command "/usr/lib/autofs/showmount -a" "Mounted NFS File Systems"
      fi
      if [ -f /etc/auto.master ] ;then
        exec_command "grep -vE '^#|^$' /etc/auto.master" "NFS Automounter Master Settings"
      fi
      if [ -f /etc/auto.misc ] ;then
        exec_command "grep -vE '^#|^$' /etc/auto.misc" "NFS Automounter misc Settings"
      fi
      if [ -f /proc/net/rpc/nfs ] ; then
        exec_command "nfsstat" "NFS Statistics"
      fi
    fi # mountd
  fi

  #(ypwhich 2>/dev/null>/dev/null) && \
  #    (exec_command "what /usr/lib/netsvc/yp/yp*; ypwhich" "NIS/Yellow Pages")

  # ntpq live sometimes in /usr/bin or /usr/sbin
  NTPQ=`which ntpq`
  # if [ $NTPQ ] && [ -x $NTPQ ] ; then
  if [ -n "$NTPQ" ] && [ -x "$NTPQ" ] ; then      # fixes by Ralph Roth, 180403
    exec_command "$NTPQ -p" "XNTP Time Protocol Daemon"
  fi
  [ -f /etc/ntp.conf ] && exec_command "grep  -vE '^#|^ *$' /etc/ntp.conf" "ntp.conf"
  [ -f /etc/shells ] && exec_command "grep  -vE '^#|^ *$'  /etc/shells" "FTP Login Shells"
  [ -f /etc/ftpusers ] && exec_command "grep  -vE '^#|^ *$'  /etc/ftpusers" "FTP Rejections (/etc/ftpusers)"
  [ -f /etc/ftpaccess ] && exec_command "grep  -vE '^#|^ *$'  /etc/ftpaccess" "FTP Permissions (/etc/ftpaccess)"
  [ -f /etc/syslog.conf ] && exec_command "grep  -vE '^#|^ *$' /etc/syslog.conf" "syslog.conf"
  [ -f /etc/syslog-ng/syslog-ng.conf ] && exec_command "grep  -vE '^#|^ *$' /etc/syslog-ng/syslog-ng.conf" "syslog-ng.conf"
  [ -f /etc/host.conf ] && exec_command "grep  -vE '^#|^ *$' /etc/host.conf" "host.conf"

  ######### SNMP ############
  [ -f /etc/snmpd.conf ] && exec_command "grep -vE '^#|^ *$' /etc/snmpd.conf" "Simple Network Management Protocol (SNMP)"
  [ -f /etc/snmp/snmpd.conf ] && exec_command "grep -vE '^#|^ *$' /etc/snmp/snmpd.conf" "Simple Network Management Protocol (SNMP)"
  [ -f /etc/snmp/snmptrapd.conf ] && exec_command "grep -vE '^#|^ *$' /etc/snmp/snmptrapd.conf" "SNMP Trapdaemon config"

  [ -f  /opt/compac/cma.conf ] && "grep -vE '^#|^ *$' /opt/compac/cma.conf" "HP Insight Management Agents configuration"

  ## ssh
  [ -f /etc/ssh/sshd_config ] && exec_command "grep -vE '^#|^ *$' /etc/ssh/sshd_config" "sshd config"
  [ -f /etc/ssh/ssh_config ] && exec_command "grep -vE '^#|^ *$' /etc/ssh/ssh_config" "ssh config"

  dec_heading_level

fi # terminates CFG_NETWORK wrapper


###########################################################################
if [ "$CFG_KERNEL" != "no" ]
then # else skip to next paragraph

# In the v2.6 Linux kernel, preventing the starvation of requests in general,
# and read requests in particular, was a primary focus of the new (four) I/O
# schedulers. The default I/O Elevator in the v2.6 Linux kernel is the
# anticipatory scheduler. RedHat RHEL4/5.6 and Novell/SUSE SLES 9-11
# installations overwrite this with the CFQ scheduler.
# see also
#     # blockdev -v --getra /dev/sda
#     get readahead: 1024
#
    GetElevator()
    {
    	for i in $(find /sys/devices/ | grep /queue/scheduler | grep -v -e /loop -e /block/ram)
    	do
     		echo $i": "$(cat $i)
    	done

    }

	paragraph "Kernel, Modules and Libraries" "Kernelparameters"
	inc_heading_level

	if [ -f /etc/lilo.conf ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/lilo.conf" "Lilo Boot Manager"
	  exec_command "/sbin/lilo -q" "currently mapped files"
	fi

	if [ -f /boot/grub/menu.lst ] ; then
	  exec_command "grep -vE '^#|^ *$' /boot/grub/menu.lst" "GRUB Boot Manager" # rar
	fi

	if [ -f /etc/palo.conf ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/palo.conf" "Palo Boot Manager"
	fi

	exec_command "ls -l /boot" "Files in /boot" # 2404-2006, ralph
	exec_command "lsmod" "Loaded Kernel Modules" # Fix/ER by VG - on RHEL 5.3, it is : /sbin/lsmod / on Ubuntu 10.04 it is /bin/lsmod,
	exec_command "ls -l /lib/modules" "Available Modules Trees"  # rar

	if [ -f /etc/modules.conf ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/modules.conf" "modules.conf"
	fi
	if [ -f /etc/modprobe.conf ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/modprobe.conf" "modprobe.conf (all settings)"
	  exec_command "grep -r = /etc/modprob*   | grep -v ':#'" "modprobe related settings "
	fi

	if [ -f /etc/sysconfig/kernel ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/sysconfig/kernel" "Modules for the ramdisk"	# rar, SuSE only
	fi

	if [ "$DEBIAN" = "no" ] && [ "SLACKWARE" = "no" ] ; then
	        which rpm > /dev/null  && exec_command "rpm -qa | grep -e ^k_def -e ^kernel -e k_itanium -e k_smp -e ^linux" "Kernel RPMs" # rar, SuSE+RH+Itanium2
	fi

	if [ "$DEBIAN" = "yes" ] ; then
	  	exec_command "dpkg -l | grep -i -e Kernel-image -e Linux-image" "Kernel related DEBs"
	fi
	[ -x /usr/sbin/get_sebool ] && exec_command "/usr/sbin/get_sebool -a" "SELinux Settings"

	who -b 2>/dev/null > /dev/null && exec_command "who -b" "System boot" #  23.03.2006, 13:18 modified by Ralph Roth
	exec_command "cat /proc/cmdline" "Kernel commandline"

	exec_command "getconf GNU_LIBC_VERSION" "libc Version (getconf)"

	if [ -r  /lib/libc.so.5 ]
	then
		if [ -x  /lib/libc.so.5 ]
		then
			exec_command "/lib/libc.so.5" "libc5 Version"  # Mandrake 9.2
		else
			exec_command "strings /lib/libc.so.5 | grep \"release version\"" "libc5 Version (Strings)"
			############# needs work out!
			## rpm ## ldd
		fi
	fi

	if [ -r  /lib/libc.so.6 ]
	then
		if [ -x  /lib/libc.so.6 ]
		then
			exec_command "/lib/libc.so.6" "libc6 Version"  # Mandrake 9.2
		else
			exec_command "strings /lib/libc.so.6 | grep \"release version\"" "libc6 Version (Strings)"
			############# needs work out!
			## rpm ## ldd
		fi
	fi

	if [ "$DEBIAN" = "no" ] && [ "$SLACKWARE" = "no" ] && [ "$GENTOO" = "no" ] ; then  ## fixed 2007-02-27 Oliver Schwabedissen
	        which rpm > /dev/null  && exec_command "rpm -qi glibc" "libc6 Version (RPM)" # rar, SuSE+RH
	fi

	exec_command "/sbin/ldconfig -vN" "Run-time link bindings"

	# MiMe: SuSE patched kernel params into /proc
	if [ -e /proc/config.gz ] ; then
	  exec_command "zcat /proc/config.gz | grep -vE '^#|^ *$'" "Kernelparameter /proc/config.gz"
	else
	  if [ -e /usr/src/linux/.config ] ; then
	    exec_command "grep -vE '^#|^ *$' /usr/src/linux/.config" "Kernelsource .config"
	  fi
	fi

	##
	## we want to display special kernel configuration as well
	## done in /etc/init.d/boot.local
	## 31Jan2003 it233 U.Frey FRU
	if [ -e /etc/init.d/boot.local ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/init.d/boot.local" "Additional Kernel Parameters init.d/boot.local"
	fi

	if [ -x /sbin/sysctl ] ; then ##  11.01.2010, 10:44 modified by Ralph Roth
	  exec_command "/sbin/sysctl -a | sort -u 2> /dev/null " "configured kernel variables at runtime"
	  exec_command "cat /etc/sysctl.conf | sort -u |grep -v -e ^# -e ^$" "configured kernel variables in /etc/sysctl.conf"
	fi

	if [ -f "/etc/rc.config" ] ; then
	   exec_command "grep ^INITRD_MODULES /etc/rc.config" "INITRD Modules"
	fi

    if [ -d /sys/devices ]
    then                                                    # The new Linux 2.6.x  I/O system and the I/O scheduler
        exec_command GetElevator "Kernel I/O Elevator"      ##  18.07.2011, 13:33 modified by Ralph Roth #* rar *#
    fi
	dec_heading_level

fi # terminates CFG_KERNEL wrapper
######################################################################

if [ "$CFG_ENHANCEMENTS" != "no" ]
then # else skip to next paragraph

	paragraph "System Enhancements"
	inc_heading_level

	if [ -e /etc/X11/XF86Config ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/X11/XF86Config" "XF86Config"
	else
	  if  [ -e /etc/XF86Config ] ; then
	    exec_command "grep -vE '^#|^ *$' /etc/XF86Config" "XF86Config"
	  fi
	fi

	# stderr output from "grep -vE '^#|^ *$' /etc/XF86Config-4":
	#    grep: /etc/XF86Config-4: No such file or directory

	if [ -e /etc/X11/XF86Config-4 ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/X11/XF86Config-4" "XF86Config-4"
	else
	  if  [ -e /etc/XF86Config-4 ] ; then                                   #  09.01.2008, 14:49 modified by Ralph Roth
	    exec_command "grep -vE '^#|^ *$' /etc/XF86Config-4" "XF86Config-4"
	  fi
	fi

	if [ -e /etc/X11/xorg.conf ] ; then
	  exec_command "grep -vE '^#|^ *$' /etc/X11/xorg.conf" "xorg.conf"
	fi

	# MiMe: fuer X braucht man Rechte
	if [ -x /usr/X11R6/bin/xhost ] ; then
	  /usr/X11R6/bin/xhost > /dev/null 2>&1
	  if [ "$?" -eq "0" ] ;
	  then
		# Gratien D'haese
		# fix for sshdX11
		# old command   [ -x /usr/bin/X11/xdpyinfo ] && [ -n "$DISPLAY" ] && exec_command "/usr/bin/X11/xdpyinfo" "X11"
		# this will only check if the display is 0 or 1 which is more then enough
		    [ -x /usr/bin/X11/xdpyinfo ] && [ -n "$DISPLAY" ] && [ `echo $DISPLAY | cut -d: -f2 | cut -d. -f1` -le 1 ] && exec_command "/usr/bin/X11/xdpyinfo" "X11"
		    [ -x /usr/bin/X11/fsinfo ] && [ -n "$FONTSERVER" ] && exec_command "/usr/bin/X11/fsinfo" "Font-Server"
	  fi
	fi

	[ -x /opt/gnome/bin/gconftool-2 ] &&  exec_command "gconftool-2 -R /system"  "GNOME System Config"  ##  BF=bernhard keppel/110711, 30.11.2010/Ralph Roth

	dec_heading_level

fi # terminates CFG_ENHANCEMENTS wrapper
###########################################################################

if [ "$CFG_APPLICATIONS" != "no" ]
then # else skip to next paragraph

	paragraph "Applications and Subsystems"

### COMMON ################################################################

	inc_heading_level

	[ -x /usr/sbin/rear ] && exec_command "/usr/sbin/rear dump" "ReaR Configuration"    #  14.06.2011, 18:58 modified by Ralph Roth #* rar *#

	if [ -d /usr/local/bin ] ; then
	  exec_command "ls -lisa /usr/local/bin" "Files in /usr/local/bin"
	fi
	if [ -d /usr/local/sbin ] ; then
	  exec_command "ls -lisa /usr/local/sbin" "Files in /usr/local/sbin"
	fi
	if [ -d /opt ] ; then
	  exec_command "ls -lisa /opt" "Files in /opt"
	fi

############ Samba and Swat ########################

	if [ -f /etc/inetd.conf ] ; then
	  SWAT=`grep swat /etc/services /etc/inetd.conf`
	fi
	if [ -f /etc/xinetd.conf ] ; then
	  SWAT=`grep swat /etc/services /etc/xinetd.conf`
	fi

	[ -n "$SWAT" ] && exec_command  "echo $SWAT" "Samba: SWAT-Port"

	[ -x /usr/sbin/smbstatus ] && exec_command "/usr/sbin/smbstatus 2>/dev/null" "Samba (smbstatus)"
	### Debian...., maybe a smbstatus -V/samba -V is usefull
	[ -x /usr/bin/smbstatus ] && exec_command "/usr/bin/smbstatus 2>/dev/null" "Samba (smbstatus)"	## fixed 2007-02-27 Oliver Schwabedissen
	[ -x /usr/bin/testparm ] && exec_command "/usr/bin/testparm -s 2> /dev/null" "Samba Configuration (testparm)" #  09.01.2008, 14:53 modified by Ralph Roth
	[ -f /etc/samba/smb.conf ] && exec_command "cat /etc/samba/smb.conf" "Samba Configuration (smb.conf)" #*#  Alexander De Bernardi, 20100421 testparm does not show complete config
	[ -f /etc/init.d/samba ] && exec_command "ps -ef | grep -E '(s|n)m[b]'" "Samba Daemons"

	if [ -x /usr/sbin/lpc ] ; then
	  exec_command "/usr/sbin/lpc status" "BSD Printer Spooler and Printers"	#*# Alexander De Bernardi, 20100310
	fi
	 if [ -x /usr/bin/lpstat ] ; then
	 exec_command "/usr/bin/lpstat -t" "SYSV Printer Spooler and Printers"		#*# Alexander De Bernardi, 20100310
	 fi
	 if [ -x /usr/bin/hp-info ] ; then
#
# This for a bug in linux version
# Found: cfg2html stalls (freeze) when hplip is installed
# Cause: hp-info called in interactive mode, waits for a reply
# EL, 1.84 - 25. Januar 2011
	 exec_command "echo q | /usr/bin/hp-info -i | \
	 	/usr/bin/col" "HPLIP Printer Info"	#*# Alexander De Bernardi, 20100310
	 fi

	[ -r /etc/printcap ] && exec_command "grep -vE '^#|^ *$' /etc/printcap" "Printcap"
	[ -r /etc/hosts.lpd ] && exec_command "grep -vE '^#|^ *$' /etc/hosts.lpd" "hosts.lpd"

##
## we want to display HP OpenVantage Operations configurations
## 31Jan2003 it233 FRU U.Frey

	if [ -e /opt/OV/bin/OpC/utils/opcdcode ] ; then
	  if [ -e /opt/OV/bin/OpC/install/opcinfo ] ; then
	    exec_command "cat /opt/OV/bin/OpC/install/opcinfo" "HP OpenView Info, Version"
	  fi
	  if [ -e /var/opt/OV/conf/OpC/monitor ] ; then
	    exec_command "/opt/OV/bin/OpC/utils/opcdcode /var/opt/OV/conf/OpC/monitor | grep DESCRIPTION" "HP OpenView Configuration MONITOR"
	  fi

	  if [ -e /var/opt/OV/conf/OpC/le ] ; then
	    exec_command "/opt/OV/bin/OpC/utils/opcdcode /var/opt/OV/conf/OpC/le | grep DESCRIPTION" "HP OpenView Configuration LOGGING"
	  fi
	fi

## we want to display Veritas netbackup configurations
## 31Jan2003 it233 FRU U.Frey
## 3/5/08 Modified/added functionality by krtmrrsn@yahoo.com, Marc Korte.
##	Some things have changed in NetBU 6.x.
##	Made a seperate section for Veritas Netbackup
	if [ -e /usr/openv/netbackup/bp.conf ] ; then

	  paragraph "Veritas Netbackup Configuration"
	  inc_heading_level

		  NetBuVersion=$(find /usr/openv/netbackup -name "version")
		  if [ -e ${NetBuVersion} ] ; then
		    exec_command "cat ${NetBuVersion}" "Veritas Netbackup Version"
		  fi
		  exec_command "cat /usr/openv/netbackup/bp.conf" "Veritas Netbackup Configuration"
		  exec_command "netstat -tap | egrep '(bpcd|bpjava-msvc|bpjava-susvc|vnetd|vopied)|(Active|Proto)'" "Veritas Netbackup Network Connections"
		    ## Use FS="=" in case there's no whitespace in the SERVER lines.
		  exec_command "for NetBuServer in $(awk 'BEGIN {FS="="} /SERVER/ {printf $NF}' /usr/openv/netbackup/bp.conf); do ping -c 3 \${NetBuServer} && echo \"\"; done" "Veritas Netbackup Servers Ping Check"
		  if ping -c 3 $(awk 'BEGIN {FS="="} /SERVER/ {print $NF}' /usr/openv/netbackup/bp.conf | head -1) >/dev/null
		  then
		    exec_command "/usr/openv/netbackup/bin/bpclntcmd -pn" "Veritas Netbackup Client to Server Inquiry"
		  fi
	  dec_heading_level
	fi

###########################################################################
# { changed/added 28.01.2004 (17:56) by Ralph Roth }
	if [ -r /etc/cmcluster.conf ] ; then
	    dec_heading_level
	    paragraph "Serviceguard"
	    inc_heading_level
	    . ${SGCONFFILE:=/etc/cmcluster.conf}   # get env. setting, rar 12.05.2005
	    PATH=$PATH:$SGSBIN:$SGLBIN
	    exec_command "cat ${SGCONFFILE:=/etc/cmcluster.conf}" "Cluster Config Files"
	    exec_command "what  $SGSBIN/cmcld|head; what  $SGSBIN/cmhaltpkg|head" "Real Serviceguard Version"  ##  12.05.2005, 10:07 modified by Ralph Roth
	    exec_command "cmquerycl -v" "Serviceguard Configuration"
	    exec_command "cmviewcl -v" "Serviceguard Nodes and Packages"
	    exec_command "cmviewconf" "Serviceguard Cluster Configuration Information"
	    exec_command "cmscancl -s" "Serviceguard Scancl Detailed Node Configuration"
	    exec_command "netstat -in" "Serviceguard Network Subnets"
	    exec_command "netstat -a |fgrep hacl" "Serviceguard Sockets"
	    exec_command "ls -l $SGCONF" "Files in $SGCONF"
	fi

######## SLES 11 SP1 Pacemaker stuff ########## Mittwoch, 16. Mrz 2011 ##### Ralph Roth ####
	[ -x /usr/sbin/corosync-cfgtool ] && exec_command "/usr/sbin/corosync-cfgtool -s" "Corosync Totem Status/Active Rings"
	if [ -x /usr/sbin/crm ] # pacemaker #
	then
		exec_command "/usr/sbin/crm -D plain configure show" "Cluster Configuration"
		exec_command "/usr/sbin/crm -D plain status" "Cluster Status"
	fi

######## RHEL 5.x CRM stuff ######## Freitag, 18. Mrz 2011 #### Ralph Roth ####
	if [ -x /usr/sbin/cman_tool ]
	then
		exec_command "/usr/sbin/cman_tool status" 	"Cluster Resource Manager Status"
		exec_command "/usr/sbin/cman_tool nodes" 	"Cluster Resource Manager Nodes"
		exec_command "/usr/sbin/cman_tool services" 	"Cluster Resource Manager Services"
	fi

####### Red Hat Cluster Suite configuration  #  04.07.2011, 16:23 modified by Ralph Roth #* rar *#
    if [ -r /etc/cluster/cluster.conf ]
    then
        exec_command "/usr/sbin/clustat" "Cluster Status"   ## ER by David Williams
        if [[ $(grep -c xml /etc/cluster/cluster.conf) -gt 0 ]];
        then  ## small example can be found at http://pastebin.com/Yi5humeL
            exec_command "cat /etc/cluster/cluster.conf|sed 's{<{\&lt{g'|sed 's{>{\&gt{g'" "Cluster Configuration (XML)"
        else
            exec_command "cat /etc/cluster/cluster.conf" "Cluster Configuration"
        fi
    fi
dec_heading_level

fi 	#"$CFG_APPLICATIONS"# <m>  23.04.2008, 2145 -  Ralph Roth

##########################################################################
##
## Display Oracle configuration if applicable
## Begin Oracle Config Display
## 31jan2003 it233 FRU U.Frey

if [ -s /etc/oratab ] ; then    # exists and >0

  paragraph "Oracle Configuration"
  inc_heading_level

  exec_command "grep -vE '^#|^$|:N' /etc/oratab " "Configured Oracle Databases Startups"        #  27.10.2011, 15:01 modified by Ralph Roth #* rar *#

  ##
  ## Display each Oracle initSID.ora File
  ##     orcl:/home/oracle/7.3.3.0.0:Y
  ##     leaveup:/home/oracle/7.3.2.1.0:N

  for  DB in $(grep ':' /etc/oratab|grep -v '^#'|grep -v ':N$')                                 #  27.10.2011, 14:58 modified by Ralph Roth #* rar *#
       do
         Ora_Home=`echo $DB | awk -F: '{print $2}'`
         Sid=`echo $DB | awk -F: '{print $1}'`
         Init=${Ora_Home}/dbs/init${Sid}.ora
         if [ -r "$Init" ]
         then
            exec_command "cat $Init" "Oracle Instance $Sid"
         else
            AddText "WARNING: obsolete entry $Init in /etc/inittab for SID $Sid!"
         fi
       done
  dec_heading_level
fi


###
##############################################################################
###   HP Proliant Server LINUX Logfiles from HP tools and or the HP PSP.   ###
###   Made by Jeroen.Kleen@hp.com EMEA ISS Competence Center Engineer      ###

if [ "$CFG_HPPROLIANTSERVER" != "no" ]
then # else skip to next paragraph

# @(#) Below follows HP Proliant specific stuff mainly written by Jeroen Kleen
# --=----------------------------------------------------------------------=---
#

	paragraph "hp ProLiant Server Log- and configuration Files"
	inc_heading_level

    temphp=/tmp/cfg2html_temp
    if [ ! -d $temphp ] ; then
         mkdir $temphp
    fi

	if [ -x /opt/hp/hpdiags/hpdiags ] ; then
		/opt/hp/hpdiags/hpdiags -v 5 -o $temphp/hpdiagsV5.txt -f -p >/dev/null
	fi

	if [ -x /opt/hp/hp_fibreutils/hp_system_info ] ; then
                rm /tmp/system_info*.tar.gz -f
				/opt/hp/hp_fibreutils/hp_system_info > /dev/null
				cp /tmp/system_info*.tar.gz $temphp
                rm /tmp/system_info*.tar.gz -f
	fi


# Request:              Dienstag, 12. Januar 2010 -- Koerber, Martin
# ========
# Starting with "8.28-13.0 (6 May 2009)" of cpqacuxe the capture functionality is no longer supported.
# http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en&cc=us&prodTypeId=15351&prodSeriesId=1121486&swItem=MTX-a72c1471380f45f4a5cb2f4ec9&prodNameId=3288144&swEnvOID=4049&swLang=8&taskId=135&mode=5
#
# Version: 8.28-13.0  (6 May 2009)
# Scripting for captures and inputs is no longer supported in ACU HPACUCLI is now responsible for Scripting

    CPQACUXE=$(which cpqacuxe 2>/dev/null)
	if [ -x "$CPQACUXE" ] ; then
			$CPQACUXE -c $temphp/cpqacuxe.cfg
	fi

    HPADUCLI=$(which hpaducli 2>/dev/null )
	if [ -x "$HPADUCLI" ] ; then
			$HPADUCLI -f $temphp/ADUreport.txt -r
	fi

	if [ -x /usr/lib/hponcfg ] ; then
		/usr/lib/hponcfg -w -a $temphp/ilo.cfg
	fi

	if [ -x /sbin/hponcfg ] ; then
		/sbin/hponcfg -w -a $temphp/ilo.cfg
	fi

	if [ -x $DMIDECODE ] ;	then
		exec_command "$DMIDECODE | grep Product" "HP Proliant Server model Information taken from dmidecode"
	fi

    SURVEY=$(which survey 2>/dev/null)
	if [ -x "$SURVEY" ] ; then
			exec_command "$SURVEY -v 5 -t" "Classic Survey output -v 5"
	fi

	if [ -x /sbin/hplog ] ; then
			exec_command "hplog -t -f -p" "Current Thermal Sensor, Fan & Power data"
			exec_command "hplog -v" "Proliant Integrated Management Log"
	fi

	if [ -r /var/log/hppldu.log ] ; then
			exec_command "cat /var/log/hppldu.log" "Installation Log PSP 7.*"
    fi

	if [ -r /tmp/hppldu.cfg ] ; then
			exec_command "cat /tmp/hppldu.cfg" "PSP 7.* Installation Settings file"
	fi

	if [ -r /var/hp/log/localhost/hpsum_log.txt ] ; then
			exec_command "cat /var/hp/log/localhost/hpsum_log.txt" "Installation Log PSP 8.* using HP SUM"
	fi

	if [ -r /var/hp/log/localhost/hpsum_detail_log.txt ] ; then
			exec_command "cat /var/hp/log/localhost/hpsum_detail_log.txt" "Detailed Installation Log PSP 8.* using HP SUM"
	fi

	if [ -e /opt/compaq/cma.conf ] ; then
			exec_command "cat /opt/compaq/cma.conf" "/opt/compaq/cma.conf file"
	fi

	if [ -e /opt/hp/hp-snmp-agents/cma.conf ] ; then
			exec_command "cat /opt/hp/hp-snmp-agents/cma.conf" "/opt/hp/hp-snmp-agents/cma.conf file"
	fi

	if [ -e /opt/compaq/snmpd.conf.orig ] ; then
			exec_command "cat /opt/compaq/snmpd.conf.orig" "/opt/compaq/snmpd.conf.orig file "
	fi

	if [ -e /var/hp/install_history.txt ] ; then
			exec_command "cat /var/hp/install_history.txt" "/var/hp/install_history.txt file"
	fi

	if [ -e /var/log/hplog.txt ] ; then
			exec_command "cat /var/log/hplog.txt" "/var/log/hplog.txt file"
	fi

	if [ -e /var/opt/hp/nicfwupg.log ] ; then
			exec_command "cat /var/opt/hp/nicfwupg.log" "/var/opt/hp/nicfwupg.log file"
	fi

	if [ -e /var/spool/compaq/cma.log ] ; then
			exec_command "cat /var/spool/compaq/cma.log" "/var/spool/compaq/cma.log Agents logfile"
	fi

	if [ -e /var/cpq/Component.log ] ; then
			exec_command "cat /var/cpq/Component.log" "Individual Components Installation Log file (ROMBIOS/SA FW/iLO)"
	fi

	if [ -e /etc/snmp/snmpd.conf ] ; then
			exec_command "cat /etc/snmp/snmpd.conf" "/etc/snmp/snmpd.conf file"
	fi

	if [ -x /etc/init.d/hpasm ] ; then
			exec_command "/etc/init.d/hpasm status" "hpasm status of how what modules are loaded and running correctly."
	fi

	if [ -e /opt/compaq/cpqhealth/cpqhealth_boot.log ] ; then
			exec_command "cat /opt/compaq/cpqhealth/cpqhealth_boot.log" "LOGfile from when hpasm failed installation"
	fi

	if [ -e /opt/compaq/hprsm/hprsm_boot.log ] ; then
			exec_command "cat /opt/compaq/hprsm/hprsm_boot.log" "LOGfile during boot from hprsm"
	fi

	if [ -x /opt/compaq/nic/bin/hpetfe  ] ; then
			exec_command "/opt/compaq/nic/bin/hpetfe -A" "/opt/compaq/utils/nic/bin/hpetfe -A HP NIC information"
	fi

    HPASMCLI=$(which hpasmcli 2>/dev/null)
	if [ -x "$HPASMCLI" ] ; then
			$HPASMCLI -s "show asr; show boot; show dimm; show f1; show fans; show ht; show ipl; show name; show powersupply; show pxe; show serial bios; show serial embedded; show serial virtual; show server; show temp; show uid; show wol" >$temphp/hpasmcliOutput.txt
			exec_command "cat $temphp/hpasmcliOutput.txt" "HP ASM CLI command line output"
	fi

	if [ -e /etc/opt/hp/hp-vt/hp-vt.conf ] ; then
			exec_command "cat /etc/opt/hp/hp-vt/hp-vt.conf" "Intelligent Networking Pack Virus Throttling conf file"
	fi

	if [ -x /etc/init.d/hp-vt ] ; then
			exec_command "/etc/init.d/hp-vt status" "Intelligent Networking Pack Virus Throttling Status"
	fi

	if [ -e /var/opt/hp/hp-vt/hp-vt.log ] ; then
			exec_command "cat /var/opt/hp/hp-vt/hp-vt.log" "Intelligent Networking Pack Logfile"
	fi

	if [ -x /opt/hp/hp-pel/nalicense ] ; then
			exec_command "/opt/hp/hp-pel/nalicense -d" "Proliant Essentials Licenses installed overview"
	fi
	if [ -e /var/opt/hp/hp-pel/hp-pel.log ] ; then
			exec_command "cat /var/opt/hp/hp-pel/hp-pel.log" "Proliant Essentials Licenses Logfile"
	fi

	if [ -e $temphp/ilo.cfg ] ; then
			exec_command "cat $temphp/ilo.cfg" "iLO configuration file captured via HPONCFG"
	fi

	if [ -e /root/install.log.syslog ] ; then
			exec_command "cat /root/install.log.syslog" "Installation SYS logfile"
    fi

	if [ -r /root/install.rdp.log ] ; then
		exec_command "cat /root/install.rdp.log" "Rapid Deployment Pack RDPinstall logfile"
    fi

	if [ -e /root/anaconda-ks.cfg ] ; then
			exec_command "cat /root/anaconda-ks.cfg" "anaconda kickstart file used during OS deployment"
	fi

	if [ -e /var/log/messages ] ; then
	#		exec_command "cat /var/log/messages" "messages logging file (older messages logfiles in TARBALL)"
                        cp /var/log/messages $temphp > /dev/null
     					cp /var/log/messages.1 $temphp > /dev/null
                        cp /var/log/messages.2 $temphp > /dev/null
	fi

	if [ -e /var/log/boot.log ] ; then
			exec_command "cat /var/log/boot.log" "boot.log logfile (older boot.log logfiles in TARBALL)"
			cp /var/log/boot.log.1 $temphp > /dev/null
			cp /var/log/boot.log.2 $temphp > /dev/null
	fi

	if [ -e /var/log/dmesg ] ; then
			exec_command "cat /var/log/dmesg" "dmesg logfile /var/log/dmesg"
	fi

	if [ -e /var/log/acpid ] ; then
			exec_command "cat /var/log/acpid" "ACPID power boot / reboot log"
	fi

#	if [ -e $temphp/ADUreport.txt ] ; then
#			exec_command "cat $temphp/ADUreport.txt" "Array Diagnostic Utility report is included in the TAR ball as a single file"
#	fi

	if [ -e $temphp/cpqacuxe.cfg ] ; then
			exec_command "cat $temphp/cpqacuxe.cfg" "cpqacuxe configuration file (SmartArray configuration)"
	fi

	if [ -e /tmp/hpsum ] ; then
			echo "Generating HPSUM reports"
			/tmp/hpsum /report /veryv >dev/null
			/tmp/hpsum /inventory_report /veryv >dev/null
			/tmp/hpsum /firmware_report /veryv >dev/null
			cp /tmp/discovery.xml $temphp >dev/null
			cp /tmp/HPSUM_* $temphp >dev/null
			cp /tmp/hp_sum/*.trace $temphp >dev/null
			cp /tmp/hp_sum/InventoryResults.xml $temphp >dev/nlsull
	fi

	if [ -d /var/hp/log	] ; then
			cp /var/hp/log/* $temphp
			cp /var/hp/log/localhost/* $temphp
			cp /var/log/hp_sum/* $temphp
	fi

	if [ -d /opt/hp/hpdiags ] ; then
			cp /opt/hp/hpdiags/survey* $temphp
    fi

	if [ -d /opt/hp/hp-fc-enablement/elxreport.sh ] ; then
			/opt/hp/hp-fc-enablement/elxreport >dev/null
			cp /tmp/elxreport.sh* $temphp
	fi

	if [ -d /opt/hp/hp-fc-enablement/ql-hba-collect-1.8/ql-hba-collect.sh ] ; then
			/opt/hp/hp-fc-enablement/ql-hba-collect-1.8/ql-hba-collect.sh >dev/null
			cp /tmp/QLogicDiag* $temphp
	fi

	if [ -x /usr/local/bin/vcsu ] ; then
		echo "HP Virtual Connect Support Utility (VCSU) detected; get if needed the VC logs"
		echo " collected via /usr/local/bin/vcsu -a collect. and with vcsu -a -supportdump and"
		echo " executute then again cfg2html to get all the logs included automatically."
		cp /usr/local/bin/*.txt $temphp
		cp /usr/local/bin/vcsu*.log $temphp
	fi

	if [ -e /opt/netxen ] ; then
		echo "NetXen diagnostic utility detected; to get full NetXEN diag output run command:"
		echo "/opt/netxen/nxudiag -i ethX (ethX is your eth adapter like eth0 / eth1"
	fi

	###below partitioning and HPACUCLI is contributed by kgalal@gmail.com
    ## Changed 2011-09-05 Peter Boysen - Previous hpacucli commands was redundant.
	if [ -x /usr/sbin/hpacucli ] ; then
# 		exec_command "/usr/sbin/hpacucli controller all show" "HP SmartArray controllers Detected"	 # added by jeroenkleen HP
# 		exec_command "/usr/sbin/hpacucli controller all show status" "HP SmartArray controllers Detected with Status"
# 		slotnum=`/usr/sbin/hpacucli controller all show | awk '{if($0!="")print $6}'`  # jkleen: this doesn't work (yet) for MSA1x000 controllers
# 		exec_command "/usr/sbin/hpacucli controller slot=$slotnum physicaldrive all show" "Physical Drives on SmartArray Controller"
# 		exec_command "/usr/sbin/hpacucli controller slot=$slotnum logicaldrive all show" "Logical Drives on SmartArray controller"
		exec_command "/usr/sbin/hpacucli ctrl all show config detail" "HP SmartArray controllers Detected"	 # added by jeroenkleen HP # Changed 2011-09-05 Peter Boysen
        /usr/sbin/hpacucli controller all diag file=$temphp/hpacucli_diag.txt	       # Added 2011-09-05 Peter Boysen.
	fi

	disks=`/sbin/fdisk -l`
	if [ ! -z "$disks" ] ; then
		exec_command "/sbin/fdisk -l" "Disk Partitions on Logical Drives"
	else
		disks=`cat /proc/partitions | awk '{if($4 ~ /\//)print $4}' |grep -v p`
		for adisk in $disks ; do
			exec_command "/sbin/fdisk -l /dev/$adisk" "Disk Partitions - /dev/$adisk"
		done
	fi

	###above partitioning and HPACUCLI is contributed by kgalal@gmail.com

	exec_command "ls $temphp" "These files have been made or captured during CFG2html execution and should be in the zipped TARball"
	hplog -s INFO -l "CFG2HTML HP Proliant Server report successfully created"

	dec_heading_level


fi  # end of CFG_HPPROLIANTSERVER paragraph
###  END of HP Proliant Server Integration
###############################################################################
###



###
##############################################################################
###   Altiris ADL agent settings and logfiles
###   Made by Jeroen.Kleen@hp.com EMEA ISS Competence Center Engineer      ###

if [ "$CFG_ALTIRISAGENTFILES" != "no" ]
then # else skip to next paragraph

# checking if Altiris directory exist otherwise skip this section
if [ -e /opt/altiris/deployment/adlagent ] ; then

  paragraph "Altiris ADL Agent logfiles and settings"
  inc_heading_level

  exec_command "cat /opt/altiris/deployment/adlagent/conf/adlagent.conf" "Altiris ADLagent settings file"
  exec_command "cat /opt/altiris/deployment/adlagent/log/adlagentdbg.txt" "Altris ADLagent Debugging file"
  exec_command "cat /opt/altiris/deployment/adlagent/log/adlagentIpTrace.txt" "Altiris ADLagent IP tracing file"

  dec_heading_level
fi

fi  # end of CFG_ALTIRISAGENTFILES paragraph
###  END of Altiris ADL agent settings and logfiles
##############################################################################


###
##############################################################################
###   VMWARE settings and logfiles
###   Made by Jeroen.Kleen@hp.com EMEA ISS Competence Center Engineer      ###

if [ "$CFG_VMWARE" != "no" ]
then # else skip to next paragraph

# checking if VMWare directory exist otherwise skip this section
if [ -e /proc/vmware ] ; then

  paragraph "VMWare logfiles and settings"
  inc_heading_level

exec_command "vmware -v" "VMWare Server version"

echo "VMWare server detected. We will start now the vm-support script in case you"
echo "need this vmware debugging file send to VMWare support or other support teams."
vm-support
exec_command "cat esx-$(date -I).$$.tgz" "vm-support ticket generated in local directory if vm-support is installed."


dec_heading_level
fi
fi  # end of CFG_VMWARE paragraph
##############################################################################

#
# execute custom plugins   -- anaumann 2009/07/10
#

if [ "$CFG_PLUGINS" != "no" ];
then # else skip to next paragraph
    if [ -f /etc/cfg2html/plugins ]; then
	paragraph "Custom plugins"

        # include plugin configuration
	. /etc/cfg2html/plugins


	if [ -n "$CFG2HTML_PLUGIN_DIR" -a -n "$CFG2HTML_PLUGINS" ]; then
            # only run plugins when we know where to find them and at least one of them is enabled

	    inc_heading_level

	    if [ "$CFG2HTML_PLUGINS" == "all" ]; then
		# include all plugins
		CFG2HTML_PLUGINS="$(ls -1 $CFG2HTML_PLUGIN_DIR)"
	    fi

	    for CFG2HTML_PLUGIN in $CFG2HTML_PLUGINS; do
		if [ -f "$CFG2HTML_PLUGIN_DIR/$CFG2HTML_PLUGIN" ]; then
		    . $CFG2HTML_PLUGIN_DIR/$CFG2HTML_PLUGIN
		    exec_command cfg2html_plugin "$CFG2HTML_PLUGINTITLE"
		else
		    AddText "Configured plugin $CFG2HTML_PLUGIN not found in $CFG2HTML_PLUGIN_DIR"
		fi
	    done
	    dec_heading_level
	fi
    fi
fi

## end of plugin processing


#
# collect local files
#
if [ -f /etc/cfg2html/files ] ; then
  paragraph "Local files"
  inc_heading_level
  . /etc/cfg2html/files
  for i in $FILES
  do
    if [ -f $i ] ; then
      exec_command "grep -vE '(^#|^ *$)' $i" "File: $i"
    fi
  done
  AddText "You can customize this entry by editing /etc/cfg2html/files"
  dec_heading_level
fi

dec_heading_level

close_html
###########################################################################
###########################################################################
######     Creating gzipped TAR File for all needed files together. Added by Jeroen Kleen HP EMEA ISS CC

if [ "$CFG_HPPROLIANTSERVER" != "no" ]
then # else skip to next paragraph

 if [ -f $OUTDIR/$BASEFILE.tar ] ; then
        rm $OUTDIR/$BASEFILE.tar
 fi
echo " "
	echo " The following files are included in your gzipped tarball file: "

	# tar cvf $OUTDIR/$BASEFILE.tar $OUTDIR/$BASEFILE.err $OUTDIR/$BASEFILE.html $OUTDIR/cfg2html_back.jpg $OUTDIR/profbull.gif $OUTDIR/$BASEFILE.partitions.save $OUTDIR/$BASEFILE.txt ADUreport.txt /var/spool/compaq/vcagent/log/vcagentd.log /var/spool/compaq/vcagent/log/vcasetup.log /tmp/hpdiags.xml ilo.cfg
	tar -czf $OUTDIR/$BASEFILE.tar.gz $temphp
	echo "  "
	echo " If you created this CFG2HTML report on request of a HP support Agent "
	echo " then please send the $OUTDIR/$BASEFILE.tar.gz file to: "
	echo "           HPsupport_Global@hp.com     "
	echo " Where in the subject is stated: <CASE:YOURCASEID> eg: <CASE:6000000000> "
	echo "  "
	echo " Feedback please to: CFG2HTML@hp.com or twitter.com/cfg2html    Thanks! "

fi  # end of CFG_HPPROLIANTSERVER (making tarball)
###########################################################################


logger "End of $VERSION"
echo -e "\n"
line

logger "End of $VERSION"
rm -f core > /dev/null

########## remove the error.log if it has size zero #######################
[ ! -s "$ERROR_LOG" ] && rm -f $ERROR_LOG 2> /dev/null

exit 0

####################################################################
