Open matt9mg opened 4 years ago
checking the error.log file I can see this.
AH00106: piped log program '/var/www/html/import_logs.py --debug --enable-http-errors --enable-http-redirects --enable-bots --url=http://XXXXXXXXXX --output=/var/log/apache2/matomo.log --recorders=1 --recorder-max-payload-size=1 --token-auth=XXXXXXXXXXXXXXXX --idsite=3 --log-format-name=common_complete -' failed unexpectedly
But checking /var/log/apache2/matomo.log i just get the same old output above.
Hi,
I don't know Apache at all, so I can't help here. But just for your information: This section of the README was written 8 years ago, so it is not impossible that it won't work that way any more. If you find out more it would be great if you could create a PR that fixes it or if it turns out to not work at all, removes it.
Running the above in the apache vhost using a php script manages to grab the stdin.
<?php
$stdin = fopen('php://stdin', 'rb');
ob_implicit_flush(true);
while ($line = fgets($stdin)) {
$line = trim($line);
file_put_contents(__DIR__ . '/tmp.txt', print_r($line, true), FILE_APPEND);
}
But adding some debug logging into the .py script shows nothing is being passed to python. My python skills aren't that strong so may need someone else to help with this as its a big requirement.
Using the latest version supplied in this repository (which is different from the matomo application you download from the website) doesn't work at all
AH00106: piped log program '/usr/bin/python3 /var/www/html/import_logs.py --debug --enable-http-errors --enable-http-redirects --enable-bots --url=http://XXXXXXXX --output=/var/log/apache2/matomo.log --recorders=1 --recorder-max-payload-size=1 --token-auth=XXXXXXXXXXXXXXX --idsite=3 --log-format-name=common_complete -' failed unexpectedly
Traceback (most recent call last):
File "/var/www/html/import_logs.py", line 2661, in <module>
config = Configuration()
File "/var/www/html/import_logs.py", line 1024, in __init__
self._parse_args(self._create_parser(), argv)
File "/var/www/html/import_logs.py", line 934, in _parse_args
sys.stdout = sys.stderr = open(self.options.output, 'a+', 0)
ValueError: can't have unbuffered text I/O
But does support my theory that the buffer is empty which is passed to python.
similar issue here: the --output
option seems bugged.
dropping it and redirecting stdout manually helped in my case.
Using the latest version supplied in this repository (which is different from the matomo application you download from the website) doesn't work at all
AH00106: piped log program '/usr/bin/python3 /var/www/html/import_logs.py --debug --enable-http-errors --enable-http-redirects --enable-bots --url=http://XXXXXXXX --output=/var/log/apache2/matomo.log --recorders=1 --recorder-max-payload-size=1 --token-auth=XXXXXXXXXXXXXXX --idsite=3 --log-format-name=common_complete -' failed unexpectedly Traceback (most recent call last): File "/var/www/html/import_logs.py", line 2661, in <module> config = Configuration() File "/var/www/html/import_logs.py", line 1024, in __init__ self._parse_args(self._create_parser(), argv) File "/var/www/html/import_logs.py", line 934, in _parse_args sys.stdout = sys.stderr = open(self.options.output, 'a+', 0) ValueError: can't have unbuffered text I/O
But does support my theory that the buffer is empty which is passed to python.
It's python3 migration issue: offset isn't applicable in "text-mode" i/o. Can be fixed with small patch:
if self.options.output:
- sys.stdout = sys.stderr = open(self.options.output, 'a+', 0)
+ sys.stdout = sys.stderr = open(self.options.output, 'a+')
@AdUser would you mind creating a small PR for that, so someone from the team can review and merge that? Thanks.
It would seem running the below code from the documentation doesn't seem to pass anything into stderin.
This is placed in the Vhost
output is from the log file
But if I run this command via a cron from a file it works as expected and I see the log output is sending this information to my matomo instance.
/var/www/html/import_logs.py --debug --enable-http-errors --enable-http-redirects --enable-bots --url=http://XXXXX --output=/var/log/apache2/matomo.log --recorders=1 --recorder-max-payload-size=1 --token-auth=XXXXXXXXXX --idsite=3 --log-format-name=common_complete /var/log/apache2/site.log