Prev | Current Page 335 | Next

Chris Tyler

"X Power Tools"

sh :: monitor server availability, warn user if service unavailable
#
# === Configuration variables
# Seconds between service availability tests
SECONDS=15
# Command to test the server availability
CHECK="wget http://yellow/ --spider -t 1"
# URIs for warning message (should be file://...) and kiosk's homepage
WARN="file:/usr/local/kiosk/outage_warning.html"
HOMEPAGE="http://yellow/"
# === End of configuration variables
STATE="UP"
while sleep $SECONDS
do
$CHECK
RESULT=$?
case "$STATE" in
"UP")
if [ "$RESULT" -ne "0" ]
then
firefox -remote "openurl($WARN)"
STATE="DOWN"
fi
;;
"DOWN")
if [ "$RESULT" -eq 0 ]
then
firefox -remote "openurl($HOMEPAGE)"
STATE="UP"
fi
;;
esac
done
This script uses the Firefox -remote argument to instruct a running instance of Firefox
to load a local error message page ($WARN) or the kiosk??™s home page on the
remote server ($HOMEPAGE) when connectivity to the remote server is lost or restored.
15.7
15.7 Network Status Monitoring 227
If you??™re setting up a kiosk that uses an application other than a browser, substitute
another command to check that the remote server is accessible and replace the
browser messages with a graphic image that will fill the screen when the server is
down:
#!/bin/bash
#
# monitor.


Pages:
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347