diff --git a/fritzBoxShell.sh b/fritzBoxShell.sh
index 6ba22dd..0257ff9 100755
--- a/fritzBoxShell.sh
+++ b/fritzBoxShell.sh
@@ -73,6 +73,10 @@ while [[ $# -gt 0 ]]; do
-F|--outputfilter)
OutputFilter="$2"
shift ; shift
+ ;;
+ --backupConfFolder)
+ backupConfFolder="$2"
+ shift ; shift
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
@@ -531,6 +535,80 @@ WLANGUESTstatistics() {
fi
}
+### ----------------------------------------------------------------------------------------------------- ###
+### -------------------------------- FUNCTION LANcount - TR-064 Protocol -------------------------------- ###
+### ----------------------------------------------------------------------------------------------------- ###
+
+
+LANcount() {
+ # TR-064 service information
+ SERVICE="urn:dslforum-org:service:Hosts:1"
+ CONTROL_URL="/upnp/control/hosts"
+
+ total_hosts=$(curl -s -k -m 5 --anyauth -u "$BoxUSER:$BoxPW" "http://$BoxIP:49000$CONTROL_URL" \
+ -H 'Content-Type: text/xml; charset="utf-8"' \
+ -H "SoapAction:$SERVICE#GetHostNumberOfEntries" \
+ -d "
+
+
+
+
+ " | grep NewHostNumberOfEntries | awk -F">" '{print $2}' | awk -F"<" '{print $1}')
+ # echo "Total number of hosts: $total_hosts"
+
+ # 2. Loop through devices and filter for Ethernet
+ # Count Ethernet devices
+ ethernet_count=0
+
+ # Maximal parallel processes
+ max_parallel=10
+ pids=() # Array for process IDs
+
+ # Loop through all hosts and query them in parallel
+ for ((i=0; i
+
+
+ $i
+
+ " | grep NewInterfaceType | awk -F">" '{print $2}' | awk -F"<" '{print $1}')
+
+ if [[ "$interface_type" == "Ethernet" ]]; then
+ # Count Ethernet connections
+ echo 1 >> /tmp/ethernet_count.tmp
+ fi
+ ) &
+
+ # Store process IDs
+ pids+=($!)
+
+ # If the number of background processes reaches the limit, we wait for the first process
+ if (( ${#pids[@]} >= max_parallel )); then
+ # Wait for one of the running processes
+ wait "${pids[0]}"
+ # Remove the first process from the array
+ pids=("${pids[@]:1}")
+ fi
+ done
+
+ wait
+
+ # Sum of Ethernet connections
+ ethernet_count=$(wc -l < /tmp/ethernet_count.tmp)
+
+ # Print result
+ echo "Number of Ethernet connections: $ethernet_count"
+
+ # Delete temporary file
+ rm /tmp/ethernet_count.tmp
+
+}
+
### ----------------------------------------------------------------------------------------------------- ###
### -------------------------------- FUNCTION LANstate - TR-064 Protocol -------------------------------- ###
### ----------------------------------------------------------------------------------------------------- ###
@@ -982,9 +1060,9 @@ confBackup() {
# File Downlaod
dt=$(date '+%Y%m%d_%H%M%S');
- $(curl -s -k "$curlOutput1" -o "${dt}_SicherungEinstellungen.export" --anyauth -u "$BoxUSER:$BoxPW")
- if [ -e "${dt}_SicherungEinstellungen.export" ]; then
- echo "File successfully downloaded: ${dt}_SicherungEinstellungen.export"
+ $(curl -s -k "$curlOutput1" -o "$backupConfFolder${dt}_SicherungEinstellungen.export" --anyauth -u "$BoxUSER:$BoxPW")
+ if [ -e "${backupConfFolder}${dt}_SicherungEinstellungen.export" ]; then
+ echo "File successfully downloaded: ${backupConfFolder}${dt}_SicherungEinstellungen.export"
fi
}
@@ -1040,6 +1118,7 @@ DisplayArguments() {
echo "| | totalConnectionsLAN | Number of total connected LAN clients (incl. full Mesh) |"
echo "|-----------------|---------------------------|-----------------------------------------------------------------------------|"
echo "| LAN | STATE | Statistics for the LAN easily digestible by telegraf |"
+ echo "| LAN | COUNT | Total number of connected devices through ethernet |"
echo "| DSL | STATE | Statistics for the DSL easily digestible by telegraf |"
echo "| WAN | STATE | Statistics for the WAN easily digestible by telegraf |"
echo "| WAN | RECONNECT | Ask for a new IP Address from your provider |"
@@ -1111,6 +1190,7 @@ else
fi
elif [ "$option1" = "LAN" ]; then
if [ "$option2" = "STATE" ]; then LANstate "$option2";
+ elif [ "$option2" = "COUNT" ]; then LANcount "$option2";
else DisplayArguments
fi
elif [ "$option1" = "DSL" ]; then
diff --git a/fritzBoxShellConfig.sh b/fritzBoxShellConfig.sh
index 7f49427..3bc7d3e 100644
--- a/fritzBoxShellConfig.sh
+++ b/fritzBoxShellConfig.sh
@@ -13,3 +13,6 @@
[[ -z "$RepeaterIP" ]] && RepeaterIP="fritz.repeater"
[[ -z "$RepeaterUSER" ]] && RepeaterUSER="" #Usually on Fritz!Repeater no User is existing. Can be left empty.
[[ -z "$RepeaterPW" ]] && RepeaterPW="YourPassword"
+
+# In case you are using the Fritz!Box Backup export this path is used to download the backup - kepp empty if you want to use the same directory than the script
+[[ -z "$backupConfFolder" ]] && backupConfFolder="" # Dont forget the "/" at the end!!!
\ No newline at end of file