#!/usr/bin/php 1) { $debug = $argv[1]; } //udp server IP and Port for listen $UDP_IP = "127.0.0.1"; $UDP_PORT = 1433; //create socket and bind them $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_bind($socket, $UDP_IP, $UDP_PORT); //init of this variables $from = ''; $port = 0; //use the output of rtl_433 -f 433920000 -f 433920000 -H 120 -F syslog:127.0.0.1:1433" //returns the json payload function parse_syslog($line) { //Try to extract the payload from a syslog line.// $line = mb_convert_encoding($line, "ASCII"); if (startsWith($line,"<")) { //fields should be "VER", timestamp, hostname, command, pid, mid, sdata, payload $fields = explode(" ",$line, 8); $line = $fields[7]; } return $line; } //server main loop for (;;) { //read from $socket into $line socket_recvfrom($socket, $line, 1024, 0, $from, $port); try { //parse $line -> returns the json payload $line = parse_syslog($line); /* do something with content of $line for example decode $line into a array $arr = json_decode($line,true); do something with that array and puted into a file as json file_put_contents('test.json', json_encode($arr, JSON_PRETTY_PRINT); */ } catch (Exception $e) { echo "---------------------------------------------\n"; echo 'Exception intercepted: ', $e->getMessage(), "\n"; echo "------------------------------------------- -\n"; } } ?>