inital upload

This commit is contained in:
Sven Holz
2022-06-13 23:35:46 +02:00
commit a17b5e9262
12 changed files with 677 additions and 0 deletions

164
README.md Normal file
View File

@@ -0,0 +1,164 @@
# Docker Based Latency Monitor
Docker container which tracks latency of one or many hosts and reports to InfluxDBv2.
## Description
This Docker Container is able to track the latency of one or many targets and reports all data to a given InfluxDBv2.
It´s based on python3 an makes usage of following python libraries:
- pythonping
- influxdb_client
- threading
- sys
- os
- datetime
- configparser
- time
Configuration can be passed via ENV **OR** configuration file.
In case of using the ENV option you are just able to monitor **ONE** target for more targets please use the configuration file.
Also some influx connection options are just configurable via config file but normally they are not needed.
## Getting Started
### Requirements
- Docker
- Docker-Compose
- InfluxDB Version >= 2
- pythonping needs root privileges so same for the container
### ENV Variables
Name | Example | Usage | Option/Must
:------: | :-----: | :-----: | :-----:
INFLUX_URL | http://10.0.0.1:8086 | InfluxDB Host | must
INFLUX_TOKEN | eWOcp-MCv2Y3IJPlER7wcCiuYkV8HdC8d7...ICKirhw0lwEczRNnrIoTqZAg== | InfluxDB API Token | must
INFLUX_BUCKET | latency | InfluxDB Bucket | must
INFLUX_ORG | MyOrg | InfluxDB Organization | must
TARGET_HOST | 8.8.8.8 | Monitored Host (IP/FQDN) | must
### Config File
**Instead** of using the ENV variables you can use a config file.
**Keep in mind it´s a OR decision not a AND**
See [template_config.ini](./Docker_Build/template_config.ini)
Rename the file to *config.ini* make your changes and add it as a volume mount to the container:
#### Docker-Compose Style
```
volumes:
- /YOUR_PATH/config.ini:/app/config.ini
```
#### Docker-CLI Style
```
docker latency-monitor -v /YOUR_PATH/config.ini:/app/config.ini
```
### Compose Files
#### FULL-STACK
1st thing to do is creating the *docker-compose.yml:
```
cp docker-compose-full_stack.yml docker-compose.yml
```
##### Certificate
*Traefik* will act as a proxy and ensures the usage of TLS so it needs your certificate and key file.
within the *docker-compose.yml* you will find:
```
- ./traefik/mycert.crt:/certs/cert.crt:ro
- ./traefik/mycert.key:/certs/privkey.key:ro
```
so please place your certificate file as *./traefik/mycert.crt* and the key file as *./traefik/mycert.key*.
Thats it
##### Variables
You need to configure Variables in following files to make the compose work:
- **file**
- VARIABLE1
- VARIABLE2
- VARIABLE3
-----
- **docker-compose.yml** *(was docker-compose-full_stack.yml before*
- PLACE_YOUR_FQDN_HERE (3 times)
-----
- **.env** *(env needs to be renamed to .env)*
- YOUR_PATH_TO_CONTAINER_STATIC_DATA
- YOUR_ADMIN_USER
- YOUR_ADMIN_PASSWORD
- YOUR_ORGANIZATION
- YOUR_BUCKET_NAME
- YOUR_ADMIN_TOKEN
-----
- **grafana/provisioning/datasources/grafana-datasource.yml**
- YOUR_ADMIN_TOKEN
- YOUR_ORGANIZATION
- YOUR_BUCKET_NAME
##### File Permissions
Because we are configuring *grafana* for permanent data storing and *grafana* actually runs with *UID* + *GID*: *472:472* it´s necessary to change permisson of die permanent storage directory we have configured.
The directory build from the following config part of grafana within the docker-compose.yml:
```
${MyPath}/grafana/var_lib
```
*MyPath* was configured earlier in the *.env* file.
so let´s assume the following:
MyPath = /opt/docker/containers/
then you have to do the following
```
chown -R 472:472 /opt/docker/containers/grafana/var_lib
```
## Authors
Contributors names and contact info
* [Sven Holz](mailto:code+latency-monitor@planet-espresso.com)
## Version History
* 0.1
* Initial Release
## License
free to use