Skip to content

Commit 88cc21f

Browse files
committed
Issue hestiacp#63 - improved interface parsing
1 parent 4af3103 commit 88cc21f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bin/v-update-sys-rrd-net

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ if [ ! -d "$RRD/net" ]; then
3636
fi
3737

3838
# Parsing network interfaces
39-
ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g")
39+
ndev=$(cat /proc/net/dev)
40+
ifaces=$(echo "$ndev" |grep : |cut -f 1 -d : |sed -e "s/ //g")
4041

4142
# Parsing excludes
4243
for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do
@@ -62,9 +63,9 @@ for iface in $ifaces; do
6263

6364
# Parsing device stats
6465
if [ "$period" = 'daily' ]; then
65-
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
66-
rx=$(echo "$raw_iface" |awk '{print $2}')
67-
tx=$(echo "$raw_iface" |awk '{print $10}')
66+
x=$(echo "$ndev" |sed -e "s/^ *//" |grep "^$iface:" |sed -e "s/:/ /")
67+
rx=$(echo "$x" |awk '{print $2}')
68+
tx=$(echo "$x" |awk '{print $10}')
6869

6970
# Updating rrd database
7071
rrdtool update $RRD/net/$iface.rrd N:$rx:$tx

0 commit comments

Comments
 (0)