VnStat errors



  • I have recently installed vnstat on my pfSense box, but I don't seem to be able to get it to work, as I always get the following error.

    Notice: Undefined index:  totalrx in /usr/local/www/vnstat/index.php on line 77

    Notice: Undefined index:  totalrxk in /usr/local/www/vnstat/index.php on line 77

    Notice: Undefined index:  totaltx in /usr/local/www/vnstat/index.php on line 78

    Notice: Undefined index:  totaltxk in /usr/local/www/vnstat/index.php on line 78

    I have tried waiting for over 30 minutes, which is longer than indicated in the following thread.

    http://forum.pfsense.org/index.php/topic,19712.0.html

    I know I have had traffic on all but one of the four NICs as one of them is now disabled.

    I just noticed that the site defaults to "Traffic data for Wireless_NIC (ath0)" which happens to be the network card that is deactivated.

    I have deleted "ath0" & ".ath0" in the "/var/db/vnstat" folder, as suggested in the following thread, but it still lists the network card & gives me the above error.

    http://forum.pfsense.org/index.php/topic,14179.0.html

    I then waited for over five minutes in the hopes that it would sort itself out, but it still lists all 4 cards & it still has the error I mentioned earlier.

    I also noticed that the files in the folder "/var/db/vnstat" are all owned by root:wheel. I don't know if that is an issue or not but I thought I'd mention it as I've seen other issues that were mentioned that were related to file ownership.

    Version 1.2.3-RELEASE
    built on Sun Dec 6 23:21:36 EST 2009
    Platform pfSense

    Installed packages
    Backup 0.1.7
    Cron 0.2
    Fit123 1.0
    Lightsquid 1.7.1
    bandwidthd 2.0.1.2
    phpSysInfo 2.5.4
    squid 2.7.8_1
    vnstat 1.6.3

    If you need more info just ask as I don't know why this is happening or if it is something that I did wrong.



  • The is some commands from console you can try like
    vnstat -u
    for update
    vnstat -tr -i "real_nic_name"
    for 5 sec live traffic



  • Coming at it after sleeping I went to view the source, then I noticed the hyperlinks. So I can see stats for the other NICs, but I still see the NIC that does not have the enable option checked.

    I assume that the "vnstat -u" isn't supposed to give any output, because I didn't see anything from that command.

    Here are the other commands I ran along with the result they gave me.

    $ vnstat -tr -i "em0"
    Sampling em0 (5 seconds average)...                                   13 packets sampled in 5 seconds
    Traffic average for em0
          rx           0.19 kB/s              1 packets/s
          tx           0.22 kB/s              1 packets/s
    
    $ vnstat -tr -i "em1"
    Sampling em1 (5 seconds average)...                                   5 packets sampled in 5 seconds
    Traffic average for em1
          rx           0.06 kB/s              0 packets/s
          tx           0.01 kB/s              0 packets/s
    
    $ vnstat -tr -i "vr0"
    Sampling vr0 (5 seconds average)...                                   6 packets sampled in 5 seconds
    Traffic average for vr0
          rx           0.05 kB/s              0 packets/s
          tx           0.02 kB/s              0 packets/s
    
    $ vnstat -tr -i "ath0"
    Sampling ath0 (5 seconds average)...                                    0 packets sampled in 5 seconds
    Traffic average for ath0
          rx           0.00 kB/s              0 packets/s
          tx           0.00 kB/s              0 packets/s
    
    

    I did some searching online & I found the idea of using "isset()" as a way to prevent the errors from showing up. I've included an example. I haven't tested it yet but that could get rid of the error for everyone, which I think would be nice.

    	if (!isset($summary['totalrx']) && !isset($summary['totalrxk']) && !isset($summary['totaltx']) && !isset($summary['totaltxk'])){
    		$trx = $summary['totalrx']*1024+$summary['totalrxk'];
    		$ttx = $summary['totaltx']*1024+$summary['totaltxk'];
    	}
    


  • Coming at it after sleeping I went to view the source, then I noticed the hyperlinks. So I can see stats for the other NICs, but I still see the NIC that does not have the enable option checked.

    If you do not plan to enable it then you can remove it from /usr/local/www/vnstat/config.php ,though it seems unusual to assign a nic and not enable it.



  • I wasn't the one to install the wireless NIC without an antenna & management doesn't seem to want to get some so that we can use that instead of the router we now use for our wireless connections. I guess in this case I could just un-assign it.

    I have to admit it but I am somewhat new at using pfSense.

    Edit 2010-05-14

    Well after un-assigning it & then uninstalling & re-installing vnStat the error went away. I still think you might want to look at the code I gave you as it could remove the error for anyone else when they first install vnStat on to their box.


Locked