Giter VIP home page Giter VIP logo

rasplex-vnstat's Introduction

rasplex-vnstat

A dirty hack to run vnStat on RasPlex.

Installation

mkdir /storage/local
cd /storage/local
wget https://github.com/itspriddle/rasplex-vnstat/releases/download/v1.18/rasplex-vnstat.tar.gz
tar -vzxf rasplex-vnstat.tar.gz
rm rasplex-vnstat.tar.gz

Setup PATH so you can access vnstat and vnstatd without full paths:

echo 'export PATH="/storage/local/bin:/storage/local/sbin:$PATH"' >> /storage/.profile

Setup vnStat configuration file so vnstat and vnstatd work without having to pass a --config option on every invocation:

ln -s /storage/local/etc/vnstat.conf /storage/.vnstatrc

Setup a cron to start vnstatd. This will preserve any existing crontab:

( crontab -l 2> /dev/null | grep -v vnstatd; echo '*/5 * * * * /usr/bin/pgrep vnstatd >/dev/null || /storage/local/sbin/vnstatd -d > /dev/null' ) | crontab -

Configuration

The default vnstat.conf is configured to use eth0 as the default interface when vnstat is called without the --iface option. If you are using WiFi instead, you can run this command to change the configuration:

sed -i 's|^Interface "eth0"$|Interface "wlan0"|' /storage/local/etc/vnstat.conf

Usage

After first installing, you'll need to wait a few minutes for vnstatd to start and collect usage. You can manually start it with:

vnstatd -d

To see a traffic report, run vnstat. See vnstat --help for vnStat usage.

Building

This section outlines how to compile vnStat for use on RasPlex. RasPlex doesn't include the necessary tools to compile vnStat, so this must be done on a separate Raspberry Pi running Raspbian. I used a Raspberry Pi 2 to compile and RasPlex is on a Raspberry Pi 3.

Run these commands from the Raspbian based Pi to download and compile vnStat, and package it for upload to this repo:

sudo -i
mkdir -p /storage/local/{src,bin,sbin,etc,run,var/{lib,log}/vnstat}
cd /storage/local/src
wget https://github.com/vergoh/vnstat/releases/download/v1.18/vnstat-1.18.tar.gz
tar -vzxf vnstat-1.18.tar.gz
cd vnstat-1.18
./configure --prefix=/storage/local --sysconfdir=/storage/local/etc
make
cp vnstat /storage/local/bin
cp vnstatd /storage/local/sbin
sed 's|^DatabaseDir.*$|DatabaseDir "/storage/local/var/lib/vnstat"|;s|^LogFile.*$|LogFile "/storage/local/var/log/vnstat/vnstat.log"|;s|^PidFile.*$|PidFile "/storage/local/run/vnstat/vnstat.pid"|' cfg/vnstat.conf > /storage/local/etc/vnstat.conf
cd /storage/local
tar -vzcf rasplex-vnstat.tar.gz {bin,sbin,etc,run/vnstat,var/{log,lib}/vnstat}

rasplex-vnstat's People

Contributors

itspriddle avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.