[Plugin] Network Stats


dorgan

Recommended Posts

  • 2 months later...
  • 5 months later...
On 7/30/2020 at 5:56 AM, fmp4m said:

I have began having an odd problem where my Network Stats are not working.  They say

"vnstat service must berunning STARTED to view network stats."

 

So I checked:

/etc/rc.d/rc.vnstat start

 

received: 

Error: Not enough free diskspace available in "/var/lib/vnstat/", exiting.

 

My array/cache/ has plenty of space far beyond any need this would have so I checked:

ls -l /var/lib/vnstat
total 4
-rw-r--r-- 1 root root 0 Jul 29 16:49 vnstat.db
 

Any ideas?

 

I occured the same problem, and solved by changing the default DatabaseDir '/var/lib/vnstat' to '/mnt/user/vnstat' in /etc/vnstat.conf. 

The new DatabaseDir ‘/mnt/user/vnstat’ was created in UNRAID WEBGUI shares tab.

 

Though I still don't understand why default DatabaseDir failed. Hope someone could enlight me.

 

Link to comment
  • 3 weeks later...
  • 1 month later...
On 4/15/2020 at 6:54 PM, dorgan said:

I have added the ability to add pretty much any interface to be tracked.  I have also added the ability to add an alias to an interface that is used on the graphs.  I have found some information on how identify which veth interface maps to a given docker container, but it does not seem consistent, if someone knows an easy way, then maybe I can add this to the interface.

Settings-Page_2020-04-15.thumb.png.8d9f83c89b994a7f4fecf3a08c51ef25.png

 

Stats-Page_2020-04-15.thumb.png.dae2dd2ec31dfa1a0fd9ef62775139a7.png

 

Hello,

 

I manage to autofill Alias with a script

 

for container in $(docker ps --format '{{.ID}}'); do
  veth=""
  networkmode=$(docker inspect -f "{{.HostConfig.NetworkMode}}" $container)
  name=$(docker ps --filter "id=$container" --format "{{.Names}}")
  if [ "$networkmode" == "host" ]; then
    veth="host"
  elif [ "$networkmode" == "br0" ]; then
    veth="br0"
  else
    pid=$(docker inspect --format '{{.State.Pid}}' "$container")
    ifindex=$(nsenter -t $pid -n ip link | sed -n -e 's/.*eth0@if\([0-9]*\):.*/\1/p')
    if [ -z "$ifindex" ]; then
      veth="not found"
    else
      veth=$(ip -o link | grep ^$ifindex | sed -n -e 's/.*\(veth[[:alnum:]]*\).*/\1/p')
    fi
  fi
  if [[ "$veth" = "veth"* ]]; then
    echo $container : $name : $veth
    sed -i "/$name/d" /boot/config/plugins/networkstats/networkstats.cfg
    sed -i "/alias-$veth/d" /boot/config/plugins/networkstats/networkstats.cfg
    echo "alias-"$veth"="\"$name\" >> /boot/config/plugins/networkstats/networkstats.cfg
  fi
done

 

Edited by Meldrak
script mod
Link to comment
  • 3 weeks later...
On 5/21/2021 at 9:07 AM, Meldrak said:

 

Hello,

 

I manage to autofill Alias with a script

 


for container in $(docker ps --format '{{.ID}}'); do
  veth=""
  networkmode=$(docker inspect -f "{{.HostConfig.NetworkMode}}" $container)
  name=$(docker ps --filter "id=$container" --format "{{.Names}}")
  if [ "$networkmode" == "host" ]; then
    veth="host"
  elif [ "$networkmode" == "br0" ]; then
    veth="br0"
  else
    pid=$(docker inspect --format '{{.State.Pid}}' "$container")
    ifindex=$(nsenter -t $pid -n ip link | sed -n -e 's/.*eth0@if\([0-9]*\):.*/\1/p')
    if [ -z "$ifindex" ]; then
      veth="not found"
    else
      veth=$(ip -o link | grep ^$ifindex | sed -n -e 's/.*\(veth[[:alnum:]]*\).*/\1/p')
    fi
  fi
  if [[ "$veth" = "veth"* ]]; then
    sed -i "/$veth/c\alias-$veth='$name'" /boot/config/plugins/networkstats/networkstats.cfg
  fi
done

 

