diff --git a/task-2/team-16/host_network_moniter.txt b/task-2/team-16/host_network_moniter.txt new file mode 100644 index 0000000..49abcb2 --- /dev/null +++ b/task-2/team-16/host_network_moniter.txt @@ -0,0 +1,14 @@ +18:51:39 => 26/05/2022 :ping success 142.250.67.174 host is up +20:26:44 => 26/05/2022 :ping success 142.250.67.174 host is up +20:30:17 => 26/05/2022 :ping success 142.250.67.174 host is up +21:36:15 => 01/06/2022 :ping success 142.250.67.174 host is up +21:40:43 => 01/06/2022 :ping success DEFAULTVALUE host is up +21:42:39 => 01/06/2022 :ping success host is up +21:48:18 => 01/06/2022 :ping success host is up +21:48:35 => 01/06/2022 :ping success 1 host is up +21:50:16 => 01/06/2022 :ping success host is up +21:53:17 => 01/06/2022 :ping success 142.250.67.174 host is up +21:53:39 => 01/06/2022 :ping success 0 host is up +21:54:40 => 01/06/2022 :ping success 10.0.0.1 host is up +21:54:49 => 01/06/2022 :ping success 10.0.0.11 host is up +21:55:25 => 01/06/2022 :ping success 192.168.1.45 host is up diff --git a/task-2/team-16/script1.sh b/task-2/team-16/script1.sh new file mode 100755 index 0000000..6c132e7 --- /dev/null +++ b/task-2/team-16/script1.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +#requiement sudo permission and nmap installed +PORT_FILE="port_file.txt" + +function port_find() { + echo "--------------------------------------------------------------------------------------" + sudo nmap -sT -O "$1" >port_file.txt + port="" + while read -r line; do + if [ "$line" = "PORT STATE SERVICE" ]; then + re='^[0-9]+$' + read -r line + port=$(echo "$line" | awk '{print $1}') + status=$(echo "$line" | awk '{print $2}') + p=${port:0:1} + while [[ $p =~ $re ]]; do + echo 'port '"$port" 'of the host '"$1" 'is' "$status" + read -r line + port=$(echo "$line" | awk '{print $1}') + p=${port:0:1} + done + # echo 'port '"$port" 'of the host '"$1" 'is' "$status" + # p=$(echo "$line" | awk '{print $1}') + + fi + done <$PORT_FILE + if [ "$port" = "" ]; then + printf '%s\n Host seems down. If it is really up, but blocking our ping probes' "$line" + fi + rm port_file.txt +} +echo "--------------------------------------------------------------------------------------" +echo "Enter an ip : " +read -r ip +port_find "$ip" diff --git a/task-2/team-16/script2.sh b/task-2/team-16/script2.sh new file mode 100755 index 0000000..108c8df --- /dev/null +++ b/task-2/team-16/script2.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + + +function status_record() { + time=$(date +%k:%M:%S) + date=$(date +%d/%m/%Y) + suc_or_fal="" + up_or_down="" + + + ping "$1" & + sleep 5 && pingResponse=$? && kill -9 "$(pgrep ping)" + + + if [ $pingResponse -eq 0 ]; then + up_or_down="up" + suc_or_fal="success" + else + up_or_down="not up" + suc_or_fal="failed" + fi + + result="${time} => ${date} :ping ${suc_or_fal} $1 host is ${up_or_down}" + echo "$result" + echo "$result" >> host_network_moniter.txt +} + +while true; do + status_record "142.250.67.174" + sleep 60m + +done diff --git a/task-2/team-16/script3.sh b/task-2/team-16/script3.sh new file mode 100755 index 0000000..a6da49c --- /dev/null +++ b/task-2/team-16/script3.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +curl -X GET http://gincy.pythonanywhere.com/ -H "Accept: */*" +echo +echo "===========================================================================" + +# Task 3 +curl -X GET http://gincy.pythonanywhere.com/getusers -H "Accept: */*" + + + +echo +echo "===========================================================================" + + + +# Task 4 +echo "User vinay : " +curl -X POST http://gincy.pythonanywhere.com/login -H "Authorization: "username":"vinay"," -H "Content-Type: application/json" --data-binary @- <