Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Script to check multiple URLs in Nagios, see http://phunehehe.net/check-multiple-urls-nagios/
#!/bin/bash
# Split URLs by comma
urls=${1//,/ }
for url in $urls
do
hostname="${url%%/*}"
if [[ "$url" = */* ]]
then
# Domain plus path, like example.com/path
path="/${url#*/}"
else
# Just domain, like example.com
path=/
fi
result="$(/usr/lib/nagios/plugins/check_http --hostname "$hostname" --url "$path")"
status="$?"
if [[ "$status" -ne 0 ]]
then
# First warning is the final result
echo "$url: $result"
exit "$status"
fi
done
echo "All URLs OK: $urls"

Hi @phunehehe. Sorry if this is too old for you, but I'm looking for a multi-url-checker. This plugin is not working for me. Is there a particular sintaxis I should use to execute this against a group of urls?? Thanks!!

I can't either get this to work. I have a bunch of URL's. It shows All Urls OK even when given a wrong URL in the $urls !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment