So far the script will collect the domain in 1 rule and the next rule will hold some text and the version number. I have no scripting skills to get this reworked to list a Domain name, package number and date.
What it does allow me to do is put this info in an email per MDS, from there it is simply a text find and replace and a move to excel where some simple formulas will give you the right output, be this part manual but it works.
We use a separate file called FWLib which sets the variables used in the different scripts we have:
#!/bin/sh
#-----------------------------------------------------------
# FWlib - library holds common libraries for FW*
# script files
#-----------------------------------------------------------
# Set Script constants ...
SCRIPT=`basename $0`
BASEDIR=/backup
SCRIPTDIR=$BASEDIR/scripts
LOG=$SCRIPTDIR/$SCRIPT.log
BCK=$SCRIPTDIR/$SCRIPT.bck
# Set MDS constants ...
MDS_CPDIR=/opt/CPshrd-R77 # needed if script is run from cronjob
# Set FW logfiles constants ...
LOGDIR=/var/log/Our-log
LOGBCK=$BASEDIR/log.bck
TMPDIR=/var/log/Our-logtmp
EXPORT=/var/log/Our-export
# Set MAIL constants ...
readonly MAILSVR=<IP-Address Mailserver>
readonly MAILFROM=`uname -n`@aaa.com
readonly MAILTO=admin@aaa.com
readonly MAILCHK=admin@aaa.com
readonly MAILERROR=admin@aaa.com
# Include Check Point MDS commands and variables ...
source $MDS_CPDIR/tmp/.CPprofile.sh
# aplications
GREP=/bin/grep
function timestamp {
# ---------------------------------------------------------------------------
# Write entry to logfile
# ---------------------------------------------------------------------------
echo `date --utc +%H:%M` "$*"
}
The actual script FWIPSverto run through all Domains on the MDS it is run from:
#!/bin/sh
#-----------------------------------------------------------
# FWIPSver - collects info from all Domains about the actual version
# of the IPS database.
#-----------------------------------------------------------
# If the script is called with one or more Domain names on
# the command line, these Domains are processed. Otherwise
# the script iterates over the entire Multi Domain
# installation
#-----------------------------------------------------------
# Link additional constants and functions library ...
source `dirname $0`/FWlib
# Declare other variables
declare -a CMAs
# Assign CMAs from the commandline (if any) ...
CMAs=( $* )
#---------------------------------------------------------
# Determine date to be used in filenames
#---------------------------------------------------------
DT=`date --utc +%Y%m%d`
#---------------------------------------------------------
# Initialize Logfile and output file and keep the previous as .bck
#---------------------------------------------------------
# Backup old logfile ...
[ -e $BCK ] && rm $BCK
[ -e $LOG ] && mv $LOG $BCK
# Backup old logfile ...
[ -e data.bck ] && rm data.bck
[ -e data.txt ] && mv data.txt data.bck
# Backup and create new logdir ...
[ -d $LOGDIR ] && rm -R $LOGDIR
[ ! -d $LOGDIR ] && mkdir $LOGDIR
# Remove and create new tmpdir ...
[ ! -d $TMPDIR ] && mkdir $TMPDIR
# Create new logfile ...
echo '**************************************' >$LOG
echo 'Collect IPS versions of all Domains ... ' >>$LOG
echo '**************************************' >>$LOG
echo 'Provider-1 server: '`uname -n` >>$LOG
echo 'Current date : '`date --utc +%d-%m-%Y` >>$LOG
echo 'Current time : '`date --utc +%H:%M` >>$LOG
echo >>$LOG
#---------------------------------------------------------
# Find all Domains
#---------------------------------------------------------
# Set environment to the MDS environment ...
mdsenv
if [ ${#CMAs[@]} = 0 ]; then
# Get all CMA names ...
j=0
for i in `mdsquerydb CMAs`; do
CMAs[j++]=`expr $i : '\(.*\)_\._\._'`
done
fi
#---------------------------------------------------------
for CMA in ${CMAs[@]}; do
echo '============================================' >>$LOG
echo 'Determining IPS Version on CMA: '$CMA >>$LOG
echo '============================================' >>$LOG
# Switch environment to CMA ...
mdsenv $CMA >>NULL
if [ "$?" = "0" ]; then
echo $CMA >>data.txt
cat $FWDIR/conf/asm.C | grep asm_update_version_vpn >>$LOG
cat $FWDIR/conf/asm.C | grep asm_update_version_vpn >>data.txt
echo >>$LOG
else
echo "CMA does not live on this machine" >>$LOG
fi
done
# End of script; close logfile ...
echo >>$LOG
echo '--------------------------------------------' >>$LOG
timestamp 'End of FWIPSver script ... ' >>$LOG
echo '--------------------------------------------' >>$LOG
# Send resulting log file to mail group ...
/opt/CPsuite-R77/fw1/bin/sendmail -t $MAILSVR -s "FW IPS Version check results" -f $MAILFROM $MAILTO <$LOG
/opt/CPsuite-R77/fw1/bin/sendmail -t $MAILSVR -s "FW IPS Version check results" -f $MAILFROM $MAILTO <data.txt
That is all there is to it.
If anyone knows of a simple way to collect just the version number and convert this on the MDS itself before we mail it out that would really help.
Regards, Maarten