Skip to content

Instantly share code, notes, and snippets.

@nachouve
Created February 28, 2014 13:59
Show Gist options
  • Save nachouve/9271549 to your computer and use it in GitHub Desktop.
Save nachouve/9271549 to your computer and use it in GitHub Desktop.
Simple script to check web services/pages with request each 'SLEEP_TIME' seconds.
#!/bin/bash
# Very simple script to check web services/pages with request each 'SLEEP_TIME' seconds.
# It is useful for health checks of OGC services.
#
# IMPORTANT: You must configure the RESPONSE_CHARS_NUM_EXPECTED used to compare with the real response.
#
# It has a infinite loop.
# Recomended redirect output to a file.
#
# Author: Nacho Varela
# License: GPL3+
##################### PARAMS ##########################
# Time between requests
SLEEP_TIME=90
# Service to request
URL='http://arcgispre/arcgis/services/Viticola/Viticola_SIXPAC13_WFS_PRE/MapServer/WFSServer/'
# Parameters of the request
PARAMS='SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&&FILTER=<ogc:Filter><ogc:BBOX><ogc:PropertyName>Shape</ogc:PropertyName><gml:Box%20srsName="urn:x-ogc:def:crs:EPSG:25829"><gml:coordinates>602269,4703983%20604269,4705983</gml:coordinates></gml:Box></ogc:BBOX></ogc:Filter>&TypeName=Viticola_Viticola_SIXPAC13_WFS_PRE:Recintos_2013'
# Number of chars exoected on the request (you must calculate it previusly)
RESPONSE_CHARS_NUM_EXPECTED=12048370
##################### END PARAMS ##########################
while [ 1 ] ; do
RESPONSE_CHARS_NUM_RECEIVED=$(curl --silent --show-error $URL'?'$PARAMS | grep $URL | wc -c)
datetime=$(date +%Y%m%d-%H:%M:%S)
if [ $RESPONSE_CHARS_NUM_EXPECTED -eq $RESPONSE_CHARS_NUM_RECEIVED ]; then
echo $datetime': Correct! '$URL
else
echo $datetime': Fails! '$URL
fi
sleep $SLEEP_TIME
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment