Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd52e9ef41 | ||
|
|
682c943b2e | ||
|
|
c3d367c4d9 |
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-template.ini
|
||||||
@@ -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,
|
||||||
@@ -114,7 +114,7 @@ class ThreadPing(Thread):
|
|||||||
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, 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))
|
||||||
|
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -280,11 +280,14 @@ Contributors names and contact info
|
|||||||
|
|
||||||
## Version History
|
## Version History
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|||||||
@@ -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