MCPcopy Create free account
hub / github.com/apache/impala / _memory

Function _memory

docker/monitor.py:60–83  ·  view source on GitHub ↗

Returns (total, used) memory on system, in GB. Used is computed as total - available. Calls "free" and parses output. Sample output for reference: total used free shared buffers cache available Mem: 126747197440 26363965440 56618553344 31

()

Source from the content-addressed store, hash-verified

58
59
60def _memory():
61 """Returns (total, used) memory on system, in GB.
62
63 Used is computed as total - available.
64
65 Calls "free" and parses output. Sample output for reference:
66
67 total used free shared buffers cache available
68 Mem: 126747197440 26363965440 56618553344 31678464 2091614208 41673064448 99384889344
69 Swap: 0 0 0
70 """
71
72 free_lines = subprocess.check_output(["free", "-b", "-w"],
73 universal_newlines=True).split('\n')
74 free_grid = [x.split() for x in free_lines]
75 # Identify columns for "total" and "available"
76 total_idx = free_grid[0].index("total")
77 available_idx = free_grid[0].index("available")
78 total = int(free_grid[1][1 + total_idx])
79 available = int(free_grid[1][1 + available_idx])
80 used = total - available
81 total_gb = total / (1024.0 * 1024.0 * 1024.0)
82 used_gb = used / (1024.0 * 1024.0 * 1024.0)
83 return (total_gb, used_gb)
84
85
86def datetime_to_seconds_since_epoch(dt):

Callers 2

total_memoryFunction · 0.85
used_memoryFunction · 0.85

Calls 1

indexMethod · 0.45

Tested by

no test coverage detected