Monday, December 17, 2018

▷ CA ControlMinder policy batch apply to multi-servers on Unix/Linux)

[ PIM policy batch apply to multi-servers on unix/linux ]


#!/bin/sh
#

work_dir=`grep "^SEOSPATH" /etc/seos.ini | awk -F" = " '{print $2}'`"/work"
rule_scr="$work_dir/rule.script"
#rule_scr="$work_dir/rule_real.txt"
#rule_scr="$work_dir/rule_warn.txt"
tgt_list="$work_dir/rule.target"
inp_file="$work_dir/rule.input"
log_file="$work_dir/rule.log_`date '+%Y%m%d%H%M'`"

echo "Rule Script FileName: $rule_scr"
echo "Rule Target FileName: $tgt_list"
echo "Press Y|y(es) to continue... (otherwise any other key)"
read inp

if [ "$inp" != "Y" -a "$inp" != "y" ] ; then echo "exiting..." ; exit ; fi

sum_cnt=0
suc_cnt=0
err_cnt=0
err_lst=-

if [ ! -d "$work_dir/out" ] ; then mkdir "$work_dir/out" ; fi

for host_nm in `cat $tgt_list | grep -v "^#"`
do
        out_file="$work_dir/out/$host_nm.out"
        $work_dir/../bin/selang -s -c "host $host_nm" -o $out_file

        ok_cnt=`cat $out_file | grep "Successfully connected" | wc -l`

        if [ $ok_cnt -eq 1 ] ; then
                echo "host $host_nm" > $inp_file
                cat  "$rule_scr"    >> $inp_file

                $work_dir/../bin/selang -s -f $inp_file | tee -a $log_file

                suc_cnt=`expr $suc_cnt + 1`
        else
                cat $out_file >> $log_file

                err_cnt=`expr $err_cnt + 1`
                err_lst="$err_lst $host_nm "
        fi

        sum_cnt=`expr $sum_cnt + 1`
done

echo >> $log_file
echo "[Total: $sum_cnt, Success: $suc_cnt, failure: $err_cnt]" >> $log_file
echo "Failure Hosts: $err_lst" >> $log_file

[ rule.script file sample ]
cu secadm
er terminal 10.10.10.30 owner(nobody) defacc(none) warning
auth terminal 10.10.10.30 id(root) acc(all)

[ rule.target file sample ]
# Exclude if first character is '#'
# Host_IP(Host_NM)
dc01
dc02
#dc03

No comments:

Post a Comment

◈ Recent Post

▷ UITest demo with TestOne (Mobile, Keypad and Drag until found tip)

[ UITest Demo Environment ] 1. UITest Solution: TestOne 2. Description 데모 설명    How to use keypad, and to drag until found.     키패드를...

◈ Popular Posts