Read and parse perf.data

混江龙づ霸主 提交于 2020-01-13 02:47:37

问题


I am recording a performance counters frm linux using the command perf record.

I want to use the result perf.data as an input to other programming apps. Do you know how shall I read and parse the data in perf.data? Is there a way to transform it to .text file or .csv?


回答1:


An example command definition that redirects service check performance data to a text file for later processing by another application is shown below:

define command{

    command_name    store-service-perfdata

    command_line    /bin/echo -e "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$" >> /usr/local/nagios/var/service-perfdata.dat

    }



回答2:


There is builtin perf.data parser and printer in perf tool of linux tools with subcommand "script".

To convert perf.data file

perf script > perf.data.txt

To convert output of perf record in other file (perf record -o filename.data) use -i option:

perf script -i filename.data > filename.data.txt

perf script is documented at man perf-script, available online at http://man7.org/linux/man-pages/man1/perf-script.1.html

   perf-script - Read perf.data (created by perf record) and display
   trace output

   This command reads the input file and displays the trace recorded.

       'perf script' to see a detailed trace of the workload that was
       recorded.


来源:https://stackoverflow.com/questions/11921842/read-and-parse-perf-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!