Created
January 8, 2014 14:01
-
-
Save nielsvanderbeke/8317140 to your computer and use it in GitHub Desktop.
script to get your telenet isp usage
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
#!/bin/sh | |
###################################################################### | |
# script telemeter.sh | |
# purpose Get internet usage indicator telenet using telemeter webservice | |
# author Niels Vanderbeke | |
# date 20140103 | |
# parameters none | |
# changed at 20140103 | |
# changed by Niels Vanderbeke | |
###################################################################### | |
#---------------------------------------------------------------------- | |
# Variables | |
#---------------------------------------------------------------------- | |
UserId="*****" | |
Password="****" | |
#---------------------------------------------------------------------- | |
# Construct soap envelope | |
#---------------------------------------------------------------------- | |
echo " | |
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://www.telenet.be/TelemeterService/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> | |
<SOAP-ENV:Body> | |
<mns1:RetrieveUsageRequest xmlns:mns1='http://www.telenet.be/TelemeterService/'> | |
<UserId>$UserId</UserId> | |
<Password>$Password</Password> | |
</mns1:RetrieveUsageRequest> | |
</SOAP-ENV:Body> | |
</SOAP-ENV:Envelope> | |
" > .temp.request.xml | |
#---------------------------------------------------------------------- | |
# Execute webserivce call using soap envelope in .temp.request.xml | |
# WSDL : https://t4t.services.telenet.be/TelemeterService.wsdl | |
#---------------------------------------------------------------------- | |
ACTION="retrieveUsage" | |
URL="https://t4t.services.telenet.be/TelemeterService" | |
curl -o .temp.respons.xml --silent --connect-timeout 5 --max-time 10 --retry 5 --fail --insecure --header "Content-Type: text/xml; charset=utf-8" --header "SOAPAction:$ACTION" [email protected] $URL > .temp.respons.xml | |
RETVAL=$? | |
#---------------------------------------------------------------------- | |
# Parse output webserivce call .temp.request.xml if webserice call was succesfull | |
#---------------------------------------------------------------------- | |
if [ $RETVAL -eq 0 ]; then | |
PeriodeFrom=$(echo "cat //FUP/Period/From/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
PeriodeTill=$(echo "cat //FUP/Period/Till/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
PeriodeCurrentDay=$(echo "cat //FUP/Period/CurrentDay/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
UsageTotalUsage=$(echo "cat //FUP/Usage/TotalUsage/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
UsageMinUsageRemaining=$(echo "cat //FUP/Usage/MinUsageRemaining/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
UsageMaxUsageRemaining=$(echo "cat //FUP/Usage/MaxUsageRemaining/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
UsageUnit=$(echo "cat //FUP/Usage/Unit/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
UsageLastUpdate=$(echo "cat //FUP/Usage/LastUpdate/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
StatusDescriptionNL=$(echo "cat //FUP/StatusDescription/NL/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
StatusDescriptionFR=$(echo "cat //FUP/StatusDescription/FR/text()" | xmllint --shell .temp.respons.xml | grep -v "/ >" | grep -v " -------") | |
echo "Status : $StatusDescriptionNL, periode $PeriodeFrom tot $PeriodeTill ( huidige dag : $PeriodeCurrentDay )" | |
echo "Verbose : $UsageTotalUsage $UsageUnit ( Laatste update $UsageLastUpdate )" | |
echo "Max : UsageMaxUsageRemaining - $UsageMaxUsageRemaining $UsageUnit , UsageMinUsageRemaining - $UsageMinUsageRemaining $UsageUnit" | |
fi | |
#---------------------------------------------------------------------- | |
# Cleanup | |
#---------------------------------------------------------------------- | |
rm .temp.request.xml .temp.respons.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment