Giter Site home page Giter Site logo

vps-traffic-bot's Introduction

vps-traffic-bot

screenshot

simple telegram-bot based on vnStat utility that shows how much traffic you spent this month

Installation

1. Install requirements

  • Install ruby with bundler
    # mpapis public key used to verify installation package to ensure security.
    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
    # RVM stable with ruby and bundler (may take a while)
    sudo \curl -sSL https://get.rvm.io | bash -s stable --gems=bundler
    
  • Install vnstat
    sudo apt-get install vnstat
    

2. Setup an application

  • add a new user, clone repo to it's ~, install dependencies locally
    sudo adduser trafficbot_app
    su trafficbot_app
    cd ~ 
    git clone https://github.com/frostbolt/vps-traffic-bot
    cd vps-traffic-bot
    bundle install --path vendor/bundle
    
  • create bot with @botfather, place your token to config.yml
  • check if everything is OK
    bundle exec ruby app.rb
    
  • make sure to exit so you return to your usual user

3. Create a systemctl service

run nano /usr/lib/systemd/system/vpstrafficbot.service, insert the following fragment

[Unit]
Description=telegram bot for checking network adapter TX packages
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
User=trafficbot_app
Group=trafficbot_app

WorkingDirectory=/home/trafficbot_app/vps-traffic-bot
PIDFile=/home/trafficbot_app/vps-traffic-bot/vps-traffic-bot.pid

ExecStart=/bin/bash -lc 'bundle exec ruby app.rb'
ExecStop=/bin/kill -s TERM $MAINPID ; /bin/sleep 1
TimeoutSec=30
RestartSec=15s
Restart=always

[Install]
WantedBy=multi-user.target

4. Enjoy!

run systemctl start vpstrafficbot and that's it.

Thanks

vps-traffic-bot's People

Contributors

frostbolt avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

aka-z

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.