This is nice, maybe I will rework some of this into identifying applications, and then you can just select which applications to track.  Do you know if the network device change upon reboot??

Link to comment
On 6/7/2021 at 11:40 PM, dorgan said:

This is nice, maybe I will rework some of this into identifying applications, and then you can just select which applications to track.  Do you know if the network device change upon reboot??

 

Yes the network device name change on reboot or docker update

My script just fill the docker name to the veth device in the config file

It doesn't auto select the device you want to track, you need to select it in your plugin and hit save

 

I updated the script in previous post to delete the old entry if there's one

Link to comment
  • 3 weeks later...
  • 2 weeks later...
On 7/2/2020 at 6:14 PM, DjBill said:

Hi, thanks for the plugin. This post https://forums.docker.com/t/relationship-between-interface-vethxxxxx-and-container/12872/25 explains how to correlate "vethxxxxx" interfaces and "docker".
This post also have some script that might  help you on the development.

 

 

Following the link above has a comment and link to the following Github -- https://github.com/cslev/find_veth_docker

 

As I'm very new to Unraid and Linux, can someone please help me understand where I would enter this information in? I tried in the terminal for Unraid and also the console of one of the dockers I'm trying to figure out the Veth..

 

In both locations I've tried entering.. 

sudo ./find_veth_docker.sh -n nextcloud

Link to comment
On 7/15/2021 at 9:58 AM, ThatTallGuy21 said:

 

Following the link above has a comment and link to the following Github -- https://github.com/cslev/find_veth_docker

 

As I'm very new to Unraid and Linux, can someone please help me understand where I would enter this information in? I tried in the terminal for Unraid and also the console of one of the dockers I'm trying to figure out the Veth..

 

In both locations I've tried entering.. 

sudo ./find_veth_docker.sh -n nextcloud

So after additional research I found that Veth##### changes each time a container restarts, so unless this is able to be persisted, then I'm not going to worry about this too much. Would like to know how to quickly find it, using the above, but not completely needed. 

Link to comment
  • 4 weeks later...

I did some little changes to my script, and now data persist on containers restarts and on interfaces name changes

Before running my script as a CRON job (every day is a good choice), you'll need to setup the plugin once with interfaces you'd like to show

To persist on array reboot, you'll also need to run script after docker finish starting all containers

 

https://github.com/Meldrak/user-scripts/blob/main/networkstats

 

On 6/7/2021 at 11:40 PM, dorgan said:

This is nice, maybe I will rework some of this into identifying applications, and then you can just select which applications to track.  Do you know if the network device change upon reboot??

 

  • Like 1
Link to comment
  • 3 weeks later...

Hello,

 

the page Stats -> Network Stats only shows two empty/non-existing images (placeholder).

I already re-installed the plugin but it did not help.

Recently i changed my mainboard from multi LAN to single LAN.

Re-configuration and even a manual edit of the interface in /etc/vnstat.conf did not help. Debug of vnstat says, logging is of traffic is fine.

Unraid Version is 6.10-rc1.

 

Thanks for help!

Link to comment
21 minutes ago, Twix said:

Hello,

 

the page Stats -> Network Stats only shows two empty/non-existing images (placeholder).

I already re-installed the plugin but it did not help.

Recently i changed my mainboard from multi LAN to single LAN.

Re-configuration and even a manual edit of the interface in /etc/vnstat.conf did not help. Debug of vnstat says, logging is of traffic is fine.

Unraid Version is 6.10-rc1.

 

Thanks for help!

It takes a while for the graphs to start showing up the first time.

Link to comment
  • 2 weeks later...
  • 2 weeks later...
  • 4 weeks later...

I'm also seeing the same issue with the stats images not loading.

Trying "vnstati" on the commandline returns:

vnstati: error while loading shared libraries: libgd.so.3: cannot open shared object file: No such file or directory

 

So i assume this is why the images no longer load but a quick google about that error code and I couldn't find a fix unfortunately.

Link to comment
14 minutes ago, Migz93 said:

I'm also seeing the same issue with the stats images not loading.

Trying "vnstati" on the commandline returns:

vnstati: error while loading shared libraries: libgd.so.3: cannot open shared object file: No such file or directory

 

So i assume this is why the images no longer load but a quick google about that error code and I couldn't find a fix unfortunately.

What version of unraid are you running??  I just did a clean install of the plugin and everything is working on 6.9.2

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.