User avatar
HermannSW
Posts: 6098
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

‘trend’ can dynamically plot streaming data

Sat Dec 05, 2020 6:52 pm

TIL on Linux utility 'trend' while reading this:
https://iosoft.blog/2020/11/16/streamin ... pberry-pi/

I compiled cpuburn-a53
https://raw.githubusercontent.com/ssvb/ ... burn-a53.S
on Pi400 and saw that temperature goes down to 39°C on idle, and up to 53°C with cpuburn running.

This simple command measures temperature and pipes into trend:

Code: Select all

$ (while true; do vcgencmd measure_temp | cut -f2 -d\=; sleep 1; done) | trend - 120x4
120x4 means 120 seconds for 4 minutes according man page.
trend can be installed by "sudo apt-get install trend".

I found out by accident that you can click into the graph and get corresponding value displayed at top.
The graph resulted by starting cpuburn-a53, then pressing CTRL-C, restarting and finally pressing CTRL-C again:
trend.cpuburn-a53.png
trend.cpuburn-a53.png
trend.cpuburn-a53.png (4.14 KiB) Viewed 927 times

P.S:
I tried 60x1, and I really like that "make oldest data points darkest" in circular display:
trend.cpuburn-a53.60x1.png
trend.cpuburn-a53.60x1.png
trend.cpuburn-a53.60x1.png (3.71 KiB) Viewed 918 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6098
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: ‘trend’ can dynamically plot streaming data

Sun Dec 06, 2020 9:47 pm

I missed some kind of scale, then found it in manpage:

Code: Select all

pi@raspberrypi400:~ $ man trend | grep '\-v'
     -v                       visible values
pi@raspberrypi400:~ $ 
trend-v.png
trend-v.png
trend-v.png (4.77 KiB) Viewed 865 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6098
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: ‘trend’ can dynamically plot streaming data

Wed Dec 09, 2020 2:01 pm

trend can deal with floating point numbers as well.

I installed adjtimex for comparing system clock with the CMOS clock if present (RTC, Real Time Clock).

Code: Select all

pi@raspberrypi400:~ $ sudo adjtimex --compare=1 --utc
                                      --- current ---   -- suggested --
cmos time     system-cmos  error_ppm   tick      freq    tick      freq
1607521579      -0.001602             10000         0
pi@raspberrypi400:~ $ 

Calling same command a bit later shows bigger drift (system-cmos):

Code: Select all

pi@raspberrypi400:~ $ sudo adjtimex --compare=1 --utc
                                      --- current ---   -- suggested --
cmos time     system-cmos  error_ppm   tick      freq    tick      freq
1607521707      -0.463171             10000  10280700
pi@raspberrypi400:~ $ 


This trend command cuts out drift and pipes into trend with update each second:

Code: Select all

pi@raspberrypi400:~ $ (while true; do  sudo adjtimex --compare=1 --utc| tail -1|cut -b16-25; sleep 1; done) | trend -v - 60x1 

I disabled Wifi and rebooted, that way no network time update can happen.
I opened terminal as soon as possible after reboot, and executed that command.
Drift shown is in 0.002..0.004 second range.
Then, after 30 seconds, I enabled Wifi, you can see this by the big jump when kernel did network time update.
After that there is a roughly -0.5 second drift -- because DS3231 RTC stores time only with second resolution:
https://datasheets.maximintegrated.com/ ... df#page=11
trend-v.rtc_drift.png
trend-v.rtc_drift.png
trend-v.rtc_drift.png (2.67 KiB) Viewed 807 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6098
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: ‘trend’ can dynamically plot streaming data

Wed Dec 16, 2020 9:38 pm

Using 240x4 gives more details on system time correcting RTC time (the drift displayed changes abruptely). Highest drift value is -0.48s, lowest drift value is -0.80s:

Code: Select all

$ (while true; do  sudo adjtimex --compare=1 --utc| tail -1|cut -b16-25; sleep 1; done) | trend -v - 240x4$ (while true; do  sudo adjtimex --compare=1 --utc| tail -1|cut -b16-25; sleep 1; done) | trend -v - 240x4
trend-v.rtc_drift.longer.png
trend-v.rtc_drift.longer.png
trend-v.rtc_drift.longer.png (4.26 KiB) Viewed 619 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

Return to “Raspberry Pi OS”