diff options
author | coderick14 | 2017-06-30 01:43:51 +0530 |
---|---|---|
committer | coderick14 | 2017-06-30 01:43:51 +0530 |
commit | 000f50a2ae71d6e938ab7841fdf8ccbc2fedd3c2 (patch) | |
tree | 79a26249e585a16a9a83310544c6dd4e8e64a2e3 | |
parent | a50a19a341c593e92313588d508ec7ee284f43d3 (diff) | |
download | SBHS-2018-Rpi-000f50a2ae71d6e938ab7841fdf8ccbc2fedd3c2.tar.gz SBHS-2018-Rpi-000f50a2ae71d6e938ab7841fdf8ccbc2fedd3c2.tar.bz2 SBHS-2018-Rpi-000f50a2ae71d6e938ab7841fdf8ccbc2fedd3c2.zip |
Fetch logs from RPis during cronjob
-rw-r--r-- | new_cron_job.sh | 2 | ||||
-rw-r--r-- | sbhs_server/scan_rpis.sh | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/new_cron_job.sh b/new_cron_job.sh index 7bf6e6d..0ac4e53 100644 --- a/new_cron_job.sh +++ b/new_cron_job.sh @@ -8,7 +8,7 @@ find $(pwd) -iname \*.pyc -exec rm -rfv {} \; #to delete all .pyc files DIR="$( cd "$( dirname "$0" )" && pwd )" cd $DIR killall streamer -source ../bin/activate +source ../venv/bin/activate #source ./bin/activate #python sbhs_server/scan_machines.py bash sbhs_server/scan_rpis.sh diff --git a/sbhs_server/scan_rpis.sh b/sbhs_server/scan_rpis.sh index 4577a41..14edac1 100644 --- a/sbhs_server/scan_rpis.sh +++ b/sbhs_server/scan_rpis.sh @@ -5,15 +5,16 @@ cd sbhs_server mkdir -p RPi_data mkdir -p RPi_data/map RPi_data/report -# get IP addresses of connected Raspberry Pi's -nmap -n -sP 10.42.0.255/24 | grep -E -o "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])" | grep -v "10.42.0.1" > RPi_data/ipaddrs.txt - # Get map_machine_ids.txt and server reports from all connected Raspberry Pi's while read -r ip do - curl -o RPi_data/map/$ip.txt $ip/map_machine_ids.txt - curl -o RPi_data/report/$ip.txt $ip/report.json + echo $ip + curl -o RPi_data/map/$ip.txt $ip/map_machine_ids.txt + curl -o RPi_data/report/$ip.txt $ip/report.json + rsync -arz --exclude="django_error.log" -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress pi@$ip:/home/pi/sbhs-pi/log/ /home/vlabs-sbhs/code/sbhs/log/ + rsync -arz --remove-source-files -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress pi@$ip:/home/pi/sbhs-pi/experiments/ /home/vlabs-sbhs/code/sbhs/experiments/ done < "RPi_data/ipaddrs.txt" # Execute script to create IP map -python create_ip_map.py
\ No newline at end of file +python create_ip_map.py + |