djmelik / archey

Archey is a system information tool written in Python.
http://github.com/djmelik/archey/blob/master/archey
Other
396 stars 120 forks source link

Encountered a bug #30

Open ManuelSchneid3r opened 9 years ago

ManuelSchneid3r commented 9 years ago
Traceback (most recent call last):
  File "/usr/bin/archey", line 261, in <module>
    out.append(classes[x]())
  File "/usr/bin/archey", line 215, in __init__
    used = int(ram[2]) - int(ram[5]) - int(ram[6])
IndexError: list index out of range

Used the version currently available in the AUR.

ghost commented 9 years ago

If you like I can help you fix that. Reply with the output to: free -m

ManuelSchneid3r commented 9 years ago
free -m
               gesamt       benutzt     frei      gemns.  Puffer/Cache verfügbar
Speicher:        6904        1827        1324         543        3752        4243
Swap:             0           0           0
ghost commented 9 years ago

\o/ yay! non English! lol I know Frei means free. Can you translate the other columns, please?

ManuelSchneid3r commented 9 years ago
free -m
              overall       used     free      shared.  Buffer/Cache available
mamory:        6904        1827        1324         543        3752        4243
Swap:             0           0           0
ghost commented 9 years ago

thanks: sudo nano /usr/bin/archey

at or near line 215:

find: used = int(ram[2]) - int(ram[5]) - int(ram[6])

place a # in front of the word "used"

used = int(ram[2]) - int(ram[5]) - int(ram[6])

This will comment the line and preserve it for later if you need to revert.

Under that line add: used = int(ram[2]) + int(ram[4])

It should look like:

used = int(ram[2]) - int(ram[5]) - int(ram[6])

used = int(ram[2]) + int(ram[4])

ctrl+x to save and hit enter without changing the name of the file.

It should be fixed.

Mausy5043 commented 8 years ago

wouldn't it be easier to parse /proc/meminfo?

"Here's one I prepared earlier." :

  out = cat("/proc/meminfo").splitlines()
  for line in range(0, len(out)-1):
    mem = out[line].split()
    if mem[0] == 'MemFree:':
      outMemFree = int(mem[1])
    elif mem[0] == 'MemTotal:':
      outMemTotal = int(mem[1])
    elif mem[0] == 'Buffers:':
      outMemBuf = int(mem[1])
    elif mem[0] == 'Cached:':
      outMemCache = int(mem[1])
    elif mem[0] == 'SwapTotal:':
      outMemSwapTotal = int(mem[1])
    elif mem[0] == "SwapFree:":
      outMemSwapFree = int(mem[1])

  outMemUsed = outMemTotal - (outMemFree + outMemBuf + outMemCache)
  outMemSwapUsed = outMemSwapTotal - outMemSwapFree