9 - name: Install grepcidr
14 - include_vars: "{{ ConfigFileName }}"
15 - debug: var="trafficpresence"
16 failed_when: "'trafficpresence' is not defined"
18 - name: Get fw interface
20 IP_PPNET=$(cat /etc/network/interfaces |grep address | awk '{print $2}' | grepcidr -f /opt/config/protected_private_net_cidr.txt)
21 cat /etc/network/interfaces | grep $IP_PPNET -B1 | grep iface | awk '{print $2}'
22 register: fw_ppnet_iface
24 - name: Traffic check if trafficpresence is TRUE
25 when: trafficpresence == true
27 - name: Traffic check if trafficpresence is TRUE
30 COL=$(netstat -i|grep lo |awk '{print NF}')
31 if [ $COL -eq 11 ] ; then NCOL=7
32 elif [ $COL -eq 12 ] ; then NCOL=8
33 else echo "bad NETSTAT version"
35 TXOK_INITIAL=$(netstat -i | fgrep "{{ fw_ppnet_iface.stdout }}" | awk -v col=$NCOL '{print $col}')
37 for i in {1..{{ time_measure }}}
39 TXOK_CURRENT=$(netstat -i | fgrep "{{ fw_ppnet_iface.stdout }}" | awk -v col=$NCOL '{print $col}')
40 if [ $TXOK_CURRENT -gt $TXOK_INITIAL ] ; then
41 echo 'traffic present'
47 if [ $TXOK_CURRENT -eq $TXOK_INITIAL ] ; then
51 register: traffic_check
54 msg: 'traffic absent {{ traffic_check.stdout_lines }} '
55 when: traffic_check.rc == 1
56 failed_when: traffic_check.rc == 1
58 msg: 'traffic present {{ traffic_check.stdout_lines }} '
59 when: traffic_check.rc == 0
61 - name: Traffic check if trafficpresence is FALSE
62 when: trafficpresence == false
64 - name: Traffic check trafficpresence is FALSE
67 COL=$(netstat -i|grep lo |awk '{print NF}')
68 if [ $COL -eq 11 ] ; then NCOL=7
69 elif [ $COL -eq 12 ] ; then NCOL=8
70 else echo "bad NETSTAT version"
72 for i in {1..{{ time_measure }}}
74 TXOK_INITIAL=$(netstat -i | fgrep "{{ fw_ppnet_iface.stdout }}" | awk -v col=$NCOL '{print $col}')
76 TXOK_CURRENT=$(netstat -i | fgrep "{{ fw_ppnet_iface.stdout }}" | awk -v col=$NCOL '{print $col}')
77 if [ $TXOK_CURRENT -eq $TXOK_INITIAL ] ; then
82 if [ $TXOK_CURRENT -gt $TXOK_INITIAL ] ; then
83 echo 'traffic present'
86 register: traffic_check
89 msg: 'traffic absent {{ traffic_check.stdout_lines }} '
90 when: traffic_check.rc == 0
92 msg: 'traffic present {{ traffic_check.stdout_lines }} '
93 when: traffic_check.rc == 1
94 failed_when: traffic_check.rc == 1