Skip to content

Commit

Permalink
Updated Rockchip3588 monitoring: refined Dockerfile, code refactoring…
Browse files Browse the repository at this point in the history
… to use shared files
  • Loading branch information
MarkhamLee committed Apr 2, 2024
1 parent 98488eb commit cd58b63
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,9 @@
# convert the payload that's appended to the base to json, otherwise you
# will DB write errors. The standard data = {"key": "value"} Python dict
# is fine.

import logging
from hw_monitoring_libraries.logging_util import logger
from influxdb_client import InfluxDBClient # noqa E402
from influxdb_client.client.write_api import SYNCHRONOUS # noqa E402
from sys import stdout

# set up/configure logging with stdout so it can be picked up by K8s
logger = logging.getLogger('utilities_logger')
logger.setLevel(logging.DEBUG)

handler = logging.StreamHandler(stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(filename)s - %(message)s') # noqa: E501
handler.setFormatter(formatter)
logger.addHandler(handler)


class InfluxClient():
Expand Down
27 changes: 27 additions & 0 deletions hardware_monitoring/rockchip3588/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# temp stage
FROM python:3.12.2-slim as build

WORKDIR /app

RUN apt-get update -y && apt-get install -y gcc python3-dev

COPY /hw_monitoring_libraries/requirements.txt .

RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt


# final stage
FROM python:3.12-slim

COPY ./hw_monitoring_libraries ./hw_monitoring_libraries

WORKDIR /hw_telemetry

COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .

RUN pip install --no-cache /wheels/*

COPY ./rockchip3588 ./

ENTRYPOINT ["python3", "/hw_telemetry/main.py"]
8 changes: 0 additions & 8 deletions hardware_monitoring/rockchip3588/container/Dockerfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
#!/usr/bin/env python
# Markham Lee (C) 2023 - 2024
# K3s-Data-Platform-IoT
# https://github.com/MarkhamLee/kubernetes-k3s-data-platform-IoT
# This script "should work" on any device running a Rockchip 3588
# System on Chip (SOC). But it was specifically built and tested on
# an Orange Pi 5 Plus Running Joshua Riek's Ubuntu Distro for
# RockChip 3588 Devices:
# https://github.com/Joshua-Riek/ubuntu-rockchip


import time
# kubernetes-k3s-data-and-IoT-platform
# https://github.com/MarkhamLee/kubernetes-k3s-data-and-IoT-platform
# HW monitoring Script for an Orange Pi 5+, meant to extend the
# monitoring capabilities in K8s, tracking: CPU, NVME and GPU temps
# & utilization data. This script "should work" on any device running
# a Rockchip 3588 System on Chip (SOC). But it was specifically built and
# tested on an Orange Pi 5 Plus Running Joshua Riek's Ubuntu Distro for
# RockChip 3588 Devices: https://github.com/Joshua-Riek/ubuntu-rockchip
import gc
import os
import logging
from sys import stdout
import sys
import time
from rockchip_3588 import RockChipData
from influx_client import InfluxClient

# set up/configure logging with stdout so it can be picked up by K8s
logger = logging.getLogger('rockchip_telemetry_logger')
logger.setLevel(logging.DEBUG)
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(parent_dir)

handler = logging.StreamHandler(stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(filename)s - %(message)s') # noqa: E501
handler.setFormatter(formatter)
logger.addHandler(handler)
from hw_monitoring_libraries.logging_util import logger # noqa: E402
from hw_monitoring_libraries.influx_client import InfluxClient # noqa: E402

# instantiate InfluxDB class
influxdb_write = InfluxClient()
Expand Down

0 comments on commit cd58b63

Please sign in to comment.