Last active
December 23, 2018 00:54
-
-
Save phunehehe/5564090 to your computer and use it in GitHub Desktop.
Script to check multiple URLs in Nagios, see http://phunehehe.net/check-multiple-urls-nagios/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
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
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!!