Score:1

How to write pidstat output to a sadc file for analysis later (sar)

cn flag

How can I write the output of pidstat to a file for analysis later?

In sar, you can monitor usage and write-out to a file for later analysis using the -o argument. From the man page:

       If multiple samples and multiple reports are desired, it is convenient to specify an output file for the sar command.  Run the sar command as  a
       background process. The syntax for this is:

       sar -o datafile interval count >/dev/null 2>&1 &

       All  data are captured in binary form and saved to a file (datafile).  The data can then be selectively displayed with the sar command using the
       -f option. Set the interval and count parameters to select count records at interval second intervals. If the count parameter is  not  set,  all
       the  records saved in the file will be selected.  Collection of data in this manner is useful to characterize system usage over a period of time
       and determine peak usage hours.
...
       -o [ filename ]
              Save the readings in the file in binary form. Each reading is in a separate record. The default value of the filename  parameter  is  the
              current  daily data file, the /var/log/sa/sadd file. The -o option is exclusive of the -f option.  All the data available from the kernel
              are saved in the file (in fact, sar calls its data collector sadc with the option "-S ALL". See sadc(8) manual page).

I need to monitor the resource usage of a specific process by name. The equivalent tool for this is pidstat. Sadly, pidstat has no -o argument

[root@host ~]# pidstat -o pidstat.sadc -C "nginx" 1
Usage: pidstat [ options ] [ <interval> [ <count> ] ]
Options are:
[ -d ] [ -h ] [ -I ] [ -l ] [ -r ] [ -s ] [ -t ] [ -U [ <username> ] ] [ -u ]
[ -V ] [ -w ] [ -C <command> ] [ -p { <pid> [,...] | SELF | ALL } ]
[ -T { TASK | CHILD | ALL } ]
[root@host ~]# 

How can I tell pidstat to output to a file in sadc format so that it can be analyzed later with tools like kSAR?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.