joseph-mccarthy / internet-monitor

Small Python App that monitors internet connection and provides api for consumption

Home Page:https://joseph-mccarthy.github.io/projects/internet-monitor/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Internet Monitor

GitHub release (latest SemVer) GitHub Sonar Quality Gate wakatime

Table of Contents


Description

Created this small and simple application to keep my Internet Service Provider honest. It's written in Python made up of two components. The first component is the speed test which is run every 30 minutes, and uses the speedtest.net cli and stores the result in local sqlite database. The second component is a simple API that allows a client of choice to pull the data for the latest result, average of the last 24 hours and finally one for graphing.

Technologies

Back To The Top


How To Use

There are two options to use this software. Can run with just python by checking out the repository or use the docker image.

Python

To use this method you'll require at least Python 3.7 install on your machine

git clone git@github.com:joseph-mccarthy/internet-monitor.git
curl -s https://install.speedtest.net/app/cli/install.deb.sh | bash
apt-get install speedtest
cd internet-monitor
pip3 install -r requirements.txt
./local-start.sh

Docker

There is also a provided Docker image that runs both the speed test and the api with an exposed port of 5000

docker pull joemccarthy/internet-monitor:latest
docker run -d -p 5000:5000 joemccarthy/internet-monitor:latest

API Reference

The API exposes three endpoints for the data saved in the database

/latest

{
    "download": 3296755.0,
    "upload": 2175216.0,
    "ping": 62.496,
    "time": 1645789388.759391
}

/last-day

{
    "download": {
        "high": 3852744.0,
        "average": 3629769.4166666665,
        "low": 3296755.0
    },
    "upload": {
        "high": 2331189.0,
        "average": 1883408.0416666667,
        "low": 1215527.0
    },
    "ping": {
        "high": 62.496,
        "average": 16.989,
        "low": 12.594
    }
}

/graph

[
    {
        "id": 1,
        "download": 3364494.0,
        "upload": 1085589.0,
        "ping": 15.426,
        "time": 1645710501.983828
    },
    {
        "id": 2,
        "download": 3330109.0,
        "upload": 822428.0,
        "ping": 17.148,
        "time": 1645712303.276396
    },
    {
        "id": 3,
        "download": 3316571.0,
        "upload": 1076903.0,
        "ping": 15.835,
        "time": 1645714140.544144
    },
    {
        "id": 4,
        "download": 3261149.0,
        "upload": 1134400.0,
        "ping": 15.76,
        "time": 1645715986.757451
    }
]

Back To The Top


References

Back To The Top


License

Copyright (c) 2022 Joseph McCarthy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back To The Top


Author Info

Back To The Top

About

Small Python App that monitors internet connection and provides api for consumption

https://joseph-mccarthy.github.io/projects/internet-monitor/

License:MIT License


Languages

Language:Python 86.5%Language:Dockerfile 9.0%Language:Shell 4.5%