nick8967
Posts: 155
Joined: Fri Mar 25, 2016 11:02 pm

plot/statistics of the processor

Tue Mar 31, 2020 6:48 pm

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...

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26442
Joined: Sat Jul 30, 2011 7:41 pm

Re: plot/statistics of the processor

Tue Mar 31, 2020 8:15 pm

What performance data are you looking for? CPU frequency? Temperature? There are various projects around the place to log those.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

nick8967
Posts: 155
Joined: Fri Mar 25, 2016 11:02 pm

Re: plot/statistics of the processor

Tue Mar 31, 2020 8:28 pm

(CPU load/core, RAM load, frequency, Power consumption) / time

jahboater
Posts: 5680
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: plot/statistics of the processor

Wed Apr 01, 2020 12:03 am

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.
Pi4 8GB running PIOS64

nick8967
Posts: 155
Joined: Fri Mar 25, 2016 11:02 pm

Re: plot/statistics of the processor

Wed Jul 08, 2020 6:24 pm

Does the above code run, or I am doing something wrong?

jahboater
Posts: 5680
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: plot/statistics of the processor

Wed Jul 08, 2020 6:53 pm

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
Pi4 8GB running PIOS64

cleverca22
Posts: 581
Joined: Sat Aug 18, 2012 2:33 pm

Re: plot/statistics of the processor

Wed Jul 08, 2020 6:57 pm

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

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2351
Joined: Thu Jul 11, 2013 2:37 pm

Re: plot/statistics of the processor

Wed Jul 08, 2020 7:03 pm

Rockets are loud.
https://astro-pi.org

cleverca22
Posts: 581
Joined: Sat Aug 18, 2012 2:33 pm

Re: plot/statistics of the processor

Wed Jul 08, 2020 7:16 pm

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

nick8967
Posts: 155
Joined: Fri Mar 25, 2016 11:02 pm

Re: plot/statistics of the processor

Wed Jul 08, 2020 8:09 pm

Do they export to log files? csv? txt? something?

jahboater
Posts: 5680
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: plot/statistics of the processor

Wed Jul 08, 2020 10:07 pm

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.
Pi4 8GB running PIOS64

User avatar
DougieLawson
Posts: 38883
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: plot/statistics of the processor

Wed Jul 08, 2020 10:24 pm

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.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

jahboater
Posts: 5680
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: plot/statistics of the processor

Thu Jul 09, 2020 2:36 am

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.
Pi4 8GB running PIOS64

Return to “Troubleshooting”