MDS script to check CMA sync status via command line

From cpwiki.net
Revision as of 22:09, 25 February 2013 by Nighthawk (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Check Point Profressional Services

here it am... and it is portable. works on R65 to R75.

#!/bin/bash
source /opt/CPshared/5.0/tmp/.CPprofile.sh
MDS_HOSTNAME=`hostname`
MDS_BASE_IP=`cpmiquerybin attr "mdsdb" mdss "" -a __name__,ipaddr | grep -i $MDS_HOSTNAME | awk '{print $2}'`
echo "mds hostname = $MDS_HOSTNAME"
echo "mds base ip = $MDS_BASE_IP"
MDS_CMA_LIST=( `cpmiquerybin attr "mdsdb" network_objects "management='true'" -a __name__ | awk -F "_._._" '{printf $1 " " }'` )
MDS_CMA_LIST_LEN=${#MDS_CMA_LIST[@]}    # get array length
MDS_CMA_LIST_LEN=$(($MDS_CMA_LIST_LEN))
printf "%-35s%-35s%8s%1s%-8s%15s\n" CMA-1 CMA-2 Status / Status Sync_Status
printf "%-35s%-35s%8s%1s%-8s%15s\n" ---------------------------------- ---------------------------------- -------- - -------- --------------
for a in `seq $MDS_CMA_LIST_LEN`
do
  mdsenv ${MDS_CMA_LIST[$a-1]}        # subtract 1 because array keys start @ zero
  LOCAL_CMA=( `cpmiquerybin attr "" network_objects "management='true'" -a __name__ | awk '{printf $1 " "}'` )
  CMA_1_STATUS=`cpmistat -o schema -r mg ${LOCAL_CMA[0]} | grep mgActiveStatus | awk '{print $2}'`
  CMA_2_STATUS=`cpmistat -o schema -r mg ${LOCAL_CMA[1]} | grep mgActiveStatus | awk '{print $2}'`
  CMA_1_SYNC_STATUS=`cpmistat -o schema -r mg ${LOCAL_CMA[0]} | grep "mgSyncStatus" | grep -v "N/R" | awk '{print $2}'`
  CMA_2_SYNC_STATUS=`cpmistat -o schema -r mg ${LOCAL_CMA[1]} | grep "mgSyncStatus" | grep -v "N/R" | awk '{print $2}'`
  printf "%-35s%-35s%8s%1s%-8s%15s\n" ${LOCAL_CMA[0]} ${LOCAL_CMA[1]} $CMA_1_STATUS / $CMA_2_STATUS $CMA_1_SYNC_STATUS $CMA_2_SYNC_STATUS
done