mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
mcastmngr: fix mcast stats script
Fixed worng temp_igmp_file variable accessing, which caused the same 'temp_igmp_file' file to be used each time 'ubus call mcast stats' was called instead of /tmp/igmp_stats_<PID> file. Because of this, temp file was sometimes overwritten by the next call before it had time to read and the IPTV_IGMP_4-12-1-24_2401.py test ended with an error. A waiting loop has also been added so that mcproxy has time to process the signal and write the dump to a file.
This commit is contained in:
parent
caa0653bfe
commit
e9f64893ac
1 changed files with 20 additions and 8 deletions
|
|
@ -4,15 +4,27 @@
|
||||||
. /lib/functions.sh
|
. /lib/functions.sh
|
||||||
|
|
||||||
read_mcast_stats() {
|
read_mcast_stats() {
|
||||||
|
local temp_igmp_file='/tmp/igmp_stats_'$$
|
||||||
|
local snooping_stats='/tmp/igmp_snooping_stats'
|
||||||
|
local old_mod_time=$(date +%s 2>/dev/null -r "$snooping_stats")
|
||||||
|
|
||||||
temp_igmp_file='/tmp/igmp_stats_'$$
|
|
||||||
# Sending signal to mcproxy to dump multicast data in /tmp/igmp_snooping_stats
|
# Sending signal to mcproxy to dump multicast data in /tmp/igmp_snooping_stats
|
||||||
mcast_pids=$(pidof mcproxy)
|
local mcast_pids=$(pidof mcproxy)
|
||||||
for pid in $mcast_pids
|
for pid in $mcast_pids
|
||||||
do
|
do
|
||||||
$(kill -10 $pid)
|
$(kill -10 $pid)
|
||||||
done
|
done
|
||||||
cat /tmp/igmp_snooping_stats > temp_igmp_file
|
|
||||||
|
# Wait for signal is being processed by mcproxy
|
||||||
|
if [ -n "$mcast_pids" ]; then
|
||||||
|
for i in 1 2 3; do
|
||||||
|
local new_mod_time=$(date +%s 2>/dev/null -r "$snooping_stats")
|
||||||
|
[ -n "$new_mod_time" ] && [ "$new_mod_time" != "$old_mod_time" ] && break
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat "$snooping_stats" > "$temp_igmp_file"
|
||||||
|
|
||||||
local mcast_addrs=""
|
local mcast_addrs=""
|
||||||
local ifaces=""
|
local ifaces=""
|
||||||
|
|
@ -42,7 +54,7 @@ read_mcast_stats() {
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done < temp_igmp_file
|
done < "$temp_igmp_file"
|
||||||
|
|
||||||
while read line; do
|
while read line; do
|
||||||
# reading each line
|
# reading each line
|
||||||
|
|
@ -69,7 +81,7 @@ read_mcast_stats() {
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done < temp_igmp_file
|
done < "$temp_igmp_file"
|
||||||
|
|
||||||
json_init
|
json_init
|
||||||
json_add_array "snooping"
|
json_add_array "snooping"
|
||||||
|
|
@ -89,7 +101,7 @@ read_mcast_stats() {
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done < temp_igmp_file
|
done < "$temp_igmp_file"
|
||||||
IFS=" "
|
IFS=" "
|
||||||
for gip_addr in $mcast_addrs; do
|
for gip_addr in $mcast_addrs; do
|
||||||
grp_obj_added=0
|
grp_obj_added=0
|
||||||
|
|
@ -124,7 +136,7 @@ read_mcast_stats() {
|
||||||
json_close_object #close the associated device object
|
json_close_object #close the associated device object
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done < temp_igmp_file
|
done < "$temp_igmp_file"
|
||||||
json_close_array #close the associated devices array
|
json_close_array #close the associated devices array
|
||||||
json_close_object # close the groups object
|
json_close_object # close the groups object
|
||||||
done # close the loop for group addresses
|
done # close the loop for group addresses
|
||||||
|
|
@ -134,7 +146,7 @@ read_mcast_stats() {
|
||||||
json_close_array # close the snooping array
|
json_close_array # close the snooping array
|
||||||
json_dump
|
json_dump
|
||||||
|
|
||||||
rm -f temp_igmp_file
|
rm -f "$temp_igmp_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue