Skip to content

Commit

Permalink
Merge pull request #2925 from freenas/NAS-101306
Browse files Browse the repository at this point in the history
NAS-101306 / 11.3 / Fix running disktemp.py standalone
  • Loading branch information
themylogin committed Apr 22, 2019
2 parents 81abaa5 + 51a420c commit 9d4c656
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/freenas/usr/local/lib/collectd_pyplugins/disktemp.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, *args, **kwargs):
self.values = None
self.meta = None

def dispatch(self):
def dispatch(self, **kwargs):
print(f'{self.plugin}:{self.plugin_instance}:{self.type}:{self.type_instance}:{self.values}')

collectd = CollectdDummy()
Expand All @@ -93,6 +93,9 @@ def get_temperature(stdout):
>>> get_temperature("194 Temperature_Internal 0x0022 100 100 000 Old_age Always - 26\\n"\
"190 Temperature_Case 0x0022 100 100 000 Old_age Always - 27")
26
>>> get_temperature(" 7 Seek_Error_Rate 0x000f 081 060 030 Pre-fail Always - 126511909\\n"\
"190 Airflow_Temperature_Cel 0x0022 062 053 045 Old_age Always - 38 (Min/Max 27/40)")
38
>>> get_temperature("Temperature: 40 Celsius")
40
Expand All @@ -106,9 +109,12 @@ def get_temperature(stdout):
# ataprint.cpp

data = {}
for s in re.findall(r'((190|194)[^\n]*)', stdout, re.M):
for s in re.findall(r'^((190|194) .+)', stdout, re.M):
s = s[0].split()
data[s[1]] = int(s[9])
try:
data[s[1]] = int(s[9])
except (IndexError, ValueError):
pass
for k in ['Temperature_Celsius', 'Temperature_Internal', 'Drive_Temperature',
'Temperature_Case', 'Case_Temperature', 'Airflow_Temperature_Cel']:
if k in data:
Expand Down

0 comments on commit 9d4c656

Please sign in to comment.