Flow audit: Difference between revisions

From Essential
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
# application check : update reference
# application check : update reference
# APA 20210323
# APA 20210323
# pacheco at infocepo.com


# initialisation des variables
# initialisation des variables

Revision as of 18:07, 14 March 2022

#!/bin/bash
# application check : update reference
# APA 20210323
# pacheco at infocepo.com

# initialisation des variables
#  hostCheck="$1"
  baseDir="$(realpath "$(dirname $0)"/..)"
  cacheFile=/tmp/"$(basename $0)"$$
#  logFile="${baseDir}"/log/"$(basename $0)"-"$(echo "${hostCheck}" | tr -c '[:alnum:]' '_' | cut -c 1-68 )".$(date -u '+%Y-%m-%dT%H_%M_%SZ')

cat <<EOT >/tmp/flow-script
lsof -i -P |tail -n +2 |grep -vEw localhost |awk '{print \$3"@"\$1" "\$9}' |sed -r "s# [^:]+##" |sed -r "s#(-...|).infocepo.com##g" |sed -r "s#\broot@##g" |sed -r "s#-mgt\b##g" |env LC_COLLATE=C sort -u |grep -v ">\$(hostname -s)" \
>/tmp/tiers\$\$

cat /tmp/tiers\$\$ >/tmp/tiers\$\$-in
cat /tmp/tiers\$\$-in |grep -v "\->" |sed -r "s#^[^:]+##" |while read lineMy ;do
  sed -ri "s#^([^:]+\${lineMy})\->([^:]+):.*\\\$#\1<\-\2#g" /tmp/tiers\$\$
  #echo sed -ri "#^[^:]+\${lineMy}\$#d" /tmp/tiers\$\$
done

cat /tmp/tiers\$\$ |sed -r "s#:.*->#->#" |sort -u |\
sed -r 's#^#\t\t\t-> #' |\
sed -r 's#^\t(.*)<-(.*)#\2\1#' |\
sed -r 's#^(.*)->( .*)->(.*)#\1  \2\t\t\t-> \3#'

rm -f /tmp/tiers\$\$*
EOT
#.scriptDiff.sh "$(hostList.sh infocepo |grep -E "p(|-mgt)$" )" /tmp/flow-script >/tmp/flow-ex
.scriptComm.sh infocepo /tmp/flow-script |gzip >/exploitation/env/flow-infra-comm.gz
.scriptDiff.sh infocepo /tmp/flow-script >/tmp/flow-ex
cat /tmp/flow-ex
 #|awk '!seen[$0]++'

#=== update db flow ===
cat /tmp/flow-ex |gzip >/exploitation/env/flow-infra.gz