Compare commits

..

3 Commits

Author SHA1 Message Date
a54c8e566b Improved deploy and build scripts 2025-12-29 14:06:49 +01:00
db9e2bf87a Updated db name 2025-11-07 14:41:52 +01:00
493cfb1b88 Merge branch 'influxdb3' 2025-10-02 22:27:49 +02:00
4 changed files with 35 additions and 24 deletions

View File

@@ -1,19 +0,0 @@
#!/bin/bash
GIT_HASH=$(git rev-parse --short HEAD)
docker-compose stop routermon
docker-compose stop upsmon
docker container prune
echo "Building UPSmon"
cp ../pyutils/utils.py ../upsmon/
docker build --build-arg BUILD_VER=${GIT_HASH} -f ../upsmon/upsmon.Dockerfile -t upsmon:influx3 ../upsmon
rm ../upsmon/utils.py
echo "Building Routermon"
cp ../pyutils/utils.py ../routermon/
docker build --build-arg BUILD_VER=${GIT_HASH} -f ../routermon/routermon.Dockerfile -t routermon:influx3 ../routermon
rm ../routermon/utils.py
docker-compose up -d

13
docker/deploy.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
GIT_HASH=$(git rev-parse --short HEAD)
cp ../pyutils/utils.py ../upsmon/
cp ../pyutils/utils.py ../routermon/
docker compose build --build-arg BUILD_VER=${GIT_HASH}
rm ../upsmon/utils.py
rm ../routermon/utils.py
docker compose up -d

View File

@@ -3,6 +3,10 @@ services:
image: influxdb:3-core
container_name: edx-influxdb3
restart: unless-stopped
ulimits:
nofile:
soft: 65536
hard: 65536
ports:
- 8181:8181
command:
@@ -38,7 +42,12 @@ services:
max-file: "5"
upsmon:
image: upsmon:influx3
build:
context: ../upsmon
dockerfile: ../upsmon/upsmon.Dockerfile
args:
BUILD_VER:
#image: upsmon:influx3
container_name: edx-upsmon
restart: unless-stopped
depends_on:
@@ -54,7 +63,7 @@ services:
- INTERVAL=5
- INFLUXDB_TOKEN=apiv3_tbEpA8JmIRTfr8Wbw9npD79BcMlFsnV4_jhdt-CdUP53Mos61KBODGaggl2g5oKZZvZrZu3e6mpob6zorhEdbg
- INFLUXDB_URL=http://influxdb3:8181
- INFLUXDB_DATABASE=edelweiss
- INFLUXDB_DATABASE=edelweiss30d
- PORT=/dev/ttyS0
- BAUD=2400
- LOG_FILE=/tmp/upsmon.log
@@ -62,7 +71,12 @@ services:
- LOG_CLI_LVL=INFO
routermon:
image: routermon:influx3
build:
context: ../routermon
dockerfile: ../routermon/routermon.Dockerfile
args:
BUILD_VER:
#image: routermon:influx3
container_name: edx-routermon
restart: unless-stopped
depends_on:
@@ -76,7 +90,7 @@ services:
- INTERVAL=5
- INFLUXDB_TOKEN=apiv3_tbEpA8JmIRTfr8Wbw9npD79BcMlFsnV4_jhdt-CdUP53Mos61KBODGaggl2g5oKZZvZrZu3e6mpob6zorhEdbg
- INFLUXDB_URL=http://influxdb3:8181
- INFLUXDB_DATABASE=edelweiss
- INFLUXDB_DATABASE=edelweiss30d
- MIKROTIK_IP=192.168.31.1
- MIKROTIK_USER=service
- MIKROTIK_PASSWORD=dataservice

View File

@@ -65,7 +65,10 @@ def main() -> int:
if_stats_old = if_stats
LOGGER.debug(f"\nInterfaces: {json.dumps(if_stats, indent = 2)}")
LOGGER.debug(f"\nResources: {json.dumps(hw_stats, indent = 2)}")
time.sleep(INTERVAL-(last-now))
last: float = time.time()
cycle_time: float = last - now
LOGGER.debug(f"Cycle Time: {cycle_time:4.3f}")
time.sleep(INTERVAL-cycle_time)
except Exception as e:
print(f"Unexpected exception: [{e}]")
return 1