Page 1 of 1

plot/statistics of the processor

Posted: Tue Mar 31, 2020 6:48 pm
by nick8967
Hello, How can I get a plot of the performance of the processor of raspberry pi over the time? I want to export the data to a .csv file so that I can process the data...

Re: plot/statistics of the processor

Posted: Tue Mar 31, 2020 8:15 pm
by jamesh
What performance data are you looking for? CPU frequency? Temperature? There are various projects around the place to log those.

Re: plot/statistics of the processor

Posted: Tue Mar 31, 2020 8:28 pm
by nick8967
(CPU load/core, RAM load, frequency, Power consumption) / time

Re: plot/statistics of the processor

Posted: Wed Apr 01, 2020 12:03 am
by jahboater
nick8967 wrote:
Tue Mar 31, 2020 8:28 pm
(CPU load/core, RAM load, frequency, Power consumption) / time
Take a look at vmstat (see "man vmstat" for info).
Try "vmstat 10 10" for example.
vmstat is included with Raspbian.

"dstat" looks nicer but you must install it with "sudo apt install dstat"
Then just type "dstat". dstat includes network traffic and looks very good.

"iostat" ("sudo apt install sysstat") provides lots of info about disks

"nicstat" (sudo apt install nicstat) provides info about the network interfaces

"ifstat" also about network interfaces

All of these can collect statistics at your choice of interval into a log.

Finally, see this little script for CPU speeds/temps/voltages/throttling:

Code: Select all

#!/bin/bash
Counter=14
DisplayHeader="Time       Temp     CPU     Core         Health           Vcore"
while true ; do
  let ++Counter
  if [ ${Counter} -eq 15 ]; then
    echo -e "${DisplayHeader}"
    Counter=0
  fi
  Health=$(perl -e "printf \"%19b\n\", $(vcgencmd get_throttled | cut -f2 -d=)")
  Temp=$(vcgencmd measure_temp | cut -f2 -d=)
  Clockspeed=$(vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
  Corespeed=$(vcgencmd measure_clock core | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
  CoreVolt=$(vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
  echo -e "$(date '+%H:%M:%S')  ${Temp}  $(printf '%4s' ${Clockspeed})MHz $(printf '%4s' ${Corespeed})MHz  $(printf '%020u' ${Health})  ${CoreVolt}"
  sleep 10
done
modify it to suit your requirements.

There used to be something called "sar" (System Activity Reporter) but it doesn't seem to be in the Raspbian repos.

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 6:24 pm
by nick8967
Does the above code run, or I am doing something wrong?

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 6:53 pm
by jahboater
nick8967 wrote:
Wed Jul 08, 2020 6:24 pm
Does the above code run, or I am doing something wrong?
Of course it runs!

Copy it to a file, say "pistat" but you may call it anything.
Then type:

chmod +x pistat

Then type:

./pistat

and it will run. You should perhaps place it on the PATH to avoid the ./ prefix.
Alter the "sleep 10" at the end to change the poll frequency.

Note you can easily add the PMIC temperature using this:

vcgencmd measure_temp pmic

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 6:57 pm
by cleverca22
there are also some metrics that linux cant scrape on its own

SD_IDL/SD_CYC are used on VC4 (rpi0 to rpi3) to measure how busy the dram controller is

would that be another metric you would want to measure?
can the current firmware help with reporting the numbers? they overflow rather quickly

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 7:03 pm
by jdb

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 7:16 pm
by cleverca22
jdb wrote:
Wed Jul 08, 2020 7:03 pm
You want bcmstat.

https://github.com/MilhouseVH/bcmstat
nice!, its even showing gpu mem, so you can tell if you have too much or too little gpu_mem=!

but i dont think i see any support for dram bandwidth via the 2 registers i named, not sure if start.elf can expose those counts to linux

there is also axi performance counters that can reveal if one peripheral is hogging the bus

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 8:09 pm
by nick8967
Do they export to log files? csv? txt? something?

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 10:07 pm
by jahboater
nick8967 wrote:
Wed Jul 08, 2020 8:09 pm
Do they export to log files? csv? txt? something?
bcmstat looks like a shell script, as is the script I showed above.
Should be trivial to save the output to a file in any desired format.

Re: plot/statistics of the processor

Posted: Wed Jul 08, 2020 10:24 pm
by DougieLawson
jahboater wrote:
Wed Jul 08, 2020 10:07 pm
bcmstat looks like a shell script, as is the script I showed above.
Should be trivial to save the output to a file in any desired format.
Not sure why it's called bcmstat.sh as it's a python program. Being python should make writing output as CSV even easier.

Re: plot/statistics of the processor

Posted: Thu Jul 09, 2020 2:36 am
by jahboater
These scripts write to the screen and therefore the number of columns is limited by the screen/window columns.

Writing to a CSV file allows all the known information to be placed on each line.