What's new

FlexQoS real time stats added to a file for node_exporter

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

waeking

Regular Contributor
First of all thank so much for flexqos! I have been using this on a RT-AC68U for a few years now. Currently on flexqos 1.41

I found a github repo and currently going through the files, but am having trouble finding where flexqos.asp get its data for the current rates?

The ultimate goal I am trying to acheive is to create a temp (bash) file that will have both the class (ie: Net_flow,Work_flow,...) and rates in bytes.

When I am done I could paste the final file here. That is if anyone is interested?
 
Thanks for being so quick! I am now looking into grep to get just the number I need now..... getting close with

tc -s class show dev eth0 | grep -C 1 117 | grep Sent | grep -Eo '[0-9]+'

Not pretty, and still need to isolate the first line. Any suggestions are welcome
 
Any suggestions are welcome
You limit the output like so:
Code:
tc -s class show dev eth0 parent 1: | grep -A2 "parent 1:1"
What output format are you trying to get for node_exporter? There are a few sed/awk gurus around here who can help.
 
dave14305 Thanks for all your information. I just saw your last post now.

This is my first attempt I have this now working in Grafana and it seems to be working well. I tried to create an array instead of a case statement but busybox sh doesn't work well with them. Feel free to clean up the code. I am not familiar with grep awk and sed. Also I may have some of the priorities wrong. Please feel free to correct.

Bash:
#!/bin/sh

# Note the start time of the script.
START="$(date +%s)"

# Adjust as needed.
TEXTFILE_COLLECTOR_DIR="/tmp/node_exporter"

#set -- "Net" "Gaming" "Streaming" "Work" "Web" "Downloads" "Others" "Learn"

for dev in br0 eth0; do
i=0

while [ $i -le 7 ]; do
#bytes=`tc -s class show dev $dev | grep -A1 "prio $i" | grep Sent | awk '{ print $2 }' | head -n1`
bytes=`tc -s class show dev $dev parent 1: | grep -A2 "parent 1:1" | grep -A1 "prio $i" | grep Sent | awk '{print $2}'`

#  pos=$i
#  shift "$(( pos ))"
#  type=`printf '%s\n' "$2"`

case $i in
7) type=Learn ;;
6) type=Others ;;
5) type=Streaming ;;
4) type=Web ;;
3) type=Work ;;
2) type=Download ;;
1) type=Gaming ;;
0) type=Net
esac

if [ $dev = eth0 ]; then
echo router_flexqos_recieve_total{type='"'$type'"'} $bytes >> "$TEXTFILE_COLLECTOR_DIR/flexqos.prom.$$"
else
echo router_flexqos_transmit_total{type='"'$type'"'} $bytes >> "$TEXTFILE_COLLECTOR_DIR/flexqos.prom.$$"
fi

true $(( i++ ))

done
done

END="$(date +%s)"
echo router_flexqos_duration_seconds $(($END - $START)) >> "$TEXTFILE_COLLECTOR_DIR/flexqos.prom.$$"
echo router_flexqos_last_run_seconds $END >> "$TEXTFILE_COLLECTOR_DIR/flexqos.prom.$$"

## Rename the temporary file automically.
## This avoids the node exporter seeing half a file.
mv "$TEXTFILE_COLLECTOR_DIR/flexqos.prom.$$" \
"$TEXTFILE_COLLECTOR_DIR/flexqos.prom"
 
Last edited:

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top