Skip to content

Commit

Permalink
Fix LibreHardwareMonitor computation for swap/pagefile usage in case …
Browse files Browse the repository at this point in the history
…no swap/pagefile defined
  • Loading branch information
mathoudebine committed Nov 12, 2023
1 parent d44505f commit dfa5573
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/sensors/sensors_librehardwaremonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,13 @@ def swap_percent() -> float:
swap_used = virtual_mem_used - mem_used
swap_available = virtual_mem_available - mem_available
swap_total = swap_used + swap_available
try:
percent_swap = swap_used / swap_total * 100.0
except:
# No swap / pagefile disabled
percent_swap = 0.0

return swap_used / swap_total * 100.0
return percent_swap

@staticmethod
def virtual_percent() -> float:
Expand Down

0 comments on commit dfa5573

Please sign in to comment.