Finished InfluxDB integration

This commit is contained in:
YuruC3 2025-07-02 22:43:08 +02:00
parent b6c91e4ac4
commit 582925b8a1
4 changed files with 62 additions and 53 deletions

View File

@ -3,16 +3,8 @@
services: services:
mdfanchanger: mdfanchanger:
container_name: MD_Fan_Changer container_name: MD_Fan_Changer
image: yuruc3/md1200_fan_controll:v1.2.1 image: yuruc3/md1200_fan_controll:v2-flux
environment: env_file: md1200.env
# - MD1200BAUD=
- SERIALADAPTER=/dev/ttyUSB0
- TEMP_FACTOR=17
- EPPYSLEEPY=0.5
- MDSERIALTIMEOUT=0.5
# - LOW_FAN_TRSHD=
# - HIGH_FAN_TRSHD=
env_file: "md1200.env"
devices: devices:
- /dev/ttyUSB0:/dev/ttyUSB0 - /dev/ttyUSB0:/dev/ttyUSB0
restart: unless-stopped restart: unless-stopped

View File

@ -10,7 +10,7 @@ MD1200BAUD = int(os.getenv("MD1200BAUD", 38400))
# used if you want to run it on multiple JBODs # used if you want to run it on multiple JBODs
SERIALADAPTER = os.getenv("SERIALADAPTER", "/dev/ttyUSB0") SERIALADAPTER = os.getenv("SERIALADAPTER", "/dev/ttyUSB0")
# Factor that defines how aggressive the temperature curve is # Factor that defines how aggressive the temperature curve is
TEMP_FACTOR = int(os.getenv("TEMP_FACTOR", 16)) TEMP_FACTOR = int(os.getenv("TEMP_FACTOR", 19))
# time between sending command to get temp and storing it. It's there to allow JBOD to answer # time between sending command to get temp and storing it. It's there to allow JBOD to answer
EPPYSLEEPY = float(os.getenv("EPPYSLEEPY", 1)) EPPYSLEEPY = float(os.getenv("EPPYSLEEPY", 1))
@ -59,10 +59,11 @@ MDict = {}
fluxSending = False fluxSending = False
currentTime = 0 currentTime = 0
lastTempReading = 0 lastTempReading = 0
inflxdb_LeData = []
# Initialize InfluxDB client and influxdb API # Initialize InfluxDB client and influxdb API
# ---------------------UNCOMMENT----------------------- # ---------------------UNCOMMENT-----------------------
# inflxdb_client = influxdb_client.InfluxDBClient(url=url, token=token, org=org) inflxdb_client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)
# write_api = inflxdb_client.write_api(write_options=SYNCHRONOUS) write_api = inflxdb_client.write_api(write_options=SYNCHRONOUS)
# ---------------------UNCOMMENT----------------------- # ---------------------UNCOMMENT-----------------------
@ -178,41 +179,33 @@ def process_temps():
# ---LeData--- # ---LeData---
if fluxSending: if fluxSending:
# Prep InfluxDB data # Prep InfluxDB data
# ---------------------UNCOMMENT----------------------- inflxdb_Data_To_Send = (
# inflxdb_Data_To_Send = ( influxdb_client.Point(f"{measurement}-script")
# influxdb_client.Point(f"{measurement}-script") .tag("MACHINE", MACHINE_TAG)
# .tag("MACHINE", MACHINE_TAG) .tag("LOCATION", LOCATION)
# .tag("LOCATION", LOCATION) .field("Backplane1", MDict["bp1"])
# .field("Backplane1", MDict["bp1"]) .field("Backplane2", MDict["bp2"])
# .field("Backplane2", MDict["bp2"]) .field("SASIntModule0", MDict["sim0"])
# .field("SASIntModule0", MDict["sim0"]) .field("SASIntModule1", MDict["sim1"])
# .field("SASIntModule1", MDict["sim1"]) .field("Expander0", MDict["exp0"])
# .field("Expander0", MDict["exp0"]) .field("Expander1", MDict["exp1"])
# .field("Expander1", MDict["exp1"]) .field("Average", MDict["avg"])
# .field("Average", MDict["avg"]) )
# )
# inflxdb_Datazz_To_Send.append(inflxdb_Data_To_Send) # Prep/append data
# # Send data to InfluxDB inflxdb_LeData.append(inflxdb_Data_To_Send)
# write_api.write(bucket=bucket, org=org, record=inflxdb_Data_To_Send) # Send data to InfluxDB
# # time.sleep(INFLX_SEPARATE_POINTS) # separate points write_api.write(bucket=bucket, org=org, record=inflxdb_Data_To_Send)
# # print(f"{len(bigDict)} <--- This many entrys")
# # Clean up before another loop # Clean up before another loop
# bigDict.clear() inflxdb_LeData.clear()
# inflxdb_Datazz_To_Send.clear() print("Sending data to InfluxDB", flush=True)
# ---------------------UNCOMMENT-----------------------
print("I'm sending stuff to InfluxDB")
fluxSending = False fluxSending = False
# print("----------------")
# return ()
else: else:
continue time.sleep(0.25)

View File

@ -1,14 +1,19 @@
# baud_rate= # MD1200BAUD=
# serial_adapter= SERIALADAPTER=/dev/ttyUSB0
# wait_time=
# temp_factor= EPPYSLEEPY=1
# lower_treshold= MDSERIALTIMEOUT=1
# upper_treshold= TEMPREADINTERVAL=15
INFLUX_TOKEN=apg1gysUeCcxdcRTMmosJTenbEppmUNi9rXlANDB2oNadBdWAu2GVTDc_q_dyo0iyYsckKaOvPRm6ba2NK0y_A==
TEMP_FACTOR=17
# LOW_FAN_TRSHD=21
# HIGH_FAN_TRSHD=40
# Influxdb config
INFLUX_TOKEN=-3rZgq6EprG9i-gKqBDSFCC3hTS3U49fxGkg==
INFLUX_BUCKET=JBOD INFLUX_BUCKET=JBOD
INFLUX_ORG=staging INFLUX_ORG=FUBUKUS
INFLUX_URL=http://localhost:8086 INFLUX_URL=http://192.168.1.101:8086
INFLUX_MEASUREMENT=MD1200 INFLUX_MEASUREMENT=MD1200
INFLUX_MACHINE_TAG=CHONGUS1200 INFLUX_MACHINE_TAG=CHONGUS1200
INFLUX_LOCATION=HQ INFLUX_LOCATION=HQ
INFLX_SEPARATE_POINTS=0.1

View File

@ -0,0 +1,19 @@
MD1200BAUD=38400
SERIALADAPTER=/dev/ttyUSB0
EPPYSLEEPY=1
MDSERIALTIMEOUT=1
TEMPREADINTERVAL=15
TEMP_FACTOR=19
LOW_FAN_TRSHD=21
HIGH_FAN_TRSHD=40
# Influxdb config
INFLUX_TOKEN===
INFLUX_BUCKET=JBOD
INFLUX_ORG=staging
INFLUX_URL=http://localhost:8086
INFLUX_MEASUREMENT=MD1200
INFLUX_MACHINE_TAG=CHONGUS1200
INFLUX_LOCATION=HQ