How about this:
I've done this rather quickly because I really should be working. It certainly needs testing. Works for me though. Any thoughts?
Music to my ears - let me play with adjusting the thresholds as you have suggested.
By the way, @Lochnair and @moeller0 shouldn't tsping itself compensate for the midnight rollover issue? Otherwise the lines it prints:
root@OpenWrt-1:~/cake-autorate# tsping 9.9.9.9 --print-timestamps --machine-readable
Starting tsping 0.2.3 - pinging 1 targets
1681088125.024088,9.9.9.9,0,3324984,3325004,3325004,3325024,40,20,20
1681088125.124105,9.9.9.9,1,3325084,3325104,3325104,3325124,40,20,20
1681088125.224088,9.9.9.9,2,3325184,3325204,3325204,3325224,40,20,20
1681088125.323094,9.9.9.9,3,3325285,3325304,3325304,3325323,38,19,19
1681088125.425049,9.9.9.9,4,3325385,3325405,3325405,3325425,40,20,20
1681088125.524247,9.9.9.9,5,3325485,3325504,3325504,3325524,39,20,19
1681088125.624081,9.9.9.9,6,3325585,3325604,3325604,3325624,39,20,19
1681088125.725051,9.9.9.9,7,3325686,3325704,3325704,3325725,39,21,18
1681088125.824067,9.9.9.9,8,3325786,3325804,3325804,3325824,38,20,18
1681088125.924038,9.9.9.9,9,3325886,3325904,3325904,3325924,38,20,18
1681088126.024109,9.9.9.9,10,3325986,3326004,3326004,3326024,38,20,18
1681088126.123025,9.9.9.9,11,3326087,3326104,3326104,3326123,36,19,17
will presumably be phoney at the rollover time?
@tievolu set out the recipe for dealing with this here: