Professional Documents
Culture Documents
/usr/bin/env bash
#- check_soap.sh v1 Aaron Gorka 2016
## Usage: ./check_soap.sh --action [STRING] --url [URL] --grep [REGEX] --soap [XML]
-warn [INT] --crit [INT]
##
## Generic plugin to query a SOAP API and retrieve a value embedded in it
##
## -s|--soap SOAP request in XML format. Recommend keeping it on one line
and surrounding it with single quotes.
## -a|--action SOAP action
## -u|--url Full URL to send the SOAP request to
## -w|--warn Return WARN state when value is above this
## -c|--crit Return CRIT state when value is above this
## -g|--grep Regular expression passed to 'grep -Po' used to extract a
value from the XML output
## -o|--curlopts Any additional arguments to be passed to cURL, e.g. '--
insecure'
## -D|--debug Print debug info
## -h|--help Show help options.
## -v|--version Print version info.
##
## Example
## ./check_soap.sh --action "tsl" --url "http://dc1prd309:25086/soap/tsl" --grep
'(?<=MessagesWaiting>)[0-9]+(?=</)' --soap '<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tn="http://www.topcall.com/XMLSchema/2004/tn"
xmlns:mon="http://www.kofax.com/2011/Monitor"><soapenv:Header><tn:credentials>cid:1
029314174599</tn:credentials></soapenv:Header><soapenv:Body><mon:GetMessagesWaiting
><mon:Type>ALL</mon:Type></mon:GetMessagesWaiting></soapenv:Body></soapenv:Envelope
>' --warn 300 --crit 600
# Failsafe settings
LC_ALL=C
PATH='/sbin:/usr/sbin:/bin:/usr/bin'
set -o noclobber
set -o errexit
set -o nounset
set -o pipefail
shopt -s nullglob
unalias -a
PLUGIN='SOAP'
PERFDATA="'messages'=${VALUE}messages;${WARN};${CRIT};;"