def mpstat()

in perfrunbook/utilities/measure_and_plot_basic_sysstat_stats.py [0:0]


def mpstat(time):
    """
    Measure mpstat into a buffer for parsing
    """
    try:
        env = dict(os.environ, S_TIME_FORMAT="ISO", LC_TIME="ISO")
        res = subprocess.run(["mpstat", "-I", "ALL", "-o", "JSON", "1", f"{time}"], timeout=time+5, env=env,
                              check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        return io.StringIO(res.stdout.decode('utf-8'))
    except subprocess.CalledProcessError:
        print("Failed to measure statistics with mpstat")
        print("Please check that sar is installed using install_perfrunbook_dependencies.sh and is in your PATH")