Wednesday, 15 May 2013

xml - How do i check a remote soap service from bash and check it has a specific string -



xml - How do i check a remote soap service from bash and check it has a specific string -

i want check remote soap server, sending xml , greping string? if it's successful want output xml file can utilize pingdom check uptime of service.

here script used this. add together cron, run every 60 seconds, output result web root , utilize http custom check in pingdom or other monitoring tool:

#!/bin/bash # result file file="/var/www/vhostwebroot/out.xml" # remove file if exists (from previous runs) if [ -e $file ];then rm $file fi # set start time start=$(date +%s%3n) # soap_text.xml soap phone call want post remote server test=$(curl --silent -d @soap_test.xml -h "content-type: application/soap+xml" -h 'soapaction: ""' https://www.soap-server-to-check/service-endpoint | grep -o 'string want check for') # set end time end=$(date +%s%3n) # calculate elapsed time el=$(($end-$start)) # if string exists, output xml file if [ "$test" = 'string want check for' ] # output appropriately formatted file pingdom check echo "<pingdom_http_custom_check> <status>ok</status> <response_time>$el</response_time> </pingdom_http_custom_check>" > $file else # if check fails, output failure doc echo "<pingdom_http_custom_check> <status>down</status> <response_time>$el</response_time> </pingdom_http_custom_check>" > $file fi

xml bash curl soap

No comments:

Post a Comment