Vnstat Color

General questions.
Post Reply
gh4wi
Posts: 10
Joined: March 29th, 2018, 3:20 pm

Vnstat Color

Post by gh4wi » May 17th, 2019, 12:40 pm

Vnstat can display a nice chart of the network activity on each interface. Sadly it does not use color.
If you are running IPFire on a PC with a standard color adapter and monitor, then you can use the below bash script to add some color.
The script (vnstatd.sh) will display the Vnstat chart for the Red and Green interfaces in color.
Your display should be able to display 64 lines. If not, just edit the script and split it in half.

#!/bin/bash
#
# vnstatd.sh
#

CNT=0

while [ $CNT -ge 0 ]
do
clear
echo -e "\e[1m"
echo -e "\e[39m"
echo "vnstatd.sh"
echo "=========="

date
echo -e "\e[91m"
/usr/bin/vnstat -i red0 -h

echo -e "\e[39m"
date
echo -e "\e[92m"
/usr/bin/vnstat -i green0 -h

echo -e "\e[39m"
echo "Chart data updates using 5-minute intervals."
CNT=$(( $CNT + 1 ))
echo "Display refreshes once per minute, refresh count=" $CNT
echo "Refresh count initializes after 24-hours."
echo "[Ctrl+c] to exit."
echo -e "\e[0m"
if [ $CNT -ge 1440 ]; then CNT=0; fi
sleep 1'm'
done

Post Reply