@@ -1591,6 +1591,9 @@ def isPeriodTimerRunning():
1591
1591
K_RPI_DRV_NFS = "device-nfs"
1592
1592
K_RPI_DVC_IP = "ip"
1593
1593
K_RPI_DVC_PATH = "dvc"
1594
+ # new block devices dictionary
1595
+ K_RPI_BLK_DEVICES = "block_devices"
1596
+ K_RPI_BLK_DEV_TEMP = "temperature_c"
1594
1597
# new memory dictionary
1595
1598
K_RPI_MEMORY = "memory"
1596
1599
K_RPI_MEM_TOTAL = "size_mb"
@@ -1647,6 +1650,10 @@ def send_status(timestamp, nothing):
1647
1650
1648
1651
rpiData [K_RPI_NETWORK ] = getNetworkDictionary ()
1649
1652
1653
+ rpiBlockDevices = getBlockDevicesDictionary ()
1654
+ if len (rpiBlockDevices ) > 0 :
1655
+ rpiData [K_RPI_BLK_DEVICES ] = rpiBlockDevices
1656
+
1650
1657
rpiDrives = getDrivesDictionary ()
1651
1658
if len (rpiDrives ) > 0 :
1652
1659
rpiData [K_RPI_DRIVES ] = rpiDrives
@@ -1685,10 +1692,25 @@ def forceSingleDigit(temperature):
1685
1692
tempInterp = '{:.1f}' .format (temperature )
1686
1693
return float (tempInterp )
1687
1694
1695
+ def getBlockDevicesDictionary ():
1696
+ rpiDevices = OrderedDict ()
1697
+
1698
+ smartctlHelper = os .path .join (os .path .dirname (__file__ ), 'smartctl-helper' )
1699
+ stdout , stderr , returncode = invoke_shell_cmd ("sudo " + smartctlHelper )
1700
+ if returncode != 0 :
1701
+ print_line ('Could not query SMART data: {}' .format (stderr ), warning = True )
1702
+ return rpiDevices
1703
+
1704
+ for device in stdout .decode ('utf-8' ).splitlines ():
1705
+ [ name , temp ] = device .split (':' )
1706
+ if len (temp ) > 0 :
1707
+ rpiDevices [name ] = { K_RPI_BLK_DEV_TEMP : float (temp ) }
1708
+ return rpiDevices
1688
1709
1689
1710
def getDrivesDictionary ():
1690
1711
global rpi_filesystem
1691
1712
rpiDrives = OrderedDict ()
1713
+
1692
1714
1693
1715
# tuple { total blocks, used%, mountPoint, device }
1694
1716
for driveTuple in rpi_filesystem :
0 commit comments