#! /bin/csh -f
#
# (c) Copyright 1993-1997 Check Point Software Technologies Ltd.
# All rights reserved.
# 
# This is proprietary information of Check Point Software Technologies
# Ltd., which is provided for informational purposes only and for use
# solely in conjunction with the authorized use of Check Point Software
# Technologies Ltd. products.  The viewing and use of this information is
# subject, to the extent appropriate, to the terms and conditions of the
# license agreement that authorizes the use of the relevant product.
# 
# $Header: /fw/cvs/fw-1/fwutil/fwinfo.csh,v 1.9.2.15 1997/08/11 19:32:18 ori Exp $
#
set solaris2 = 0
set sunos4 = 0
set hpux = 0
set aix = 0

if ( -f /kernel/genunix || -f /kernel/unix ) then
	set solaris2 = 1
	set path = ( /usr/bin /usr/ucb /usr/sbin )
	set module = modules/fwmod.5.3.o
	alias dodf df -k
	alias dops /usr/ucb/ps auxww
else if (-f /hp-ux) then
	set hpux = 9
	set path = (/bin /usr/bin /etc)
	set module = modules/fwmod.hpux9.o
	alias dodf bdf
	alias dops ps -ef
else if (-f /stand/vmunix) then
	set hpux = 10
	set path = (/bin /usr/bin /usr/sbin /etc)
	set module = modules/fwmod.hpux10.o
	alias dodf bdf
	alias dops ps -ef
else if (-f /unix) then
	set aix = 1
	set path = (/bin /usr/bin /usr/sbin)
	set module = modules/fwmod/fwmod.4.x.o
	alias dodf df -k
	alias dops ps -ef
else
	set sunos4 = 1
	set path = ( /usr/bin /usr/ucb /bin /usr/etc )
	set module = modules/fwmod.4.1.3.o
	alias dodf df
	alias dops ps auxww
endif

alias header "echo '' ; echo ============================================== ; echo \!* ; echo ============================================== ; echo ''"
alias invoke "echo Issuing \'\!*\' : ; echo '' ; \!* |& cat"
alias invoke_noerr "echo Issuing \'\!*\' : ; echo '' ; \!* | cat"
alias docrash "echo Issuing crash \'\!*\' : ; echo '' ; echo \!* | crash |& cat; echo ''"

if (! $?FWDIR) set FWDIR = /etc/fw

echo '************************************************************************'
echo '                    FireWall-1 Support Information.                     '
echo '                                                                        '
echo '  When needed, you will be asked to send the output of this program to  '
echo '                        support@CheckPoint.COM                          '
echo '                                                                        '
echo '  In order to do it, you might want to invoke the following commands:   '
echo '                                                                        '
echo '  1) $FWDIR/bin/fwinfo | compress | uuencode fwinfo.Z > /tmp/fwinfo.uue '
echo '                                                                        '
echo '  2) Attach /tmp/fwinfo.uue to a mail for support@CheckPoint.COM        '
echo '                                                                        '
echo '************************************************************************'

header System Information
invoke date
echo ""
invoke hostname
echo ""
invoke uname -a
echo ""
invoke hostid
echo ""
invoke w -u
echo ""
invoke uptime
echo ""
invoke dops
echo ""
if ($solaris2) then
	invoke swap -s
	echo ""
	invoke swap -l
	echo ""
	crash < /dev/null > /dev/null
	if ($status == 0) then
		docrash kmastat
		echo ""
	endif
	invoke modinfo
	echo ""
	invoke showrev -a
	echo ""
else if ($sunos4) then
	invoke pstat -s
	echo ""
	invoke modstat
	echo ""
	invoke showrev -a
	echo ""
else if ($hpux) then
	invoke swapinfo -mta
	echo ""
	if ($hpux == 10) then
		invoke nm /stand/vmunix
		invoke swapinfo -Mta
		invoke /usr/sbin/swlist -v
		echo ""
	else if ($hpux == 9) then
		invoke nm /hp-ux
		echo ""
		invoke ls /system
	endif
	echo ""
