Skip to content

Commit

Permalink
Just report MemAvailable as usable if it's in meminfo.
Browse files Browse the repository at this point in the history
Typo.

Typo.
  • Loading branch information
truthbk committed Oct 23, 2015
1 parent 7262df0 commit a0efe9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 0 additions & 4 deletions checks/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ def run(self, checksd=None, start_event=True):
'memBuffers': memory.get('physBuffers'),
'memShared': memory.get('physShared')
}
if 'physAvailable' in memory:
memstats['memPhysAvailable'] = memory.get('physAvailable'),
if 'physPctAvailable' in memory:
memstats['memPhysPctAvailable'] = memory.get('physPctAvailable'),
payload.update(memstats)

ioStats = sys_checks['io'].check(self.agentConfig)
Expand Down
11 changes: 5 additions & 6 deletions checks/system/unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def check(self, agentConfig):
# cols[0] is the device
# cols[1:] are the values
io[cols[0]] = {}
for i in range(2, len(cols)):
for i in range(1, len(cols)):
io[cols[0]][self.xlate(headers[i], "sunos")] = cols[i]

elif sys.platform.startswith("freebsd"):
Expand Down Expand Up @@ -366,20 +366,19 @@ def check(self, agentConfig):
memData['physTotal'] = int(meminfo.get('MemTotal', 0)) / 1024
memData['physFree'] = int(meminfo.get('MemFree', 0)) / 1024
if 'MemAvailable' in meminfo:
memData['physAvailable'] = int(meminfo.get('MemAvailable', 0)) / 1024
memData['physUsable'] = int(meminfo.get('MemAvailable', 0)) / 1024
else:
# Usable is relative since cached and buffers are actually used to speed things up.
memData['physUsable'] = memData['physFree'] + memData['physBuffers'] + memData['physCached']

memData['physBuffers'] = int(meminfo.get('Buffers', 0)) / 1024
memData['physCached'] = int(meminfo.get('Cached', 0)) / 1024
memData['physShared'] = int(meminfo.get('Shmem', 0)) / 1024

memData['physUsed'] = memData['physTotal'] - memData['physFree']
# Usable is relative since cached and buffers are actually used to speed things up.
memData['physUsable'] = memData['physFree'] + memData['physBuffers'] + memData['physCached']

if memData['physTotal'] > 0:
memData['physPctUsable'] = float(memData['physUsable']) / float(memData['physTotal'])
if 'physAvailable' in memData:
memData['physPctAvailable'] = float(memData['physAvailable']) / float(memData['physTotal'])
except Exception:
self.logger.exception('Cannot compute stats from /proc/meminfo')

Expand Down

0 comments on commit a0efe9a

Please sign in to comment.