Compare commits
4 Commits
faf343b176
...
e06eea68cd
| Author | SHA1 | Date | |
|---|---|---|---|
| e06eea68cd | |||
| c9d07e7cef | |||
| 10d14a06db | |||
| 78d240a1fc |
@@ -71,28 +71,33 @@ async def idrac7_8PoolRemote_v3(remoteIP: str, queueToInsrt: asyncio.Queue):
|
|||||||
for oid, val in mainVarBinds:
|
for oid, val in mainVarBinds:
|
||||||
print(f"{oid.prettyPrint()} = {val.prettyPrint()}")
|
print(f"{oid.prettyPrint()} = {val.prettyPrint()}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Get PSU1 current, [PSU2 current], total board power draw in watts
|
||||||
|
currentsCurrentResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.6")
|
||||||
|
# PSU1 OID name, [PSU2 OID name], system board power draw
|
||||||
|
currentsNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.8")
|
||||||
|
|
||||||
# Get PSU1 current, [PSU2 current], total board power draw in watts
|
# Inlet OID name .1, [Exhaust OID name], CPU1 temp OID name, [CPU2 tempOID name]
|
||||||
currentsCurrentResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.6")
|
sensorNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.8")
|
||||||
# PSU1 OID name, [PSU2 OID name], system board power draw
|
# Inlet temp, [Exhaust temp], CPU1 temp, [CPU2 temp]
|
||||||
currentsNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.8")
|
sensorValuesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.6")
|
||||||
|
|
||||||
# Inlet OID name .1, [Exhaust OID name], CPU1 temp OID name, [CPU2 tempOID name]
|
# .1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1
|
||||||
sensorNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.8")
|
voltResult = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1")
|
||||||
# Inlet temp, [Exhaust temp], CPU1 temp, [CPU2 temp]
|
|
||||||
sensorValuesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.6")
|
|
||||||
|
|
||||||
# .1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1
|
hasExhaust = any("exhaust" in str(thing).lower() for thing in sensorNamesResults.values())
|
||||||
voltResult = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1")
|
hasCPU2 = any("cpu2" in str(thing).lower() for thing in sensorNamesResults.values())
|
||||||
|
hasPSU2 = any("ps2" in str(thing).lower() for thing in currentsNamesResults.values())
|
||||||
|
|
||||||
hasExhaust = any("exhaust" in str(thing).lower() for thing in sensorNamesResults.values())
|
except SNMPTimeoutError as e:
|
||||||
hasCPU2 = any("cpu2" in str(thing).lower() for thing in sensorNamesResults.values())
|
print(f"{e}\nContinuing regardless...")
|
||||||
hasPSU2 = any("ps2" in str(thing).lower() for thing in currentsNamesResults.values())
|
return 1
|
||||||
|
except RuntimeError as e:
|
||||||
|
print(f"SNMP error on {remoteIP}: {e}")
|
||||||
|
return 1
|
||||||
|
|
||||||
snmpEngine.close_dispatcher()
|
snmpEngine.close_dispatcher()
|
||||||
|
|
||||||
print(voltResult)
|
|
||||||
|
|
||||||
# Exhaust CPU1 and CPU2 temp
|
# Exhaust CPU1 and CPU2 temp
|
||||||
|
|
||||||
exhaustTemp = None
|
exhaustTemp = None
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import os, asyncio
|
import os, asyncio
|
||||||
|
|
||||||
from models.idracModel import snmpPyIDRACData
|
from models.idracModel import snmpPyIDRACData
|
||||||
|
from models.snmpTimeOut import SNMPTimeoutError
|
||||||
|
|
||||||
from snmp.walker import walk_column_v3
|
from snmp.walker import walk_column_v3
|
||||||
|
|
||||||
from typing import Annotated, Final
|
from typing import Annotated, Final
|
||||||
|
|
||||||
# SNMP
|
# SNMP
|
||||||
@@ -56,6 +60,10 @@ async def idrac9PoolRemote_v3(remoteIP: str, queueToInsrt: asyncio.Queue):
|
|||||||
errorIndication, errorStatus, errorIndex, mainVarBinds = await iterator
|
errorIndication, errorStatus, errorIndex, mainVarBinds = await iterator
|
||||||
|
|
||||||
if errorIndication:
|
if errorIndication:
|
||||||
|
if errorIndication == "No SNMP response received before timeout":
|
||||||
|
print(f"Host {remoteIP} timed out.\nContinuing...")
|
||||||
|
snmpEngine.close_dispatcher()
|
||||||
|
return 1
|
||||||
print(errorIndication)
|
print(errorIndication)
|
||||||
elif errorStatus:
|
elif errorStatus:
|
||||||
print(
|
print(
|
||||||
@@ -69,22 +77,30 @@ async def idrac9PoolRemote_v3(remoteIP: str, queueToInsrt: asyncio.Queue):
|
|||||||
print(f"{oid.prettyPrint()} = {val.prettyPrint()}")
|
print(f"{oid.prettyPrint()} = {val.prettyPrint()}")
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
# Get PSU1 current, [PSU2 current], total board power draw in watts
|
# Get PSU1 current, [PSU2 current], total board power draw in watts
|
||||||
currentsCurrentResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.6")
|
currentsCurrentResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.6")
|
||||||
# PSU1 OID name, [PSU2 OID name], system board power draw
|
# PSU1 OID name, [PSU2 OID name], system board power draw
|
||||||
currentsNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.8")
|
currentsNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.30.1.8")
|
||||||
|
|
||||||
# CPU1 OID name .1, [CPU2 OID name], Inlet temp OID name, [Exhaust temp OID name]
|
# CPU1 OID name .1, [CPU2 OID name], Inlet temp OID name, [Exhaust temp OID name]
|
||||||
sensorNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.8")
|
sensorNamesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.8")
|
||||||
# CPU1 temp, [CPU2 temp], Inlet temp, [Exhaust temp]
|
# CPU1 temp, [CPU2 temp], Inlet temp, [Exhaust temp]
|
||||||
sensorValuesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.6")
|
sensorValuesResults = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.700.20.1.6")
|
||||||
|
|
||||||
# .1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1
|
# .1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1
|
||||||
voltResult = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1")
|
voltResult = await walk_column_v3(snmpEngine, remoteIP, ".1.3.6.1.4.1.674.10892.5.4.600.20.1.6.1")
|
||||||
|
except SNMPTimeoutError as e:
|
||||||
|
print(f"{e}\nContinuing regardless...")
|
||||||
|
return 1
|
||||||
|
except RuntimeError as e:
|
||||||
|
print(f"SNMP error on {remoteIP}: {e}")
|
||||||
|
return 1
|
||||||
|
|
||||||
snmpEngine.close_dispatcher()
|
snmpEngine.close_dispatcher()
|
||||||
|
|
||||||
|
|
||||||
hasExhaust = any("exhaust" in str(thing).lower() for thing in sensorNamesResults.values())
|
hasExhaust = any("exhaust" in str(thing).lower() for thing in sensorNamesResults.values())
|
||||||
hasCPU2 = any("cpu2" in str(thing).lower() for thing in sensorNamesResults.values())
|
hasCPU2 = any("cpu2" in str(thing).lower() for thing in sensorNamesResults.values())
|
||||||
hasPSU2 = any("ps2" in str(thing).lower() for thing in currentsNamesResults.values())
|
hasPSU2 = any("ps2" in str(thing).lower() for thing in currentsNamesResults.values())
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ try:
|
|||||||
except:
|
except:
|
||||||
raise Exception("No IDRAC hosts variable")
|
raise Exception("No IDRAC hosts variable")
|
||||||
|
|
||||||
|
GET_INTERVAL: Final[int] = int(os.getenv("GET_INTERVAL", 60))
|
||||||
|
|
||||||
|
|
||||||
# Flightchecks-------------------------------------------
|
# Flightchecks-------------------------------------------
|
||||||
@@ -71,7 +72,7 @@ async def main():
|
|||||||
# for CiscoIP in CISCO_HOST_LIST:
|
# for CiscoIP in CISCO_HOST_LIST:
|
||||||
# tg.create_task(ciscoPoolRemote(CiscoIP, mainQueue))
|
# tg.create_task(ciscoPoolRemote(CiscoIP, mainQueue))
|
||||||
|
|
||||||
await asyncio.sleep(20)
|
await asyncio.sleep(GET_INTERVAL)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
cont/models/snmpTimeOut.py
Normal file
2
cont/models/snmpTimeOut.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
class SNMPTimeoutError(Exception):
|
||||||
|
pass
|
||||||
@@ -2,6 +2,7 @@ import asyncio, os
|
|||||||
from typing import Annotated, Final
|
from typing import Annotated, Final
|
||||||
# SNMP
|
# SNMP
|
||||||
from pysnmp.hlapi.v3arch.asyncio import *
|
from pysnmp.hlapi.v3arch.asyncio import *
|
||||||
|
from models.snmpTimeOut import SNMPTimeoutError
|
||||||
# SNMP ENV-------------------------------------------
|
# SNMP ENV-------------------------------------------
|
||||||
ROUND_PREC: Final[int] = int(os.getenv("ROUND_PREC", 2))
|
ROUND_PREC: Final[int] = int(os.getenv("ROUND_PREC", 2))
|
||||||
|
|
||||||
@@ -53,6 +54,9 @@ async def walk_column_v3(snmpEngine, remoteIP: str, base_oid: str) -> dict:
|
|||||||
lexicographicMode=False,
|
lexicographicMode=False,
|
||||||
):
|
):
|
||||||
if errInd:
|
if errInd:
|
||||||
|
print(f"\n\n{errInd}\n\n")
|
||||||
|
if "No SNMP response received before timeout" in str(errInd):
|
||||||
|
raise SNMPTimeoutError(f"Host {remoteIP} timed out while walking {base_oid}")
|
||||||
raise RuntimeError(errInd)
|
raise RuntimeError(errInd)
|
||||||
if errStat:
|
if errStat:
|
||||||
raise RuntimeError(errStat.prettyPrint())
|
raise RuntimeError(errStat.prettyPrint())
|
||||||
|
|||||||
Reference in New Issue
Block a user