#!/usr/bin/env bash
#
# export USERNAME=jpoland.oa;export PASSWORD='XXXXXCHANGEMEXXXXX'; docker run --rm -e PASSWORD=$PASSWORD -e USERNAME=$USERNAME -v /home/johnp/scsd-configs/git:/repo -v /home/johnp/scsd-configs/git/code:/work -v /home/johnp/scsd-configs/git/configs/:/configs  --privileged -t scsdansible /work/run_space_check.sh 2>/dev/null | tee space_check.txt
#
#
openfortivpn vpn.scsd.us:10443 --username=$USERNAME --trusted-cert fda7d7ed64a9bd84562c6643e858c4a61cfdc6e90b0d4ee60e07fd0bb7fb7a9f --password=$PASSWORD &
while [ ! `ip a | grep -q "inet .*ppp" && echo "1"`   ];
do
    #echo checking
    sleep 1
done
sleep 3

for sw in $(ansible-inventory --list -i inventory.yml | jq -r '._meta.hostvars | keys | .[]'| grep -E "a");do 
	ip=$(ansible-inventory --list -i inventory.yml | jq -r '._meta.hostvars["'$sw'"]["ansible_host"]')
	echo -n $sw $ip" "

        python space_check.py --user $USERNAME --password $PASSWORD --ip $ip --switchname $sw | grep -E 'tmpfs|ERROR'

done
