mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Update vnstat
This commit is contained in:
parent
cb4dce3f03
commit
155e56460e
6 changed files with 298 additions and 0 deletions
53
vnstat/files/vnstat.rpcd
Executable file
53
vnstat/files/vnstat.rpcd
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
echo '{ "speed": { "ifname": "eth0" }, "speedallif": {},"hours": { "ifname": "eth0" },"days": { "ifname": "eth0" },"months": { "ifname": "eth0" },"weeks": { "ifname": "eth0" },"top10": { "ifname": "eth0" } }'
|
||||
;;
|
||||
call)
|
||||
case "$2" in
|
||||
speed)
|
||||
read input;
|
||||
IFNAME=`echo $input | jsonfilter -e '@.ifname'`
|
||||
vnstat -i $IFNAME --json -tr
|
||||
;;
|
||||
speedallif)
|
||||
echo '{'
|
||||
for IFPATH in /var/lib/vnstat/*
|
||||
do
|
||||
IFNAME=$(basename -- "$IFPATH")
|
||||
echo '"'$IFNAME'": '
|
||||
vnstat -i $IFNAME --json -tr
|
||||
echo ','
|
||||
done
|
||||
echo '}'
|
||||
;;
|
||||
hours)
|
||||
read input;
|
||||
IFNAME=`echo $input | jsonfilter -e '@.ifname'`
|
||||
vnstat -i $IFNAME -h --json
|
||||
;;
|
||||
days)
|
||||
read input;
|
||||
IFNAME=`echo $input | jsonfilter -e '@.ifname'`
|
||||
vnstat -i $IFNAME -d --json
|
||||
;;
|
||||
months)
|
||||
read input;
|
||||
IFNAME=`echo $input | jsonfilter -e '@.ifname'`
|
||||
vnstat -i $IFNAME -m --json
|
||||
;;
|
||||
weeks)
|
||||
read input;
|
||||
IFNAME=`echo $input | jsonfilter -e '@.ifname'`
|
||||
vnstat -i $IFNAME -w --json
|
||||
;;
|
||||
top10)
|
||||
read input;
|
||||
IFNAME=`echo $input | jsonfilter -e '@.ifname'`
|
||||
vnstat -i $IFNAME -t --json
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue