A python script and steps to display locations of peers connected to qbittorrent

Overview

alt text

A python script (along with instructions) to display the locations of all the peers your qBittorrent client is connected to in a Grafana worldmap dashboard.

Disclaimer : The steps I took to get this working might not be the most efficient. But this is all I could create with what I know at the moment. Feel free to (actually this is a request) to make changes and improve this. Thanks!

Pre-requisites

  • python

    • pygeohash module (to convert latitude and longitude to geohash)
    • mariadb module (a quick google search for 'python mariadb' should tell you all you need to know about using this module)
  • MariaDB (this should work with other similar databases but I haven't tried any of them yet)

  • qBittorrent

  • Grafana

Steps

  • First step is to create the database which will contain the information about the IP addresses and their corresponding locations. I used this "https://lite.ip2location.com/database/db5-ip-country-region-city-latitude-longitude" since it is free and it had the latitude and longitude information which is enough precision to pipoint a peer on the map. Download the IPV4 CSV file from this link and follow the instructions given below in the same page to create a database and import the location data to a table.

alt text

alt text

  • Next, create a new table which I'll call peer_list to store the IP addresses along with their geohashes of all the peers which are connected at a given point in time. To create this table, which is in the same database as the ip2location table, I used:

CREATE TABLE peer_list (time int(11), ip_address varchar(15), geohash varchar(20));

Remember to grant the neccessary permissions on both the tables to your MariaDB user.

  • Now download the python script in this repository and fill in your credentials.
    • qBittorrent web API credentials
    • MariaDB credentials

Once you're done with this step, run the script once. If all goes well, you should be able to see the peer_list table populated with IP addresses and geohashes.

If you haven't already done so, install the Grafana world map plugin. You can find it here "https://grafana.com/grafana/plugins/grafana-worldmap-panel/".

alt text

alt text

alt text

  • Once that's done, create a new panel in Grafana and change visualization option to worldmap panel. Change the database source to your MariaDB database. Choose the table name as peer_list, and the metric column as geohash. In the next row, change the Column:value to Column:geohash by right clicking it and typing in geohash. Then, at the end of the query options, change the format as option to table. Then we'll change the worldmap panel options in the right side. Change the values for min and max circle size to 1 since we're displaying each peer as a single dot and not as a bigger circle. Change location data to geohash. Finally, under field mapping, enter geohash in the geo_point/geohash field box.

And, if everything went correctly (or exactly like I did lol), you should start seeing a few dots appear on the map. You can change the color of the dots by changing the color for the thresholds in previous step.

  • Now, all that's left is to add a cron entry to execute the script at regular intervals and we're done. :)
You might also like...
Python script for writing text on github contribution chart.
Python script for writing text on github contribution chart.

Github Contribution Drawer Python script for writing text on github contribution chart. Requirements Python 3.X Getting Started Create repository Put

A simple script that displays pixel-based animation on GitHub Activity
A simple script that displays pixel-based animation on GitHub Activity

GitHub Activity Animator This project contains a simple Javascript snippet that produces an animation on your GitHub activity tracker. The project als

script to generate HeN ipfs app exports  of GLSL shaders
script to generate HeN ipfs app exports of GLSL shaders

HeNerator A simple script to generate HeN ipfs app exports from any frag shader created with: GlslViewer GlslEditor The Book of Shaders glslCanvas VS

Script to create an animated data visualisation for categorical timeseries data - GIF choropleth map with annotations.
Script to create an animated data visualisation for categorical timeseries data - GIF choropleth map with annotations.

choropleth_ldn Simple script to create a chloropleth map of London with categorical timeseries data. The script in main.py creates a gif of the most f

A small script written in Python3 that generates a visual representation of the Mandelbrot set.
A small script written in Python3 that generates a visual representation of the Mandelbrot set.

Mandelbrot Set Generator A small script written in Python3 that generates a visual representation of the Mandelbrot set. Abstract The colors in the ou

This is a super simple visualization toolbox (script) for transformer attention visualization ✌
This is a super simple visualization toolbox (script) for transformer attention visualization ✌

Trans_attention_vis This is a super simple visualization toolbox (script) for transformer attention visualization ✌ 1. How to prepare your attention m

Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.
Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.

PyDexter Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax. Setup $ pip install PyDexter

A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe which runs both payloads.
A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe which runs both payloads.

Update ! ANONFILE MIGHT NOT WORK ! About A Python Binder that merge 2 files with any extension by creating a new python file and compiling it to exe w

Debugging, monitoring and visualization for Python Machine Learning and Data Science
Debugging, monitoring and visualization for Python Machine Learning and Data Science

Welcome to TensorWatch TensorWatch is a debugging and visualization tool designed for data science, deep learning and reinforcement learning from Micr

Owner
null
Farhad Davaripour, Ph.D. 1 Jan 5, 2022
Graphical display tools, to help students debug their class implementations in the Carcassonne family of projects

carcassonne_tools Graphical display tools, to help students debug their class implementations in the Carcassonne family of projects NOTE NOTE NOTE The

null 1 Nov 8, 2021
a simple REPL display lib for circuitpython

Circuitpython-termio-lib a simple REPL display lib for circuitpython Fonctions cls clear terminal screen and set cursor on top left : coords 0,0 usage

BeBoXoS 1 Nov 17, 2021
This component provides a wrapper to display SHAP plots in Streamlit.

streamlit-shap This component provides a wrapper to display SHAP plots in Streamlit.

Snehan Kekre 30 Dec 10, 2022
A simple python script using Numpy and Matplotlib library to plot a Mohr's Circle when given a two-dimensional state of stress.

Mohr's Circle Calculator This is a really small personal project done for Department of Civil Engineering, Delhi Technological University (formerly, D

Agyeya Mishra 0 Jul 17, 2021
Python script to generate a visualization of various sorting algorithms, image or video.

sorting_algo_visualizer Python script to generate a visualization of various sorting algorithms, image or video.

null 146 Nov 12, 2022
Minimal Ethereum fee data viewer for the terminal, contained in a single python script.

Minimal Ethereum fee data viewer for the terminal, contained in a single python script. Connects to your node and displays some metrics in real-time.

null 48 Dec 5, 2022
A script written in Python that generate output custom color (HEX or RGB input to x1b hexadecimal)

ColorShell ─ 1.5 Planned for v2: setup.sh for setup alias This script converts HEX and RGB code to x1b x1b is code for colorize outputs, works on ou

Riley 4 Oct 31, 2021
A python script editor for napari based on PyQode.

napari-script-editor A python script editor for napari based on PyQode. This napari plugin was generated with Cookiecutter using with @napari's cookie

Robert Haase 9 Sep 20, 2022
A python script to visualise explain plans as a graph using graphviz

README Needs to be improved Prerequisites Need to have graphiz installed on the machine. Refer to https://graphviz.readthedocs.io/en/stable/manual.htm

Edward Mallia 1 Sep 28, 2021