add a warning when running dangerously old Linux kernels
This commit is contained in:
parent
ebc54aa7c1
commit
d37e481acb
1 changed files with 18 additions and 8 deletions
|
@ -38,6 +38,8 @@ COLOR_GIT_STAGED = 10
|
|||
COLOR_PROMPT_OK = 14
|
||||
COLOR_PROMPT_ERROR = 1
|
||||
|
||||
COLOR_ERROR = 196
|
||||
|
||||
MOUNT_IGNORE_FS = ["iso9660", "tmpfs"]
|
||||
MOUNT_IGNORE_DIR = ["/dev", "/proc", "/sys"]
|
||||
|
||||
|
@ -430,25 +432,33 @@ class StatsPart(Part):
|
|||
swap_total = 0
|
||||
swap_free = 0
|
||||
|
||||
# MemAvailable is not available on <linux-3.14 and we'll bitch about that
|
||||
old_linux = True
|
||||
|
||||
with open("/proc/meminfo") as f:
|
||||
for line in f:
|
||||
if line.startswith("MemTotal"):
|
||||
mem_total = int(line.split()[1]) * 1024
|
||||
elif line.startswith("MemFree"): # MemAvailable is not available on some systems, but folllows MemFree
|
||||
mem_free = int(line.split()[1]) * 1024
|
||||
elif line.startswith("MemAvailable"):
|
||||
mem_free = int(line.split()[1]) * 1024
|
||||
old_linux = False
|
||||
elif line.startswith("SwapTotal"):
|
||||
swap_total = int(line.split()[1]) * 1024
|
||||
elif line.startswith("SwapFree"):
|
||||
swap_free = int(line.split()[1]) * 1024
|
||||
|
||||
if old_linux or True:
|
||||
self.fragments.append(style_color(COLOR_ERROR))
|
||||
self.fragments.append(style_bold())
|
||||
self.fragments.append("❌ <linux-3.14 ❌")
|
||||
else:
|
||||
self.fragments.append(style_color(COLOR_MEMSWAP))
|
||||
self.fragments.append("m")
|
||||
self.fragments.append(style_bold())
|
||||
self.fragments.append(style_color(settings.get_space_color(mem_free, mem_total)))
|
||||
mem_free_si = si_number(mem_free)
|
||||
self.fragments.append(space_string(mem_free) %(mem_free_si[0], mem_free_si[1]))
|
||||
|
||||
self.fragments.append(style_reset())
|
||||
|
||||
if swap_total - swap_free > 2**20:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue