Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b41527a2e6 | ||
|
|
8b173ff9ee | ||
|
|
8407bf1250 | ||
|
|
b51db3e64d | ||
|
|
cb6b8e1aae | ||
|
|
1772f7d929 | ||
|
|
1850598038 | ||
|
|
c6e1cc3448 | ||
|
|
06cfd448da | ||
|
|
21e5627d58 | ||
|
|
7ed91947ab | ||
|
|
5c07ade336 | ||
|
|
6980539a02 | ||
|
|
99d934d041 | ||
|
|
4c5e9ceb90 | ||
|
|
5f5aea0332 | ||
|
|
b400e34c9a | ||
|
|
dd52e9ef41 | ||
|
|
682c943b2e | ||
|
|
c3d367c4d9 |
65
.github/workflows/git2docker.yml
vendored
Normal file
65
.github/workflows/git2docker.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# This is a basic workflow to help you get started with Actions
|
||||||
|
|
||||||
|
name: CI to Docker Hub
|
||||||
|
|
||||||
|
# Controls when the workflow will run
|
||||||
|
##on:
|
||||||
|
# Triggers the workflow on push or pull request events but only for the "master" branch
|
||||||
|
## push:
|
||||||
|
## branches: [ "master" ]
|
||||||
|
|
||||||
|
|
||||||
|
# Only update with new tag pushed
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*.*"
|
||||||
|
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
|
jobs:
|
||||||
|
# This workflow contains a single job called "build"
|
||||||
|
build:
|
||||||
|
# The type of runner that the job will run on
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
|
||||||
|
- name: Cache Docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
- name: Check Out Repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./Docker_Build/
|
||||||
|
file: ./Docker_Build/Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/pylatemon:latest
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode
|
.vscode
|
||||||
.env
|
.env
|
||||||
|
*.backup
|
||||||
|
grafana-datasource.yml
|
||||||
|
docker-compose.yml
|
||||||
|
config.ini
|
||||||
@@ -23,6 +23,11 @@
|
|||||||
# host2 = 8.8.4.4
|
# host2 = 8.8.4.4
|
||||||
# host3 = 1.1.1.1
|
# host3 = 1.1.1.1
|
||||||
|
|
||||||
|
[hosts_timeout] # OPTIONAL; ping timeout in seconds (float); default is '1'
|
||||||
|
# host1 = 1
|
||||||
|
# host2 = 0.5
|
||||||
|
# host3 = 0.2
|
||||||
|
|
||||||
[hosts_timer] # OPTIONAL; ping interval in seconds; default is '5'
|
[hosts_timer] # OPTIONAL; ping interval in seconds; default is '5'
|
||||||
# host1 = 1
|
# host1 = 1
|
||||||
# host2 = 3
|
# host2 = 3
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class MyInfluxDB():
|
|||||||
writes received data to Influxdb:
|
writes received data to Influxdb:
|
||||||
host: string which includes IP or FQDN
|
host: string which includes IP or FQDN
|
||||||
host_location: string which includes location of the host
|
host_location: string which includes location of the host
|
||||||
ping_response: string which includes the ping reply in ms
|
ping_response: float which includes the ping reply in ms
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -82,7 +82,7 @@ class MyInfluxDB():
|
|||||||
def write(self, host, host_location, ping_response):
|
def write(self, host, host_location, ping_response):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.host_location = host_location
|
self.host_location = host_location
|
||||||
self.ping_response = int(ping_response)
|
self.ping_response = float(ping_response)
|
||||||
self.influx_timestamp = int(time_ns())
|
self.influx_timestamp = int(time_ns())
|
||||||
self.data_point = Point("latency_monitor").tag("location", self.host_location).tag("host", self.host).field("latency", self.ping_response).time(self.influx_timestamp)
|
self.data_point = Point("latency_monitor").tag("location", self.host_location).tag("host", self.host).field("latency", self.ping_response).time(self.influx_timestamp)
|
||||||
self.write_api.write(bucket=self.INFX_BUCKET,
|
self.write_api.write(bucket=self.INFX_BUCKET,
|
||||||
@@ -100,21 +100,24 @@ class ThreadPing(Thread):
|
|||||||
----------
|
----------
|
||||||
db: InfluxDB Object
|
db: InfluxDB Object
|
||||||
host: string which includes IP or FQDN
|
host: string which includes IP or FQDN
|
||||||
|
host_timeout: float which defines how long we wait for a reply
|
||||||
host_timer: integer which defines how often pings are send in seconds (min. 1)
|
host_timer: integer which defines how often pings are send in seconds (min. 1)
|
||||||
host_location: string which includes location of the host
|
host_location: string which includes location of the host
|
||||||
"""
|
"""
|
||||||
def __init__(self, db, host, host_timer, host_location):
|
|
||||||
|
def __init__(self, db, host, host_timeout, host_timer, host_location):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
self.MyDB = db
|
self.MyDB = db
|
||||||
self.host = host
|
self.host = host
|
||||||
|
self.host_timeout = host_timeout
|
||||||
self.host_timer = host_timer
|
self.host_timer = host_timer
|
||||||
self.host_location = host_location
|
self.host_location = host_location
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.starttime = time()
|
self.starttime = time()
|
||||||
while True:
|
while True:
|
||||||
self.ping_response_list = ping(self.host, count=1)
|
self.ping_response_list = ping(self.host, timeout=self.host_timeout, count=1)
|
||||||
self.ping_response = self.ping_response_list.rtt_avg_ms
|
self.ping_response = "{:.2f}".format(self.ping_response_list.rtt_avg_ms)
|
||||||
self.MyDB.write(self.host, self.host_location, self.ping_response)
|
self.MyDB.write(self.host, self.host_location, self.ping_response)
|
||||||
sleep(self.host_timer - ((time() - self.starttime) % 1))
|
sleep(self.host_timer - ((time() - self.starttime) % 1))
|
||||||
|
|
||||||
@@ -129,12 +132,14 @@ def main():
|
|||||||
## IF ENVIRONMENT VARIABLES ARE PASSED IGNORE CONFIG FILE
|
## IF ENVIRONMENT VARIABLES ARE PASSED IGNORE CONFIG FILE
|
||||||
if 'TARGET_HOST' in os.environ:
|
if 'TARGET_HOST' in os.environ:
|
||||||
host = os.environ['TARGET_HOST']
|
host = os.environ['TARGET_HOST']
|
||||||
|
host_timeout = float(os.getenv('TARGET_TIMEOUT', 1))
|
||||||
host_timer = int(os.getenv('TARGET_TIMER', 5))
|
host_timer = int(os.getenv('TARGET_TIMER', 5))
|
||||||
host_location = os.getenv('TARGET_LOCATION', 'unknown')
|
host_location = os.getenv('TARGET_LOCATION', 'unknown')
|
||||||
|
|
||||||
# Create Thread
|
# Create Thread
|
||||||
print("Creating thread for: %s, with interval: %s and location: %s" %(host, host_timer, host_location))
|
print("Creating thread for: %s, with timeout: %s, with interval: %s and location: %s" % (
|
||||||
thread = ThreadPing(MyDB, host, host_timer, host_location)
|
host, host_timeout, host_timer, host_location))
|
||||||
|
thread = ThreadPing(MyDB, host, host_timeout, host_timer, host_location)
|
||||||
my_threads.append(thread)
|
my_threads.append(thread)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
@@ -149,6 +154,9 @@ def main():
|
|||||||
# Create thread for each configured host
|
# Create thread for each configured host
|
||||||
for key, host in host_items:
|
for key, host in host_items:
|
||||||
|
|
||||||
|
# Check if hosts timeout is set otherwise use "1" (means 1 seconds)
|
||||||
|
host_timeout = float(config.get('hosts_timeout', key, fallback=1))
|
||||||
|
|
||||||
# Check if hosts timer is set otherwise use "5" (means 5 seconds)
|
# Check if hosts timer is set otherwise use "5" (means 5 seconds)
|
||||||
host_timer = int(config.get('hosts_timer', key, fallback=5))
|
host_timer = int(config.get('hosts_timer', key, fallback=5))
|
||||||
|
|
||||||
@@ -156,8 +164,8 @@ def main():
|
|||||||
host_location = config.get('hosts_location', key, fallback="unknown")
|
host_location = config.get('hosts_location', key, fallback="unknown")
|
||||||
|
|
||||||
# Create Thread
|
# Create Thread
|
||||||
print("Creating thread for: %s, with interval: %s and location: %s" %(host, host_timer, host_location))
|
print("Creating thread for: %s, with timeout: %s, with interval: %s and location: %s" % (host, host_timeout, host_timer, host_location))
|
||||||
thread = ThreadPing(MyDB, host, host_timer, host_location)
|
thread = ThreadPing(MyDB, host, host_timeout, host_timer, host_location)
|
||||||
my_threads.append(thread)
|
my_threads.append(thread)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
|||||||
62
README.md
62
README.md
@@ -57,15 +57,16 @@ You can find everything under *./Docker_Build/* and in the python program itself
|
|||||||
|
|
||||||
### ENV Variables
|
### ENV Variables
|
||||||
|
|
||||||
Name | Example | Usage | Option/Must
|
Name | Example | Usage | Option/Must | Type | Default
|
||||||
:------: | :-----: | :-----: | :-----:
|
:------: | :-----: | :-----: | :-----: | :-----: | :-----:
|
||||||
INFLUX_URL | http://10.0.0.1:8086 | InfluxDB Host | must
|
INFLUX_URL | http://10.0.0.1:8086 | InfluxDB Host | must | URL | ---
|
||||||
INFLUX_TOKEN | eWOcp-MCv2Y3IJPlER7wc...ICKirhw0lwEczRNnrIoTqZAg== | InfluxDB API Token | must
|
INFLUX_TOKEN | eWOcp-MCv2YPlER7wc...0zRNnrIoTqZAg== | InfluxDB API Token | must | String | ---
|
||||||
INFLUX_BUCKET | latency | InfluxDB Bucket | must
|
INFLUX_BUCKET | latency | InfluxDB Bucket | must | String | ---
|
||||||
INFLUX_ORG | MyOrg | InfluxDB Organization | must
|
INFLUX_ORG | MyOrg | InfluxDB Organization | must | String | ---
|
||||||
TARGET_HOST | 8.8.8.8 | Monitored Host (IP/FQDN) | must
|
TARGET_HOST | 8.8.8.8 | Monitored Host (IP/FQDN) | must | FQDN or IP | ---
|
||||||
TARGET_TIMER | 3 | ping frequency in sec. | option
|
TARGET_TIMEOUT | 0.5 | ping timeout in sec. | optional | Float >0 | **1**
|
||||||
TARGET_LOCATION | Google | decript. location | option
|
TARGET_TIMER | 3 | ping frequency in sec. | optional | Int >1 | **5**
|
||||||
|
TARGET_LOCATION | Google | decript. location | optional | String |**unknown**
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@@ -75,7 +76,9 @@ TARGET_LOCATION | Google | decript. location | option
|
|||||||
|
|
||||||
**Keep in mind it´s a OR decision not a AND**
|
**Keep in mind it´s a OR decision not a AND**
|
||||||
|
|
||||||
See [./latency-monitor/config.ini](./latency-monitor/config.ini)
|
See [./latency-monitor/config-template.ini](./latency-monitor/config-template.ini)
|
||||||
|
|
||||||
|
**ENV wins over file**
|
||||||
|
|
||||||
|
|
||||||
#### Docker-Compose Style
|
#### Docker-Compose Style
|
||||||
@@ -119,6 +122,7 @@ in the **.env** file *(env needs to be renamed to .env)* configure following var
|
|||||||
- YOUR_BUCKET_NAME
|
- YOUR_BUCKET_NAME
|
||||||
- YOUR_ADMIN_TOKEN
|
- YOUR_ADMIN_TOKEN
|
||||||
- YOUR_MONITORED_TARGET
|
- YOUR_MONITORED_TARGET
|
||||||
|
- YOUR_MONITORED_TARGET_TIMEOUT
|
||||||
- YOUR_MONITORED_TARGET_TIMER
|
- YOUR_MONITORED_TARGET_TIMER
|
||||||
- YOUR_MONITORED_TARGET_LOCATION
|
- YOUR_MONITORED_TARGET_LOCATION
|
||||||
|
|
||||||
@@ -161,6 +165,14 @@ Just the certificates are missing look [here](#certificate)
|
|||||||
|
|
||||||
Now run it and mybe pick a example dashboard for grafana from [here](#grafana-dashboard-examples)
|
Now run it and mybe pick a example dashboard for grafana from [here](#grafana-dashboard-examples)
|
||||||
|
|
||||||
|
#### BACKUPS FILES ???
|
||||||
|
|
||||||
|
The script will backup following files if found:
|
||||||
|
|
||||||
|
- *./docker-compose.yml*
|
||||||
|
- *./grafana/provisioning/datasources/grafana-datasource.yml*
|
||||||
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@@ -181,7 +193,7 @@ You need to configure Variables in following files to make the compose work:
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
- **docker-compose.yml** *(was docker-compose-full_stack.yml before)*
|
- **docker-compose.yml** *(generated from docker-compose-full_stack.yml)*
|
||||||
- PLACE_YOUR_FQDN_HERE (3 times)
|
- PLACE_YOUR_FQDN_HERE (3 times)
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@@ -194,12 +206,13 @@ You need to configure Variables in following files to make the compose work:
|
|||||||
- YOUR_BUCKET_NAME
|
- YOUR_BUCKET_NAME
|
||||||
- YOUR_ADMIN_TOKEN
|
- YOUR_ADMIN_TOKEN
|
||||||
- YOUR_MONITORED_TARGET
|
- YOUR_MONITORED_TARGET
|
||||||
|
- YOUR_MONITORED_TARGET_TIMEOUT
|
||||||
- YOUR_MONITORED_TARGET_TIMER
|
- YOUR_MONITORED_TARGET_TIMER
|
||||||
- YOUR_MONITORED_TARGET_LOCATION
|
- YOUR_MONITORED_TARGET_LOCATION
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
- **grafana/provisioning/datasources/grafana-datasource.yml**
|
- **grafana/provisioning/datasources/grafana-datasource.yml** *(generated from grafana/grafana-datasource-template.yml)*
|
||||||
- YOUR_ADMIN_TOKEN
|
- YOUR_ADMIN_TOKEN
|
||||||
- YOUR_ORGANIZATION
|
- YOUR_ORGANIZATION
|
||||||
- YOUR_BUCKET_NAME
|
- YOUR_BUCKET_NAME
|
||||||
@@ -232,7 +245,7 @@ Everything should be right in place now.
|
|||||||
|
|
||||||
Just the certificates are missing look [here](#certificate)
|
Just the certificates are missing look [here](#certificate)
|
||||||
|
|
||||||
Now run it and mybe pick a example dashboard for grafana from [here](#grafana-dashboard-examples)
|
Now just start over and maybe pick an example dashboard for grafana from [here](#grafana-dashboard-examples)
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-----
|
-----
|
||||||
@@ -280,11 +293,26 @@ Contributors names and contact info
|
|||||||
|
|
||||||
## Version History
|
## Version History
|
||||||
|
|
||||||
|
- v0.4
|
||||||
|
- moved from self build iamge to dockerhub
|
||||||
|
|
||||||
|
- v0.3a
|
||||||
|
- ping timeout added
|
||||||
|
- cleanup
|
||||||
|
|
||||||
|
* v0.3
|
||||||
|
* setup-script fixed and backup added
|
||||||
|
* fixed latency value problem (was sometimes string instead of float)
|
||||||
|
* cleanup
|
||||||
|
|
||||||
|
* v0.2b
|
||||||
|
* cleanup
|
||||||
|
|
||||||
* v0.2a
|
* v0.2a
|
||||||
* fixed some missing variables
|
* fixed some missing variables
|
||||||
* fixe a missing integer declaration in latency-monitor
|
* fixe a missing integer declaration in latency-monitor
|
||||||
* added automatic config creation for full-stack
|
* added automatic config creation for full-stack
|
||||||
* cleanups
|
* cleanups
|
||||||
|
|
||||||
* v0.1
|
* v0.1
|
||||||
* Initial Release
|
* Initial Release
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ services:
|
|||||||
latency-monitor:
|
latency-monitor:
|
||||||
container_name: latency-monitor
|
container_name: latency-monitor
|
||||||
hostname: latency-monitor
|
hostname: latency-monitor
|
||||||
build: ./Docker_Build
|
image: planetespresso/pylatemon
|
||||||
depends_on:
|
depends_on:
|
||||||
- influxdb
|
- influxdb
|
||||||
restart: always
|
restart: always
|
||||||
@@ -134,6 +134,7 @@ services:
|
|||||||
- INFLUX_BUCKET
|
- INFLUX_BUCKET
|
||||||
- INFLUX_ORG
|
- INFLUX_ORG
|
||||||
- TARGET_HOST
|
- TARGET_HOST
|
||||||
|
- TARGET_TIMEOUT
|
||||||
- TARGET_TIMER
|
- TARGET_TIMER
|
||||||
- TARGET_LOCATION
|
- TARGET_LOCATION
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ services:
|
|||||||
latency-monitor:
|
latency-monitor:
|
||||||
container_name: latency-monitor
|
container_name: latency-monitor
|
||||||
hostname: latency-monitor
|
hostname: latency-monitor
|
||||||
build: ./Docker_Build
|
image: planetespresso/pylatemon
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
# - ./latency-monitor/config.ini:/app/config.ini:ro # UNCOMMENT IF NEEDED
|
# - ./latency-monitor/config.ini:/app/config.ini:ro # UNCOMMENT IF NEEDED
|
||||||
|
|||||||
1
env
1
env
@@ -36,5 +36,6 @@ INFLUX_TOKEN=YOUR_ADMIN_TOKEN
|
|||||||
INFLUX_BUCKET=YOUR_BUCKET_NAME
|
INFLUX_BUCKET=YOUR_BUCKET_NAME
|
||||||
INFLUX_ORG=YOUR_ORGANIZATION
|
INFLUX_ORG=YOUR_ORGANIZATION
|
||||||
TARGET_HOST=YOUR_MONITORED_TARGET
|
TARGET_HOST=YOUR_MONITORED_TARGET
|
||||||
|
TARGET_TIMEOUT=YOUR_MONITORED_TARGET_TIMEOUT
|
||||||
TARGET_TIMER=YOUR_MONITORED_TARGET_TIMER
|
TARGET_TIMER=YOUR_MONITORED_TARGET_TIMER
|
||||||
TARGET_LOCATION=YOUR_MONITORED_TARGET_LOCATION
|
TARGET_LOCATION=YOUR_MONITORED_TARGET_LOCATION
|
||||||
@@ -23,6 +23,11 @@
|
|||||||
# host2 = 8.8.4.4
|
# host2 = 8.8.4.4
|
||||||
# host3 = 1.1.1.1
|
# host3 = 1.1.1.1
|
||||||
|
|
||||||
|
[hosts_timeout] # OPTIONAL; ping timeout in seconds (float); default is '1'
|
||||||
|
# host1 = 1
|
||||||
|
# host2 = 0.5
|
||||||
|
# host3 = 0.2
|
||||||
|
|
||||||
[hosts_timer] # OPTIONAL; ping interval in seconds; default is '5'
|
[hosts_timer] # OPTIONAL; ping interval in seconds; default is '5'
|
||||||
# host1 = 1
|
# host1 = 1
|
||||||
# host2 = 3
|
# host2 = 3
|
||||||
@@ -1,24 +1,37 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Check if .env allready exists
|
Date=`date +%Y%m%d_%H%M%s`
|
||||||
if ! test -e .env; then
|
|
||||||
echo "FAIL: You need to copy file env to .env and edit it!!!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# copy compose template to final compose file (OVERWRITTEN!!!)
|
|
||||||
cp -f ./docker-compose-full_stack.yml ./docker-compose.yml
|
|
||||||
|
|
||||||
# locate my path
|
# locate my path
|
||||||
MyScriptPath=`dirname $0`
|
MyScriptPath=`dirname $0`
|
||||||
MyScriptPathContainer="$MyScriptPath/CONTAINER/"
|
MyScriptPathContainer="$MyScriptPath/CONTAINER/"
|
||||||
|
|
||||||
|
# Check if .env allready exists
|
||||||
|
if ! test -e $MyScriptPath/.env; then
|
||||||
|
echo "FAIL: You need to copy file env to .env and edit it!!!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# backup old compose files
|
||||||
|
cp -f $MyScriptPath/docker-compose.yml $MyScriptPath/docker-compose-$Date.backup
|
||||||
|
# copy compose template to final compose file (OVERWRITTEN!!!)
|
||||||
|
cp -f $MyScriptPath/docker-compose-full_stack.yml $MyScriptPath/docker-compose.yml
|
||||||
|
|
||||||
|
# Make relevant grafana templating direcotries
|
||||||
|
echo "MKDIR: creating $MyScriptPath/grafana/provisioning/datasources"
|
||||||
|
mkdir -p $MyScriptPath/grafana/provisioning/datasources
|
||||||
|
# backup old grafana datasource file
|
||||||
|
cp -f $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml $MyScriptPath/grafana/grafana-datasource-$Date.backup
|
||||||
|
# copy grafana datasource file template to grafana datasource file
|
||||||
|
cp -f $MyScriptPath/grafana/grafana-datasource-template.yml $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml
|
||||||
|
|
||||||
|
|
||||||
# Replace .env MyPath Path with local path if NOT changed
|
# Replace .env MyPath Path with local path if NOT changed
|
||||||
sed -i -e "s#/YOUR_PATH_TO_CONTAINER_STATIC_DATA#$MyScriptPathContainer#g" .env
|
sed -i -e "s#/YOUR_PATH_TO_CONTAINER_STATIC_DATA#$MyScriptPathContainer#g" $MyScriptPath/.env
|
||||||
|
|
||||||
|
|
||||||
# Read variables from .env file
|
# Read variables from .env file
|
||||||
source .env
|
source $MyScriptPath/.env
|
||||||
|
|
||||||
echo "INFO: MyPath is $MyPath"
|
echo "INFO: MyPath is $MyPath"
|
||||||
|
|
||||||
@@ -35,6 +48,8 @@ echo "CHANGE: replace PLACE_YOUR_FQDN_HERE with $MyFQDN in $MyScriptPath/docker-
|
|||||||
sed -i -e "s/PLACE_YOUR_FQDN_HERE/$MyFQDN/g" $MyScriptPath/docker-compose.yml
|
sed -i -e "s/PLACE_YOUR_FQDN_HERE/$MyFQDN/g" $MyScriptPath/docker-compose.yml
|
||||||
|
|
||||||
# Changes in grafana/provisioning/datasources/grafana-datasource.yml
|
# Changes in grafana/provisioning/datasources/grafana-datasource.yml
|
||||||
|
echo "CHANGE: replace YOUR_INFLUXDB_URL with $INFLUX_URL in $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml"
|
||||||
|
sed -i -e "s#YOUR_INFLUXDB_URL#$INFLUX_URL#g" $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml
|
||||||
echo "CHANGE: replace YOUR_ADMIN_TOKEN with $INFLUX_TOKEN in $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml"
|
echo "CHANGE: replace YOUR_ADMIN_TOKEN with $INFLUX_TOKEN in $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml"
|
||||||
sed -i -e "s/YOUR_ADMIN_TOKEN/$INFLUX_TOKEN/g" $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml
|
sed -i -e "s/YOUR_ADMIN_TOKEN/$INFLUX_TOKEN/g" $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml
|
||||||
echo "CHANGE: replace YOUR_ORGANIZATION with $INFLUX_ORG in $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml"
|
echo "CHANGE: replace YOUR_ORGANIZATION with $INFLUX_ORG in $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml"
|
||||||
@@ -45,6 +60,8 @@ sed -i -e "s/YOUR_BUCKET_NAME/$INFLUX_BUCKET/g" $MyScriptPath/grafana/provisioni
|
|||||||
# Correct owner and permissions to satisfy the containers
|
# Correct owner and permissions to satisfy the containers
|
||||||
echo "CHMOD: chmod -R 755 $MyPath"
|
echo "CHMOD: chmod -R 755 $MyPath"
|
||||||
chmod -R 755 $MyPath
|
chmod -R 755 $MyPath
|
||||||
|
echo "CHMOD: chmod -R 755 $MyScriptPath/grafana/provisioning"
|
||||||
|
chmod -R 755 $MyScriptPath/grafana/provisioning
|
||||||
echo "CHMOD: chmod 644 $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml"
|
echo "CHMOD: chmod 644 $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml"
|
||||||
chmod 644 $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml
|
chmod 644 $MyScriptPath/grafana/provisioning/datasources/grafana-datasource.yml
|
||||||
echo "CHOWN: chown -R 472.472 $MyPath/grafana/var_lib"
|
echo "CHOWN: chown -R 472.472 $MyPath/grafana/var_lib"
|
||||||
|
|||||||
Reference in New Issue
Block a user