如何从 Vscsistats 获取实时 scsi 跟踪?

如何从 Vscsistats 获取实时 scsi 跟踪?

以下是我已经知道的事情,使用vscsistat -t选项我可以在 ESxi 上获取“VM/.vmdk”的命令跟踪。

获取 scsi 跟踪的步骤如下:

  1. 开始捕获跟踪,成功启动后会生成log_channel(id)

    vscsiStats -s -t -w worldgroupid -i handleid
    
  2. 将跟踪信息以二进制格式转储到文件中

    logchannelloger channelname filename
    
  3. 从跟踪文件中获取人类可读的格式。

    vscsistats -e filename
    

通过这些步骤,每次我启动命令vscsistats -e filename从跟踪文件中获取以人类可读格式的 scsitrace 时,它​​都会返回从开始到触发命令为止的跟踪数据。

如果我在 10 分钟后发出命令,那么它会再次返回从开始到发出命令时间的轨迹。

所以问题是,是否有任何方法可以将跟踪信息转储到二进制文件中,并直接将其转储到 stdout,就像tail -fblktrace -o - |blkparse -i -Linux 上一样?

答案1

它不是这样设计的:

  VscsiStats -- This tool controls vscsi data collection for virtual machine disk
                disk I/O workload characterization. Users can start and stop online data
                data collection for particular VMs as well as print out online histogram data.
                Command traces can also be collected and printed.

  The following histogram related options are available:
     -h, --help will print the usage
     -l, --list will list the available virtual machines and their virtual disks
     -r, --reset will reset the stats
     -s, --start will start vscsiStats collection; exclusive of -x
     -x, --stop will stop vscsiStats collection; exclusive of -s
     -w <worldgroup id>, --worldgroupid specifies a worldID to use for this operation
     -i <handle id>, --handleid specifies a vscsi handleID to use for this operation
           requires the -w option
     -p <histoType>, --printhistos will print out the current histograms for the specified
            histogram type. May be used in conjunction with -w and -i.
            histoType must be one and only one of:
                 all, ioLength, seekDistance, outstandingIOs, latency, interarrival
     -c, --csv will use comma as delimiter in conjunction with -p

  The following command trace related options are available:
     -t, --tracecmds will start scsi cmd traces; in conjunction with -s
         Note:- the -t option consumes significant system resources so
                enabling it indefinitely is not advisable
              - try to limit the #virtual disk for which cmd tracing is enabled at any
                given time by using --worldgroupid and/or --handleid options.
              - trace contains NO customer sensitive data
                - only information recorded is:
                  - serialnumber, IO block size, number of scatter-gather elements
                  - command type, block number, timestamp
                - Therefore, actual data/payload of commands is not stored
              - If successfully started, log channel id(s) will be printed out.
                To store the command trace in a file for later processing, invoke:
                $ logchannellogger <log_channel_id> <binary_trace_file>
     -e <trace file name>, --traceprettyprint reads in a vscsi cmd trace from the given
        filename and sends a CSV formatted output to stdout; exclusive of all other options

  vscsiStats Usage:
         vscsiStats [options]

您可以启动watch -n 1 cat <file>另一个 shell 来刷新文件内容。如果您不想手动启动命令,可以批量执行它们并将它们添加到 cron。

顺便说一下,要小心,每次重启时,esxi 中的某些文件都会被重置。

这里介绍将脚本添加到 cron 而不在每次启动时重置的方法:

  • 编辑文件/etc/rc.local.d/local.sh

      #add to crontab a task
      echo "01 00 1,15 * * root /vmfs/volumes/datastore1/script/yourscript.sh" >> /var/spool/cron/crontabs/root
      #stop crontab process
      kill $(cat /var/run/crond.pid)
      #start crontab process
      crond
    

不要忘记将脚本设置为可执行文件

chmod +x /vmfs/volumes/datastore1/script/yourscript.sh

相关内容