biocoder-frodo / FRITZBox-SynologyLogCenterDaemon

PHP 7.2 script that records your FRITZ!Box's System Log events in your Synology NAS
MIT License
7 stars 0 forks source link

new logs never written #1

Closed stalsma-palmetto closed 3 years ago

stalsma-palmetto commented 3 years ago

I got this mostly up and running, but nothing ever appears in the log on the NAS.

When running from terminal (ssh into NAS), w/the -q, I see all the logs that get dumped to the screen. So the connection to FritzBox seems to be working.

php74 ./Fritzbox-SynologyLogCenterDaemon.php -l=/volume1/homes/admin/logs/ -u=stats -p=/volume1/homes/admin/admin.pwdfile  -q | more
object(FritzLog)#7 (3) {
  ["Log"]=>
  array(284) {
    [0]=>
    object(FritzLogEvent)#9 (6) {
      ["_id":"FritzLogEvent":private]=>
      int(504)
      ["_category":"FritzLogEvent":private]=>
      int(1)
      ["_message":"FritzLogEvent":private]=>
      string(123) "Login of user stats to the FRITZ!Box user interface from the IP address 192.168.81.10. [3 messages since 03.02.21 14:02:27
]"
      ["_ts":"FritzLogEvent":private]=>
      int(1612357932)
      ["_dt":"FritzLogEvent":private]=>
      object(DateTime)#10 (3) {
        ["date"]=>
        string(26) "2021-02-03 14:12:12.000000"
        ["timezone_type"]=>
        int(1)
        ["timezone"]=>
        string(6) "+01:00"
      }
      ["_parent":"FritzLogEvent":private]=>
      *RECURSION*
    }

But when I remove -q, all I get is confirmation that the LogCenter is empty:

php74 ./Fritzbox-SynologyLogCenterDaemon.php -l=/volume1/homes/admin/logs/ -u=stats -p=/volume1/homes/admin/admin.pwdfile  
LogCenter table empty.
LogCenter table empty.
LogCenter table empty.
LogCenter table empty.
LogCenter table empty.
LogCenter table empty.
^C

I see where the the .DB file was created, but it's size remains 0 bytes.

I thought it was perhaps a permissions issue, so I added +w for group and world.

admin@DS718:/volume1/homes/admin$ ls -la logs/fritz.box/
total 0
drwxrwxrwx 1 admin users  50 Feb  3 13:17 .
drwxrwxrwx 1 admin users 190 Feb  3 13:17 ..
-rw-rw-rw- 1 admin users   0 Feb  3 13:17 SYNOSYSLOGDB_fritz.box.DB

I'm running v7.21 on the fritz.box.

biocoder-frodo commented 3 years ago

When Log Center accesses the databases in the /var/services/homes/admin/logs/ folder, it uses root permission; so I did that as well.

biocoder@diskstation:~$ ls /var/services/homes/admin/logs/ -latr
total 9192
-rwxrwxrwx+ 1 system log   1000448 Feb 28  2019 2019-01-20_2019-02-28.DB
-rwxrwxrwx+ 1 system log    496640 Apr  2  2019 2019-02-28_2019-04-02.DB
-rwxrwxrwx+ 1 system log     39936 Apr  4  2019 2019-04-02_2019-04-04.DB
-rw-r--r--  1 system log      8192 Apr  4  2019 2019-04-04_2019-04-04.DB
drwx------  1 root   root        0 May  4  2019 localhost
drwx------  1 root   root        0 May  4  2019 192.168.178.2
drwx------  1 root   root        0 May  5  2019 diskstation
drwxr-xr-x  1 admin  users     562 Apr 29  2020 ..
drwxr-xr-x  1 root   root      100 May 13  2020 local
drwxrwxrwx  1 admin  users     458 Dec  5 04:51 .
drwx------  1 root   root      216 Dec  8 16:35 fritz.box
-rw-r--r--  1 root   root  6766592 Feb  3 18:32 SYNOSYSLOGDB__LOCALARCH.DB
-rw-r--r--  1 root   root    32768 Feb  3 18:38 SYNOSYSLOGDB__LOCALARCH.DB-shm
-rw-r--r--  1 root   root  1060608 Feb  3 18:39 SYNOSYSLOGDB__LOCALARCH.DB-wal
biocoder@diskstation:~$ ls /var/services/homes/admin/logs/fritz.box/ -latr
ls: cannot open directory /var/services/homes/admin/logs/fritz.box/: Permission denied
biocoder@diskstation:~$ sudo ls /var/services/homes/admin/logs/fritz.box/ -latr                                                   
Password:
total 2188
-rw-r--r-- 1 root  root   657799 May  9  2020 2019-12-26_1933-11-25.ZIP
drwxrwxrwx 1 admin users     458 Dec  5 04:51 ..
drwx------ 1 root  root      216 Dec  8 16:35 .
-rw-r--r-- 1 root  root   486400 Jan 11 14:24 SYNOSYSLOGDB_fritz.box.DB
-rw-r--r-- 1 root  root  1059560 Feb  1 06:13 SYNOSYSLOGDB_fritz.box.DB-wal
-rw-r--r-- 1 root  root    32768 Feb  1 06:18 SYNOSYSLOGDB_fritz.box.DB-shm
biocoder@diskstation:~$

What happens when you sudo the command without the -q? I'm assuming you picked the default UDP port 516 for the Log Receiving rule.