Implemented cron, daemon and foreground mode; Added interval to args; README update.

This commit is contained in:
Johannes Findeisen 2021-12-27 01:13:00 +01:00
commit 27f8550ff5
2 changed files with 69 additions and 23 deletions

View file

@ -10,10 +10,10 @@ For now, I can say that uplink can monitor the status of you FRITZ!Box uplinks.
## Requirements
- A Linux based operating system (I don't test any other OS's but Raspian is fine and a good target)
- A Linux based operating system (I don't test any other OS's but Raspbian is fine and a good target)
- Git (only for installing from Git repository)
- Python3 (running for me using 3.7.3, 3.8.5 and 3.9.7 on Linux)
- fritzconnection = 1.5.0
- Python3 (running for me using 3.7.3, 3.8.5, 3.9.7 and 3.10.1 on Linux)
- fritzconnection >= 1.5.0 (included as submodule in the Git repository)
- pymysql >= 0.10.1
- sqlalchemy = 1.4.27 (not for now)
- urwid = 2.1.2 (not for now)
@ -23,6 +23,8 @@ Just install the 3rd party dependencies using `pip install $PACKAGE` or your OS
git clone https://git.unixpeople.org/hanez/uplink.git
cd uplink
# To get a local copy of fritzconnection you need to get the submodules:
git submodule update --init --recursive
cp config.example.json config.json
### Configuration
@ -32,7 +34,6 @@ Edit config.json to your needs.
#### Variables
- interval: The polling interval
- database: Path to sqlite3 Database
- uplinks: List of devices you want to poll
- provider: Custom name of the uplink provider
- ip: The IP of the router device
@ -42,13 +43,13 @@ Edit config.json to your needs.
{
"interval": 60,
"database_type": "mysql",
"database_type": "mysql", (NOT USED)
"database": "uplink",
"database_host": "127.0.0.1",
"database_user": "USER",
"database_password": "PASSWORD",
"cron": false,
"daemon": false,
"cron": false, (NOT USED)
"daemon": false, (NOT USED)
"uplinks": [
{ "provider": "Cable Provider", "ip": "192.168.0.1", "password": "1234" },
{ "provider": "DSL Provider", "ip": "192.168.1.1", "password": "1234" }
@ -57,16 +58,34 @@ Edit config.json to your needs.
### Create Database
sqlite3 uplink.sqlite3 < uplink.sql
TODO
## Usage
./uplink ./config.json
./uplink [-c | -d | -f] ./config.json
### Help
./uplink --help
```
usage: uplink [-h] [-c | -d | -f] [-i INTERVAL] [--version] CONFIGFILE
uplink is a tool to monitor the link status of AVM FRITZ!Box Cable and DSL based routers.
positional arguments:
CONFIGFILE the configfile to use
options:
-h, --help show this help message and exit
-c, --cron cron mode executes the script only once without loop (default: false)
-d, --daemon run as native daemon (default: false)
-f, --foreground run looped in foreground (default: false)
-i INTERVAL, --interval INTERVAL
poll interval in seconds. this overrides config file settings. (default: 60)
--version show program's version number and exit
```
## View collected data
I actually use "[DBeaver](https://dbeaver.io/)" for taking a look at the data uplink is collecting.