diff --git a/handle_post.sh b/handle_post.sh index e89d154..85e7309 100755 --- a/handle_post.sh +++ b/handle_post.sh @@ -1,7 +1,7 @@ #!/bin/bash if [[ "$REQUEST_PATH_SANE" =~ ^refresh ]]; then - ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2) + ip=$(echo "$POST_DATA" | cut -d '=' -f2) body="{\n\"time\": \"$(date +%T)\",\n" body+="\"status\": \"unknown\"\n}\n" diff --git a/handle_requests.sh b/handle_requests.sh index 0b10a68..f9795c6 100755 --- a/handle_requests.sh +++ b/handle_requests.sh @@ -1,35 +1,5 @@ #!/bin/bash -if [[ "$REQUEST_PATH_SANE" =~ ^refresh ]]; then - ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2) - - body="{\n\"time\": \"$(date +%T)\",\n" - body+="\"status\": \"unknown\"\n}\n" - -cat < status/$ip - - ret=1 - for i in {0..30}; do - ping -c 1 -w 5 -t 1 -q "$ip" > /dev/null 2>&1 - ret=$? - [ $ret -eq 0 ] && break - done - - echo -e "{\n\"time\": \"$(date +%T)\"," > status/$ip - - if [ $ret -eq 0 ]; then - echo -e "\"status\": \"up\"\n}\n" >> status/$ip - else - echo -e "\"status\": \"down\"\n}\n" >> status/$ip - fi - exit 0 -fi - if [[ "$REQUEST_PATH_SANE" =~ ^status ]]; then ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2) diff --git a/static/main.js b/static/main.js index fd6ff88..c940c78 100644 --- a/static/main.js +++ b/static/main.js @@ -41,8 +41,10 @@ var request_refresh = function (host) { } }); - request.open("GET", "refresh/" + host.ip); - request.send(); + var params = "ip=" + host.ip; + request.open("POST", "refresh", true); + request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + request.send(params); setTimeout(function () { request_status(host); @@ -70,7 +72,6 @@ var request_wol = function (host) { }); var params = "mac=" + host.mac; - request.open("POST", "wol", true); request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.send(params);