Quote every variables
This commit is contained in:
parent
01893d422a
commit
bf3f13dceb
2 changed files with 10 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
http | 200 | Google website | https://google.com
|
http | 200 | Google website | https://google.com
|
||||||
http4 | 200 | Google website (IPv4) | https://google.com
|
http4 | 200 | Google Website (IPv4) | https://google.com
|
||||||
http6 | 200 | Google website (IPv6) | https://google.com
|
http6 | 200 | Google Website (IPv6) | https://google.com
|
||||||
http | 404 | Google 404 | https://google.com/dummy
|
http | 404 | Google 404 | https://google.com/dummy
|
||||||
ping | 0 | Google ping | 8.8.8.8
|
ping | 0 | Google ping | 8.8.8.8
|
||||||
port | 0 | Google dns | 8.8.8.8 53
|
port | 0 | Google dns | 8.8.8.8 53
|
||||||
|
|
16
tinystatus
16
tinystatus
|
@ -31,15 +31,15 @@ check(){
|
||||||
ping*)
|
ping*)
|
||||||
ping -W${IPv} "${timeout}" -c 1 "${host}" >/dev/null 2>&1
|
ping -W${IPv} "${timeout}" -c 1 "${host}" >/dev/null 2>&1
|
||||||
statuscode=$?
|
statuscode=$?
|
||||||
[ ${statuscode} -ne ${expectedcode} ] && echo 'Host unreachable' > "${tmp}/ko/${name}.error";;
|
[ "${statuscode}" -ne "${expectedcode}" ] && echo 'Host unreachable' > "${tmp}/ko/${name}.error";;
|
||||||
port*)
|
port*)
|
||||||
error="$(nc -w${IPv} "${timeout}" -zv ${host} 2>&1)"
|
error="$(nc -w${IPv} "${timeout}" -zv ${host} 2>&1)"
|
||||||
statuscode=$?
|
statuscode=$?
|
||||||
[ ${statuscode} -ne ${expectedcode} ] && echo "${error}" > "${tmp}/ko/${name}.error";;
|
[ "${statuscode}" -ne "${expectedcode}" ] && echo "${error}" > "${tmp}/ko/${name}.error";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# verity status and write files
|
# verity status and write files
|
||||||
if [ ${statuscode} -eq ${expectedcode} ]; then
|
if [ "${statuscode}" -eq "${expectedcode}" ]; then
|
||||||
echo "Status code: ${statuscode}" > "${tmp}/ok/${name}.status"
|
echo "Status code: ${statuscode}" > "${tmp}/ok/${name}.status"
|
||||||
else
|
else
|
||||||
echo "Status code: ${statuscode}" > "${tmp}/ko/${name}.status"
|
echo "Status code: ${statuscode}" > "${tmp}/ko/${name}.status"
|
||||||
|
@ -55,7 +55,7 @@ command_exists 'curl'
|
||||||
command_exists 'nc'
|
command_exists 'nc'
|
||||||
mkdir -p "${tmp}/ok" "${tmp}/ko" || exit 1
|
mkdir -p "${tmp}/ok" "${tmp}/ko" || exit 1
|
||||||
|
|
||||||
while IFS='\n' read -r line; do
|
while IFS="$(printf '\n')" read -r line; do
|
||||||
ctype="$(get_element 1 "${line}")"
|
ctype="$(get_element 1 "${line}")"
|
||||||
code="$(get_element 2 "${line}")"
|
code="$(get_element 2 "${line}")"
|
||||||
name="$(get_element 3 "${line}")"
|
name="$(get_element 3 "${line}")"
|
||||||
|
@ -83,8 +83,8 @@ li { list-style: none; margin-bottom: 2px; padding: 5px; border-bottom: 1px soli
|
||||||
<div class='container'>
|
<div class='container'>
|
||||||
<h1>Global status</h1>
|
<h1>Global status</h1>
|
||||||
EOF
|
EOF
|
||||||
outagenb=$(find ${tmp}/ko -mindepth 1 | grep -c 'status$')
|
outagenb="$(find "${tmp}/ko" -mindepth 1 | grep -c 'status$')"
|
||||||
if [ ${outagenb} -ne 0 ]; then
|
if [ "${outagenb}" -ne 0 ]; then
|
||||||
echo "<ul><li class='panel failed-bg'>${outagenb} Outage(s)</li></ul>"
|
echo "<ul><li class='panel failed-bg'>${outagenb} Outage(s)</li></ul>"
|
||||||
else
|
else
|
||||||
echo "<ul><li class='panel success-bg'>All Systems Operational</li></ul>"
|
echo "<ul><li class='panel success-bg'>All Systems Operational</li></ul>"
|
||||||
|
@ -93,13 +93,13 @@ cat << EOF
|
||||||
<h1>Services</h1>
|
<h1>Services</h1>
|
||||||
<ul>
|
<ul>
|
||||||
EOF
|
EOF
|
||||||
for file in ${tmp}/ko/*.status; do
|
for file in "${tmp}/ko/"*.status; do
|
||||||
[ -e "${file}" ] || continue
|
[ -e "${file}" ] || continue
|
||||||
name="$(basename "${file}" | sed 's,.status$,,')"
|
name="$(basename "${file}" | sed 's,.status$,,')"
|
||||||
status="$(cat "${file}")"
|
status="$(cat "${file}")"
|
||||||
echo "<li>${name} <span class='small failed'>(${status})</span><span class='status failed'>Disrupted</span></li>"
|
echo "<li>${name} <span class='small failed'>(${status})</span><span class='status failed'>Disrupted</span></li>"
|
||||||
done
|
done
|
||||||
for file in ${tmp}/ok/*.status; do
|
for file in "${tmp}/ok/"*.status; do
|
||||||
[ -e "${file}" ] || continue
|
[ -e "${file}" ] || continue
|
||||||
name="$(basename "${file}" | sed 's,.status$,,')"
|
name="$(basename "${file}" | sed 's,.status$,,')"
|
||||||
echo "<li>${name} <span class='status success'>Operational</span></li>"
|
echo "<li>${name} <span class='status success'>Operational</span></li>"
|
||||||
|
|
Loading…
Reference in a new issue