... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
# vim: ft=sh |
2 |
+dir=$1 |
|
2 | 3 |
|
3 | 4 |
function nginx () { |
4 | 5 |
nc -zw2 127.0.0.1 80 || echo "injoignable sur port 80 local" |
... | ... |
@@ -18,6 +19,31 @@ function cherrymusic () { |
18 | 19 |
nc -zw2 127.0.0.1 8080 || echo "injoignable sur port 8080" |
19 | 20 |
} |
20 | 21 |
|
22 |
+function webapps () { |
|
23 |
+ local webapps_conf="$dir/${HOSTNAME}.webapps.conf" |
|
24 |
+ if test -r $webapps_conf; then |
|
25 |
+ local useragent= |
|
26 |
+ local host= |
|
27 |
+ local proto= |
|
28 |
+ local webapps=() |
|
29 |
+ local no_access=() |
|
30 |
+ eval "$(< $webapps_conf)" |
|
31 |
+ test -z "$useragent" && echo "manque user-agent" && return |
|
32 |
+ test -z "$host" && echo "manque hôte" && return |
|
33 |
+ test -z "$proto" && echo "manque protocole" && return |
|
34 |
+ test $(( ${#webapps[@]} % 3 )) -ne 0 && echo "mauvais nombre de paramètres de tests" && return |
|
35 |
+ for ((i=0; i<${#webapps[@]}; i+=3)); do |
|
36 |
+ http_response=$(curl --silent --max-time 2 --user-agent "$useragent" --output /dev/null --write-out "%{response_code}" $proto://$host/${webapps[i]}) |
|
37 |
+ test $http_response -ne ${webapps[i+2]} && no_access[${#no_access[@]}]="${webapps[i+1]} ($http_response)" |
|
38 |
+ done |
|
39 |
+ if test ${#no_access[@]} -ne 0; then |
|
40 |
+ echo "réponse incorrecte: ${no_access[@]}" |
|
41 |
+ fi |
|
42 |
+ else |
|
43 |
+ echo "pas de conf! ($webapps_conf)" |
|
44 |
+ fi |
|
45 |
+} |
|
46 |
+ |
|
21 | 47 |
function core_temp () { |
22 | 48 |
local min=60 |
23 | 49 |
local level=("warning" "severe" "danger!") |