Collecting IDRAC stats works.
Data is being inserted to both InfluxDB and mariadb
This commit is contained in:
@@ -92,6 +92,7 @@ class snmpPyIDRACData():
|
|||||||
inletTemp: float
|
inletTemp: float
|
||||||
exhaustTemp: float
|
exhaustTemp: float
|
||||||
cpu1Temp: float
|
cpu1Temp: float
|
||||||
|
uptimeS: int
|
||||||
uptimeH: float
|
uptimeH: float
|
||||||
|
|
||||||
# optional fields
|
# optional fields
|
||||||
@@ -125,6 +126,7 @@ class snmpPyCiscoData():
|
|||||||
inletTemp: float
|
inletTemp: float
|
||||||
exhaustTemp: float
|
exhaustTemp: float
|
||||||
cpu1Temp: float
|
cpu1Temp: float
|
||||||
|
uptimeS: int
|
||||||
uptimeH: float
|
uptimeH: float
|
||||||
|
|
||||||
# optional fields
|
# optional fields
|
||||||
@@ -145,6 +147,7 @@ class snmpPyCiscoData():
|
|||||||
f"Exhaust {self.exhaustTemp} C\n"
|
f"Exhaust {self.exhaustTemp} C\n"
|
||||||
f"CPU1 {self.cpu1Temp} C\n"
|
f"CPU1 {self.cpu1Temp} C\n"
|
||||||
f"CPU2 {self.cpu2Temp} C\n"
|
f"CPU2 {self.cpu2Temp} C\n"
|
||||||
|
f"Uptime {self.uptimeS} Seconds\n"
|
||||||
f"Uptime {self.uptimeH} Hours\n"
|
f"Uptime {self.uptimeH} Hours\n"
|
||||||
f"Uptime {self.uptimeD} Days"
|
f"Uptime {self.uptimeD} Days"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import influxdb_client, sqlalchemy, random, os, asyncio
|
import influxdb_client, sqlalchemy, random, os, asyncio
|
||||||
# from sqlmodel import Field, Session, SQLModel, create_engine, select
|
from dataclasses import asdict
|
||||||
# from sqlalchemy import create_engine, exc # , Column, Integer, String, Numeric
|
|
||||||
# from sqlalchemy.ext.declarative import declarative_base
|
|
||||||
# from sqlalchemy.orm import sessionmaker
|
|
||||||
from sqlalchemy.ext.asyncio import create_async_engine
|
from sqlalchemy.ext.asyncio import create_async_engine
|
||||||
|
from sqlTables import *
|
||||||
|
|
||||||
from classes import *
|
from classes import *
|
||||||
from typing import Annotated, Final
|
from typing import Annotated, Final
|
||||||
@@ -103,10 +102,14 @@ async def sqlDataWriter(
|
|||||||
t1.insert(), [{"name": "some name 1"}, {"name": "some name 2"}]
|
t1.insert(), [{"name": "some name 1"}, {"name": "some name 2"}]
|
||||||
)
|
)
|
||||||
case "IDRAC":
|
case "IDRAC":
|
||||||
|
payload = inpDict["value"] # snmpPyIDRACData
|
||||||
|
row = asdict(payload)
|
||||||
|
|
||||||
await eng.execute(
|
await eng.execute(
|
||||||
# changeMeLater
|
idracMeasurement.insert(),
|
||||||
t1.insert(), [{"name": "some name 1"}, {"name": "some name 2"}]
|
[row]
|
||||||
)
|
)
|
||||||
|
return 0
|
||||||
case "FANS":
|
case "FANS":
|
||||||
await eng.execute(
|
await eng.execute(
|
||||||
# changeMeLater
|
# changeMeLater
|
||||||
@@ -146,15 +149,21 @@ async def fluxWriter(
|
|||||||
|
|
||||||
# Prep InfluxDB data
|
# Prep InfluxDB data
|
||||||
inflxdb_Data_To_Send = (
|
inflxdb_Data_To_Send = (
|
||||||
influxdb_client.Point(f"{INFXLUXDB_MEASUEREMENT}")
|
influxdb_client.Point(INFXLUXDB_MEASUEREMENT)
|
||||||
.tag("PLACE", inpayload.name)
|
.tag("SOURCE", inpDict["source"])
|
||||||
.tag("TEMP", sensorIDinp)
|
.tag("TYPE", inpDict["type"])
|
||||||
.tag("TEMP", whatTheSensor)
|
.tag("HOSTNAME", inpDict["value"].hostname)
|
||||||
.field("TEMP", inpayload.temp)
|
.field("PowerDrawPSU1", inpDict["value"].powerDrawPSU1)
|
||||||
.field("TEMP", inpayload.humid)
|
.field("PowerDrawPSU2", inpDict["value"].powerDrawPSU2)
|
||||||
.field("TEMP", inpayload.hicc)
|
.field("VoltagePSU1", inpDict["value"].voltagePSU1)
|
||||||
.field("TEMP", inpayload.presss)
|
.field("VoltagePSU2", inpDict["value"].voltagePSU2)
|
||||||
.field("TEMP", inpayload.alttd)
|
.field("InletTemperature", inpDict["value"].inletTemp)
|
||||||
|
.field("ExhaustTemperature", inpDict["value"].exhaustTemp)
|
||||||
|
.field("TemperatureCPU1", inpDict["value"].cpu1Temp)
|
||||||
|
.field("TemperatureCPU2", inpDict["value"].cpu2Temp)
|
||||||
|
.field("UptimeInSeconds", inpDict["value"].uptimeS)
|
||||||
|
.field("UptimeInHours", inpDict["value"].uptimeH)
|
||||||
|
.field("UptimeInDays", inpDict["value"].uptimeD)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -252,7 +261,7 @@ async def ciscoPoolRemote(remoteIP: str, queueToInsrt: asyncio.Queue):
|
|||||||
"type": "snmpPyCiscoData"
|
"type": "snmpPyCiscoData"
|
||||||
}
|
}
|
||||||
# return returnObj
|
# return returnObj
|
||||||
queueToInsrt.put(returnDict)
|
await queueToInsrt.put(returnDict)
|
||||||
|
|
||||||
# IDRAC get data for snmpPyIDRACData class
|
# IDRAC get data for snmpPyIDRACData class
|
||||||
async def idracPoolRemote_v3(remoteIP: str, queueToInsrt: asyncio.Queue):
|
async def idracPoolRemote_v3(remoteIP: str, queueToInsrt: asyncio.Queue):
|
||||||
@@ -326,6 +335,8 @@ async def idracPoolRemote_v3(remoteIP: str, queueToInsrt: asyncio.Queue):
|
|||||||
cpu2Temp=int(varBinds[8][-1] / 10),
|
cpu2Temp=int(varBinds[8][-1] / 10),
|
||||||
# CPU1 and CPU2 temp
|
# CPU1 and CPU2 temp
|
||||||
|
|
||||||
|
uptimeS=int(varBinds[9][-1]),
|
||||||
|
# seconds
|
||||||
uptimeH=round(((int(varBinds[9][-1]) / 60) / 60), ROUND_PREC),
|
uptimeH=round(((int(varBinds[9][-1]) / 60) / 60), ROUND_PREC),
|
||||||
# seconds->minutes->hours
|
# seconds->minutes->hours
|
||||||
uptimeD=round((((int(varBinds[9][-1]) / 60) / 60) / 24), ROUND_PREC)
|
uptimeD=round((((int(varBinds[9][-1]) / 60) / 60) / 24), ROUND_PREC)
|
||||||
@@ -338,7 +349,7 @@ async def idracPoolRemote_v3(remoteIP: str, queueToInsrt: asyncio.Queue):
|
|||||||
"type": "snmpPyIDRACData"
|
"type": "snmpPyIDRACData"
|
||||||
}
|
}
|
||||||
# return returnObj
|
# return returnObj
|
||||||
queueToInsrt.put(returnDict)
|
await queueToInsrt.put(returnDict)
|
||||||
|
|
||||||
|
|
||||||
# IDRAC get FAN data
|
# IDRAC get FAN data
|
||||||
@@ -388,3 +399,5 @@ async def idracPoolRemoteFAN_v3(remoteIP: str, queueToInsrt: asyncio.Queue) -> d
|
|||||||
"value": out,
|
"value": out,
|
||||||
"type": "Dict"
|
"type": "Dict"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await queueToInsrt.put(returnDict)
|
||||||
31
cont/main.py
31
cont/main.py
@@ -9,8 +9,11 @@ from funct import *
|
|||||||
from classes import *
|
from classes import *
|
||||||
|
|
||||||
# Program ENV---------------------------------------
|
# Program ENV---------------------------------------
|
||||||
IDRAC_HOST_LIST: Final[list] = os.getenv("IDRAC_HOST_LIST").split(";")
|
try:
|
||||||
CISCO_HOST_LIST: Final[list] = os.getenv("CISCO_HOST_LIST").split(";")
|
IDRAC_HOST_LIST: Final[list] = os.getenv("IDRAC_HOST_LIST", None).split(";")
|
||||||
|
CISCO_HOST_LIST: Final[list] = os.getenv("CISCO_HOST_LIST", None).split(";")
|
||||||
|
except:
|
||||||
|
raise Exception("No IDRAC hosts variable")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -41,21 +44,24 @@ async def main():
|
|||||||
# idracQueue = asyncio.Queue()
|
# idracQueue = asyncio.Queue()
|
||||||
# ciscoQueue = asyncio.Queue()
|
# ciscoQueue = asyncio.Queue()
|
||||||
# fanQueue = asyncio.Queue()
|
# fanQueue = asyncio.Queue()
|
||||||
mainQueue(maxsize=225)
|
mainQueue = asyncio.Queue(maxsize=225)
|
||||||
|
|
||||||
|
asyncio.create_task(ALLdbWriter(mainQueue))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
tasks = []
|
|
||||||
# IDRAC part
|
# IDRAC part
|
||||||
async with asyncio.TaskGroup() as tg:
|
async with asyncio.TaskGroup() as tg:
|
||||||
for IdracIP in IDRAC_HOST_LIST:
|
for IdracIP in IDRAC_HOST_LIST:
|
||||||
tasks.append(tg.create_task(idracPoolRemote_v3(IdracIP, mainQueue)))
|
tg.create_task(idracPoolRemote_v3(IdracIP, mainQueue))
|
||||||
# tasks.append(tg.create_task(idracPoolRemoteFAN_v3(IdracIP, mainQueue)))
|
# FANS
|
||||||
|
# tg.create_task(idracPoolRemoteFAN_v3(IdracIP, mainQueue))
|
||||||
|
|
||||||
|
# CISCO devices
|
||||||
# for CiscoIP in CISCO_HOST_LIST:
|
# for CiscoIP in CISCO_HOST_LIST:
|
||||||
# tasks.append(tg.create_task(ciscoPoolRemote(CiscoIP, mainQueue)))
|
# tg.create_task(ciscoPoolRemote(CiscoIP, mainQueue))
|
||||||
|
|
||||||
sleep(20)
|
await asyncio.sleep(20)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -75,10 +81,13 @@ async def main():
|
|||||||
# print("End of code")
|
# print("End of code")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# qu = asyncio.Queue()
|
||||||
|
# asyncio.run(idracPoolRemote_v3("192.168.20.7", qu))
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
# loop = asyncio.get_event_loop()
|
||||||
task = loop.create_task(main())
|
# task = loop.create_task(main())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user