Piwik 2.04b7 error in import_logs.py

So the command-line works fine for me in 2.1 using Python 2.7.3:
sudo /home/1stakes/public_html/piwik/misc/log-analytics/import_logs.py --idsite 1 --url=http://www.1stakes.tv/piwik --enable-static /var/log/virtualmin/1stakes.tv_access_log

But when it’s in my /etc/apache2/sites-available/1stakes.tv.conf as follows:
CustomLog “|/home/1stakes/public_html/piwik/misc/log-analytics/import_logs.py --idsite 1 --url=http://www.1stakes.tv/piwik --enable-static --output=/var/log/piwik.log -” vhost_combined

I get that error in my /var/log/piwik.log:
IOError: [Errno 29] Illegal seek
Traceback (most recent call last):
File “/home/1stakes/public_html/piwik/misc/log-analytics/import_logs.py”, line 1722, in
main()
File “/home/1stakes/public_html/piwik/misc/log-analytics/import_logs.py”, line 1686, in main
parser.parse(filename)
File “/home/1stakes/public_html/piwik/misc/log-analytics/import_logs.py”, line 1535, in parse
file.seek(0)

Dunno if it’s related to this bug or not…since it’s my first setup it might just be me, but it seems like it’s right according to the README. :-/

can you reproduce this IOError: [Errno 29] Illegal seek
by executing the script directly? to be able to fix the bug, we must first reproduce it, so please let us know how we can !

Matt,

I am not sure where “blab” ended up with his problem that he posted on March 4th 2014 but I am encountering the same error where I can run the import logs from the command line but piping from apache causes a failure.

[size=medium]Piwik Error Log Output From Apache Piped Run[/size]


IOError: [Errno 29] Illegal seek
Traceback (most recent call last):
  File "/hwnet/dtg_devel/web/beta/applications/piwik210/misc/log-analytics/import_logs.py", line 1723, in <module>
    main()
  File "/hwnet/dtg_devel/web/beta/applications/piwik210/misc/log-analytics/import_logs.py", line 1687, in main
    parser.parse(filename)
  File "/hwnet/dtg_devel/web/beta/applications/piwik210/misc/log-analytics/import_logs.py", line 1536, in parse
    file.seek(0)

[size=medium]Apache Error Log Output[/size]


AH00106: piped log program '/hwnet/dtg_devel/web/beta/applications/piwik210/misc/log-analytics/import_logs.py --enable-http-errors --enable-http-redirects --enable-static --enable-bots --enable-reverse-dns --add-sites-new-hosts --output=/tmp/piwik.log --recorders=4 --url='http://boarddev-beta-staging.teradyne.com/beta_analytics' --config=/hwnet/dtg_devel/web/beta/applications/piwik210/config/config.ini.php -' failed unexpectedly

[size=medium]Apache Custom Log Pipe[/size]
Note: I’ve tried setting the url with and without using single quotes. I see it written differently in different places so not sure which is correct. Regardless, the errors dont change one way or another.


LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_common
CustomLog "|/hwnet/dtg_devel/web/beta/applications/piwik210/misc/log-analytics/import_logs.py \ 
--enable-http-errors \
--enable-http-redirects \
--enable-static \
--enable-bots \
--enable-reverse-dns \
--add-sites-new-hosts \
--output=/tmp/piwik.log \
--recorders=4 \
--url='http://boarddev-beta-staging.teradyne.com/analytics' \
--config=/hwnet/dtg_devel/web/beta/applications/piwik210/config/config.ini.php -" vhost_common

[size=medium]Sample Apache Log File Output[/size]
This is the same log info that is piped into the import_logs.py


boarddev-beta.teradyne.com 131.101.241.6 - - [09/Apr/2014:19:39:33 -0400] "GET /boarddev/ HTTP/1.1" 200 12030 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36"
boarddev-beta.teradyne.com 131.101.241.6 - - [09/Apr/2014:19:39:33 -0400] "GET /Javascripts/NSrsz.js HTTP/1.1" 304 - "http://boarddev-beta-staging.teradyne.com/boarddev/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36"
boarddev-beta.teradyne.com 131.101.241.6 - - [09/Apr/2014:19:39:33 -0400] "GET /boarddev/Stylesheets/left.css HTTP/1.1" 304 - "http://boarddev-beta-staging.teradyne.com/boarddev/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36"

[size=medium]Server Configuration[/size]


Piwik: 2.1.0
Python: 2.6.6
PHP: 5.5.10
RHEL: 6.4

This bug has been fixed in: Merge pull request #294 from etmatrix/master · matomo-org/matomo@7513fef · GitHub

See ticket: import_logs give a IOError: [Errno 29] Illegal seek when receiving log from pipe · Issue #5254 · matomo-org/matomo · GitHub

please test the patch and report if there is still a problem for you?