I did it slightly differently in the end - cron calls a script which pulls the data from rrd then processes it and saves it in a single file that gnuplot can use:
#!/bin/bash
# Fetch daily data from rrds
rrdtool fetch /var/lib/collectd/rrd/localhost/dump1090-localhost/dump1090_messages-local_accepted.rrd AVERAGE -e midnight today -s end-1day -r 3m -a > /run/messages
rrdtool fetch /var/lib/collectd/rrd/localhost/dump1090-localhost/dump1090_aircraft-recent.rrd AVERAGE -e midnight today -s end-1day -r 3m -a > /run/aircraft
# Remove headers and extraneous :
sed -i 's/://' /run/messages
sed -i 's/://' /run/aircraft
sed -i -e '1d;2d' /run/messages
sed -i -e '1d;2d' /run/aircraft
# Combine both files to create space separated data file for use by gnuplot
join -o 1.2 2.2 /run/aircraft /run/messages > /var/cache/fetch/$(date -I --date=yesterday)-scatter
This is called a few minutes after midnight and names the file for the previous complete 24 hour day. I set it to use a resolution of 3 minutes, which gives a smaller number of points to plot.
Currently I have a gnuplot script that just generates a graph for the last complete day:
date = system("date -I --date=yesterday")
set terminal pngcairo enhanced size 1280,1024
set output './'.date.'-adsb.png'
set title 'Message rate compared to aircraft seen'
set xlabel 'Aircraft'
set ylabel 'Messages rate /s'
set grid xtics ytics
f(x) = a*x**2 + b*x + c
c = 0
fit f(x) '/var/cache/fetch/'.date.'-scatter' via a,b
plot '/var/cache/fetch/'.date.'-scatter' notitle, f(x) notitle
Running “gnuplot adsb.plot” generates the .png file:
Once I’ve collected a bit more data I’ll add some comparisons to it. I’m not sure a quadratic regression is ideal for this, but it seems to fit the data quite well for an RTL dongle in a busy area. It might not fit as well for an airspy.
SSRs have a time budget for interrogations; above a certain number of aircraft, this budget will limit the interrogation rate per aircraft (& therefore response rate)
IIRC TCAS dials back transmit power when it sees a congested environment, so again fewer replies per aircraft as the effective interrogation range is lower.
It might be interesting to plot only ADS-B messages, since the transmit rate of those messages should be mostly unaffected by the environment. I don’t think that’s a statistic that’s currently collected though.
I am within range of Heathrow, so it’s very busy here and I have a lot of nearby traffic. There is a noticeable difference in message rate in the early morning as trans-Atlantic flights start to arrive before the local airports start operating, and later in the day.
The message rate is noticeably higher in this early period than it is later on in the day, but with a similar number of aircraft visible. This is quite likely due to the factors you mentioned - in the morning, received aircraft are mostly at high altitude and spread out across the country, whereas later the majority are within 50 miles and at lower altitudes.
There is definitely an impact on range with increased message traffic though - I see a marked decrease in the maximum during peak times compared with when it’s quieter.
It’s interesting to see wiedehopf’s airspy is much more consistent with fewer aircraft, but has the same increased distribution at higher traffic levels, probably due to the effects you describe.
#!/bin/bash
# Fetch daily data from rrds
rrdtool fetch /var/lib/collectd/rrd/localhost/dump1090-localhost/dump1090_messages-local_accepted.rrd AVERAGE -e midnight today -s end-1day -r 3m -a > /tmp/messages_l
rrdtool fetch /var/lib/collectd/rrd/localhost/dump1090-localhost/dump1090_messages-remote_accepted.rrd AVERAGE -e midnight today -s end-1day -r 3m -a > /tmp/messages_r
rrdtool fetch /var/lib/collectd/rrd/localhost/dump1090-localhost/dump1090_aircraft-recent.rrd AVERAGE -e midnight today -s end-1day -r 3m -a > /tmp/aircraft
# Remove headers and extraneous :
sed -i 's/://' /tmp/messages_l
sed -i 's/://' /tmp/messages_r
sed -i 's/://' /tmp/aircraft
sed -i -e '1d;2d' /tmp/messages_l
sed -i -e '1d;2d' /tmp/messages_r
sed -i -e '1d;2d' /tmp/aircraft
# Combine both files to create space separated data file for use by gnuplot
join -o 1.1 1.2 2.2 /tmp/aircraft /tmp/messages_l > /tmp/tmp
join -o 1.2 1.3 2.2 /tmp/tmp /tmp/messages_r > /tmp/$(date -I --date=yesterday)-scatter
cd /tmp
gnuplot /dev/stdin <<"EOF"
date = system("date -I --date=yesterday")
set terminal pngcairo enhanced size 1280,1024
set output '/tmp/'.date.'-adsb.png'
set datafile separator " "
set title 'Message rate compared to aircraft seen'
set xlabel 'Aircraft'
set ylabel 'Messages rate /s'
set grid xtics ytics
f(x) = c*x/sqrt(d+x**2) + a*x**2 +b*x
c=4000
d=7000
a=0.05
b=-20
fit f(x) '/tmp/'.date.'-scatter' using 1:($2+$3) via a,b,c,d
plot '/tmp/'.date.'-scatter' using 1:($2+$3), f(x) notitle
EOF
I’ve adapted the fit function a little because your data doesn’t really fit the downward trend at the end.
You probably made a mistake by saying “whoever wants to plot this graph…” – because somebody like me comes along, somebody who hasn’t followed every procedure in the thread prior to this.
I installed gnuplot-nox using your command. It initially failed because it couldn’t find something, and of course apt-get update (or whatever the command was) fixed that. I was then able to install gnuplot-nox.
Then I tried to run your script and it said rrdtool wasn’t installed. so I did “sudo apt-get install rrdtool”. That completed fine.
Then I ran the command (the one with wget in it) and I get:
ERROR: unknown option ‘-a’
ERROR: unknown option ‘-a’
ERROR: unknown option ‘-a’
Read 0 points
No data to fit
“/dev/stdin”, line 14: