def _StartOnVm(self, vm, suffix='-dstat'):
    vm.Install('dstat')

    num_cpus = vm.num_cpus

    # List block devices so that I/O to each block device can be recorded.
    block_devices, _ = vm.RemoteCommand(
        'lsblk --nodeps --output NAME --noheadings')
    block_devices = block_devices.splitlines()
    dstat_file = posixpath.join(
        vm_util.VM_TMP_DIR, '{0}{1}.csv'.format(vm.name, suffix))
    cmd = ('dstat --epoch -C total,0-{max_cpu} '
           '-D total,{block_devices} '
           '-clrdngyi -pms --fs --ipc --tcp '
           '--udp --raw --socket --unix --vm --rpc '
           '--noheaders --output {output} {dstat_interval} > /dev/null 2>&1 & '
           'echo $!').format(
               max_cpu=num_cpus - 1,
               block_devices=','.join(block_devices),
               output=dstat_file,
               dstat_interval=self.interval or '')
    stdout, _ = vm.RemoteCommand(cmd)
    with self._lock:
      self._pids[vm.name] = stdout.strip()
      self._file_names[vm.name] = dstat_file
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/traces/dstat.py/_DStatCollector._StartOnVm/original