def free_physmem():
    """Parse 'free' cmd and return physical memory's total, used
    and free values.
    """
    # Note: free can have 2 different formats, invalidating 'shared'
    # and 'cached' memory which may have different positions so we
    # do not return them.
    # https://github.com/giampaolo/psutil/issues/538#issuecomment-57059946
    lines = sh('free').split('\n')
    for line in lines:
        if line.startswith('Mem'):
            total, used, free, shared = \
                [int(x) * 1024 for x in line.split()[1:5]]
            return (total, used, free, shared)
    raise ValueError(
        "can't find 'Mem' in 'free' output:\n%s" % '\n'.join(lines))


# =====================================================================
# system virtual memory
# =====================================================================
dataset/ETHPy150Open giampaolo/psutil/psutil/tests/test_linux.py/free_physmem/original