else if ($aix) then
	invoke vmstat
	echo ""
	invoke lsdev -C
	echo ""
	invoke lsfs
endif
invoke env
echo ""
invoke set
echo ""
invoke dodf
echo ""
invoke dodf $FWDIR
echo ""
if ($hpux) then
	invoke model
	echo ""
	if ($hpux == 9) then
		invoke nodename
		echo ""
		invoke ioscan -f
		echo ""
	else
		invoke ioscan -fn
		echo ""
		invoke ioscan -fnk
		echo ""
	endif
endif
header Firewall-1 Startup File
invoke find /etc -type f -exec grep fwboot {} \; -print -exec cat {} \;
echo ""
invoke find /etc -type f -exec grep fwstart {} \; -print -exec cat {} \;
echo ""

header IP Interfaces
if ($hpux) then
	invoke lanscan
	set iflist = (lo0 `lanscan | tail +3 | awk '{print $5}'`)
	foreach if ($iflist)
		echo ""
		invoke ifconfig $if
	end
else if ($aix) then
	set iflist = `lsdev -C | grep "Network Interface" | awk '{print $1}'`
	foreach if ($iflist)
		echo ""
		invoke ifconfig $if
	end
else
	invoke ifconfig -a
endif
echo ""
invoke $FWDIR/bin/fw ctl iflist

header Netstat Information
invoke netstat -rn
echo ""
invoke netstat -i
echo ""
invoke netstat -m
echo ""
invoke netstat -s
echo ""
invoke netstat -a
echo ""
invoke arp -a
echo ""

if ($solaris2) then
	header Check Forwarding Flag
	invoke ndd /dev/ip ip_forwarding
endif

header FireWall-1 Version Information
invoke $FWDIR/bin/fw ver
alias getrcs strings -
foreach prog (bin/fw bin/fwui $module)
	invoke getrcs $FWDIR/$prog | grep 'Header: \/fw' | sed -e 's/^.*Header: //' | sed -e 's/[a-z]* Exp.*$//'
	echo ""
	if ($solaris2) then
		invoke /usr/ucb/sum $FWDIR/$prog
	else
		invoke sum $FWDIR/$prog
	endif
	echo ""
end

header FireWall-1 Status
invoke $FWDIR/bin/fw stat -i -l
echo ""

header FireWall-1 Tables
invoke $FWDIR/bin/fw tab -u
echo ""

header FireWall-1 License
invoke $FWDIR/bin/fw printlic
echo ""
invoke $FWDIR/bin/fw printlic -k
echo ""

header FireWall-1 Statistics
invoke $FWDIR/bin/fw ctl pstat
echo ""

header FireWall-1 Configuration, Database and State
invoke ls -lsigRL $FWDIR
echo ""
$FWDIR/bin/fw dbexport -f $FWDIR/conf/users.$$
if (-f $FWDIR/bin/gunzip) then
	ln -s $FWDIR/bin/gunzip /tmp/gzip.$$
else
	ln -s `which compress` /tmp/gzip.$$
endif 

echo ""
set files = `(cd $FWDIR ; echo log/{a*.log,mdq.log,fwui.log,telnet1.log,ftp1.log,http1.log,rlogin1.log} conf/{*.{C,W,pf,cl,exp,conf},users.$$,external.if*,masters*,fw.license*,fwauth.NDB,fwmusers,product.id,rulebases.fws} state/* database/* lib/{*.{def,C,h},control.map*})`
(cd $FWDIR ; invoke_noerr tar cf - $files | /tmp/gzip.$$ | uuencode fw.tar.gz ) |& cat
/bin/rm -rf /tmp/gzip.$$
rm -f $FWDIR/conf/users.$$
echo ""

header Hosts
invoke head -200 /etc/hosts
echo ""
invoke ypcat hosts | head -200
echo ""

header Services
invoke cat /etc/services
echo ""
invoke ypcat services
echo ""

