Created
July 15, 2017 22:18
-
-
Save JonTheWong/0c222703ea7dfecef6dc7074fce1b20c to your computer and use it in GitHub Desktop.
piwik cpanel + log-analytics + vhosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/etc/apache2/conf.d/includes/pre_main_global.conf -- contains | |
<Macro piwiklog $vhost $logname $output $env> | |
LogFormat "$vhost %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" $logname | |
CustomLog "|/home2/user/public_html/changeddomain.tld/misc/log-analytics/import_logs.py \ | |
--add-sites-new-hosts \ | |
--config=/home2/user/public_html/changeddomain.tld/config/config.ini.php \ | |
--url='https://changeddomain.tld/' \ | |
--token-auth=REMOVED \ | |
--enable-bots \ | |
--enable-static \ | |
--enable-http-errors \ | |
--enable-http-redirects \ | |
--enable-reverse-dns \ | |
--recorders=4 \ | |
--log-format-regex='(?P<host>[\\\\w\\\\-\\\\.\\\\/]*)(?::\\\\d+)? (?P<ip>\\\\S+) \\\\S+ \\\\S+ \\\\[(?P<date>.*?) (?P<timezone>.*?)\\\\] \\\"\\\\S+ (?P<path>.*?) \\\\S+\\\" (?P<status>\\\\S+) (?P<length>\\\\S+) \\\"(?P<referrer>.*?)\\\" \\\"(?P<user_agent>.*?)\\\"' \ | |
--output=/var/log/piwik/$output.log \ | |
-" \ | |
$logname \ | |
$env | |
</Macro> | |
Use piwiklog %v vhost_common main " " | |
/var/cpanel/templates/apache2_4/ssl_vhost.local -- contains | |
<VirtualHost *:80> | |
ServerName [% wildcard_safe(vhost.servername) %] | |
Use piwiklog %v vhost_common main " " | |
--snip snip | |
cat /var/log/piwik/main.log | |
=====> Warning: File (?P<ip>\S+) does not exist <===== | |
=====> Warning: File \S+ does not exist <===== | |
=====> Warning: File \S+ does not exist <===== | |
=====> Warning: File \[(?P<date>.*?) does not exist <===== | |
=====> Warning: File (?P<timezone>.*?)\] does not exist <===== | |
=====> Warning: File "\S+ does not exist <===== | |
=====> Warning: File (?P<path>.*?) does not exist <===== | |
=====> Warning: File \S+" does not exist <===== | |
=====> Warning: File (?P<status>\S+) does not exist <===== | |
=====> Warning: File (?P<length>\S+) does not exist <===== | |
=====> Warning: File "(?P<referrer>.*?)" does not exist <===== | |
=====> Warning: File "(?P<user_agent>.*?)"' does not exist <===== | |
=====> Warning: File (?P<ip>\S+) does not exist <===== | |
=====> Warning: File \S+ does not exist <===== | |
=====> Warning: File \S+ does not exist <===== | |
=====> Warning: File \[(?P<date>.*?) does not exist <===== | |
=====> Warning: File (?P<timezone>.*?)\] does not exist <===== | |
=====> Warning: File "\S+ does not exist <===== | |
=====> Warning: File (?P<path>.*?) does not exist <===== | |
=====> Warning: File \S+" does not exist <===== | |
=====> Warning: File (?P<status>\S+) does not exist <===== | |
=====> Warning: File (?P<length>\S+) does not exist <===== | |
=====> Warning: File "(?P<referrer>.*?)" does not exist <===== | |
=====> Warning: File "(?P<user_agent>.*?)"' does not exist <===== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for cPanel at the bottom of /var/cpanel/templates/apache2_4/vhost.local
CustomLog "||$/home2/user/public_html/analytics.domain.tld/misc/log-analytics/import_logs.py \ --config=/home2/user/public_html/analytics.domain.tld/config/config.ini.php \ --url='https://analytics.domain.tld' \ --token-auth=REMOVED \ --add-sites-new-hosts \ --enable-bots \ --enable-static \ --enable-http-errors \ --enable-http-redirects \ --enable-reverse-dns \ --recorders=4 \ --recorder-max-payload-size=1 \ --log-format-name=common_vhost \ --output=/var/log/piwik/[% wildcard_safe(vhost.servername) %] \ -" combinedvhost