Created
September 13, 2015 06:27
-
-
Save lokulin/7e733e6d00641e1ce17f to your computer and use it in GitHub Desktop.
Get the vpn status from a QNAP appliance and return a JSON string
This file contains 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
#!/usr/bin/env bash | |
BASE_URI="https://127.0.0.1/cgi-bin" | |
USER="" | |
ENCPWD="" | |
sid=$(curl --silent "${BASE_URI}/authLogin.cgi?user=${USER}&pwd=${ENCPWD}" | xmlstarlet sel -t -v "QDocRoot/authSid" -) | |
function get_status { | |
curl --silent "${BASE_URI}/application/appRequest.cgi?subfunc=vpn_client&sid=${sid}" | | |
xmlstarlet sel -t \ | |
-o '{"status":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/status" \ | |
-o ',"tx":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/tx" \ | |
-o ',"rx":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/rx" \ | |
-o ',"timestamp":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/timestamp" -o "} | |
" - | |
} | |
get_status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment