Dump1090 MySQL Database Script with Alert and Filter

Hi! I managed to get the radar.php script logging, had to modify to use with Mictronics fork of dump1090-fa. But is it in any way possible to get it to log every plane regardless of position, even the ones not transmitting position, and without MLAT? Even better would be option to store planes within configured position AND planes anywhere below given altitude. I don’t mind if it makes the database large, I have low traffic here, and database is stored on external USB hard drive.

The script only logs what’s being read by dump1090, aircraft type is not transmitted, it’s read from external database. This script does not look up info in other places than the dump1090 JSONs.

Hello Tom,

many thanks for the great work. ac_counter runs like a charm.
one, of course stupid question :wink:
I have a problem with the radar
The insert into the db works fine, if I am manually starting it.
But when I am using systemd, I got the following error from status:
sudo systemctl status radar.service
● radar.service - radar.php
Loaded: loaded (/etc/systemd/system/radar.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2019-04-10 19:45:45 UTC; 4s ago
Process: 14857 ExecStart=/home/pi/radar.php (code=exited, status=203/EXEC)
Main PID: 14857 (code=exited, status=203/EXEC)

Apr 10 19:45:45 piaware systemd[1]: radar.service: Unit entered failed state.
Apr 10 19:45:45 piaware systemd[1]: radar.service: Failed with result ‘exit-code’.

any idea?
many greetings from LEJ

Have you set the +x bit on radar.php? chmod +x radar.php

sudo journalctl -eu radar

should hopefully give some useful log in regards to the problem.

@Surgraph, many thanks, but I did the ```
sudo chmod 755 /home/pi/radar.php
@wiedehopf,

this brought only the information, that it starts and stops every 10 seconds ;-(
Apr 11 18:49:03 piaware systemd[1]: radar.service: Main process exited, code=exited, status=203/EXEC
Apr 11 18:49:03 piaware systemd[1]: radar.service: Unit entered failed state.
Apr 11 18:49:03 piaware systemd[1]: radar.service: Failed with result ‘exit-code’.
Apr 11 18:49:13 piaware systemd[1]: radar.service: Service hold-off time over, scheduling restart.
Apr 11 18:49:13 piaware systemd[1]: Stopped radar.php.
Apr 11 18:49:13 piaware systemd[1]: Started radar.php.
Apr 11 18:49:13 piaware systemd[1]: radar.service: Main process exited, code=exited, status=203/EXEC
Apr 11 18:49:13 piaware systemd[1]: radar.service: Unit entered failed state.
Apr 11 18:49:13 piaware systemd[1]: radar.service: Failed with result ‘exit-code’.
Apr 11 18:49:23 piaware systemd[1]: radar.service: Service hold-off time over, scheduling restart.
Apr 11 18:49:23 piaware systemd[1]: Stopped radar.php.
Apr 11 18:49:23 piaware systemd[1]: Started radar.php.
Apr 11 18:49:23 piaware systemd[1]: radar.service: Main process exited, code=exited, status=203/EXEC
Apr 11 18:49:23 piaware systemd[1]: radar.service: Unit entered failed state.
Apr 11 18:49:23 piaware systemd[1]: radar.service: Failed with result ‘exit-code’.

many thanks from LEJ

Can you show me:

cat /etc/systemd/system/radar.service

sure:
[Unit]
Description=radar.php

[Service]
ExecStart=/home/pi/radar.php
Restart=always
RestartSec=10
StandardOutput=/var/log/radarLog.log
StandardError=/var/log/radarError.log

[Install]
WantedBy=multi-user.target

there one sees also the 10 seconds ;-(
I added the logs, but it did not worked without them either …
Greetings from LEJ

Oh you specified log files, then the journalctl will of course show nothing :slight_smile:

Let’s see both of them please

cat /var/log/radarError.log
cat /var/log/radarLog.log

And also:
ls -l /home/pi/radar.php

they are both not existing
I changed again to null and did run: sudo journalctl -eu radar again, which is producing the same output as the status query

greetings from LEJ

If you put it null which basically means nothing there is no log at all.
Just remove these two lines completely:

StandardOutput=/var/log/radarLog.log
StandardError=/var/log/radarError.log

then:

sudo systemctl daemon-reload
sudo systemctl restart radar

then check the log again.
sudo journalctl -eu radar

How do you start the radar.php on the command line?

What does this say?
cat /home/pi/radar.php | head

same ;-(
Apr 11 19:22:16 piaware systemd[1]: Started radar.php.
Apr 11 19:22:16 piaware systemd[1]: radar.service: Main process exited, code=exited, status=203/EXEC
Apr 11 19:22:16 piaware systemd[1]: radar.service: Unit entered failed state.
Apr 11 19:22:16 piaware systemd[1]: radar.service: Failed with result ‘exit-code’.
Apr 11 19:22:27 piaware systemd[1]: radar.service: Service hold-off time over, scheduling restart.
Apr 11 19:22:27 piaware systemd[1]: Stopped radar.php.
Apr 11 19:22:27 piaware systemd[1]: Started radar.php.
Apr 11 19:22:27 piaware systemd[1]: radar.service: Main process exited, code=exited, status=203/EXEC
Apr 11 19:22:27 piaware systemd[1]: radar.service: Unit entered failed state.
Apr 11 19:22:27 piaware systemd[1]: radar.service: Failed with result ‘exit-code’.
Apr 11 19:22:28 piaware systemd[1]: Stopped radar.php.
Apr 11 19:22:28 piaware systemd[1]: Started radar.php.
Apr 11 19:22:28 piaware systemd[1]: radar.service: Main process exited, code=exited, status=203/EXEC
Apr 11 19:22:28 piaware systemd[1]: radar.service: Unit entered failed state.
Apr 11 19:22:28 piaware systemd[1]: radar.service: Failed with result ‘exit-code’.

I am running the latest flightaware flash, and only installed radar and ac_counter and Mariadb, I promise ;.-)

How do you start the radar.php on the command line?

What does this say?
cat /home/pi/radar.php | head

and this?
which php

pi@piaware:~ $ cat /home/pi/radar.php | head
4#!/usr/bin/php

<?php #phpinfo(); #var_dump(ini_get_all()); #ini_set('error_reporting', E_ALL); // below a sample create statement for database table // CREATE TABLE aircrafts (id INT NOT NULL AUTO_INCREMENT, message_date VARCHAR(100), now VARCHAR(100), hex VARCHAR(100), flight VARCHAR(100), distance VARCHAR(100), altitude VARCHAR(100), lat VARCHAR(100), lon VARCHAR(100), track VARCHAR(100), speed VARCHAR(100), vert_rate VARCHAR(100), seen_pos VARCHAR(100), seen VARCHAR(100), rssi VARCHAR(100), messages VARCHAR(100), category VARCHAR(100), squawk VARCHAR(100), nucp VARCHAR(100), mlat VARCHAR(100), tisb VARCHAR(100), rec_msg_sec VARCHAR(100), PRIMARY KEY (id)) pi@piaware:~ $ which php /usr/bin/php excuse the missing new line

Why is there a 4 in front of the # at the beginning of the file?

Heureka
I bow to you to have spotted this, and I have no idea how this happened
I offer you a beer the next time I am in Munich :wink:
many thanks and have a nice evening from LEJ

I’m probably close to the furthest spot one could be from Munich while still being in Bavaria, but thank you i’ll raise a virtual one :beer:

If you had started it on the command line with the same command as in the service file it would have been rather obvious.
But you probably used php and gave the file as an argument, this works no matter what the first line says.

same here!
many thanks from LEJ

Hi

after some setup challenges i got the script working.

It’s running now for eight minutes on my device accessing the dump stream on my remote Raspberry.

This is what i get in the window where it runs:
upt(us): 0022351 - 0.971171 loops/s avg - since 0 days 00:09:15 - run 539 @ 478,1 msg/s -> 000 dataset(s) =>

Now 9 Minutes, but the database is still empty:

mysql> use adsb;
    Database changed

mysql> SELECT * FROM aircrafts;
    Empty set (0.00 sec)

Any ideas? There’s plenty of aircrafts visible which can be found also while accessing the aircraft.json

Thanks

Additional note: I’ve read the thread again and did some tests with the hits for the user who had the same issue.

I selected all germany as Lat/Long and all filters are set to “false”.
The only thing i left alone was the alert.

But there are no errors, simply no datasets are created.

Any help would be appreciated.