Matomo logging works

This commit is contained in:
Charlie Root 2023-11-16 21:21:59 +01:00
parent b962c1452a
commit 240f257bfd
1 changed files with 40 additions and 8 deletions

View File

@ -50,6 +50,7 @@ vars:
freebsd:: freebsd::
"pkgs" slist => { "pkgs" slist => {
"apache24", "apache24",
"mod_dav_svn",
}; };
"log_dir" string =>"/var/log/httpd"; "log_dir" string =>"/var/log/httpd";
"log_dir_owner" string => "root"; "log_dir_owner" string => "root";
@ -80,7 +81,10 @@ vars:
{m:"proxy_fcgi",f:"mod_proxy_fcgi"}, {m:"proxy_fcgi",f:"mod_proxy_fcgi"},
{m:"proxy_http",f:"mod_proxy_http"}, {m:"proxy_http",f:"mod_proxy_http"},
{m:"proxy_http2",f:"mod_proxy_http2"}, {m:"proxy_http2",f:"mod_proxy_http2"},
{m:"remoteip",f:"mod_remoteip"} {m:"remoteip",f:"mod_remoteip"},
{m: "dav",f:"mod_dav"},
{m: "dav_svn", f:"mod_dav_svn"},
{m: "authz_svn", f:"mod_authz_svn"}
]'; ]';
@ -450,15 +454,17 @@ vars:
"pid" string => "/var/run/matomo-logger-$(site[domain]).pid"; "pid" string => "/var/run/matomo-logger-$(site[domain]).pid";
"log" string => "$(apache.log_dir)/$(site[domain])-access.log"; "log" string => "$(apache.log_dir)/$(site[domain])-access.log";
"siteid" string => "$(site[matomoid])"; "siteid" string => "$(site[matomoid])";
"logger_script" string => "/tmp/matomo-logger-$(site[domain]).sh";
freebsd:: freebsd::
"analyt_cmd" string => "/usr/local/bin/python3.9 /var/www/matomo/misc/log-analytics/import_logs.py"; "analyt_cmd" string => "/usr/local/bin/python3.9 $(matomo.log_importer)";
debian:: debian::
"analyt_cmd" string => "/usr/bin/python3 /var/www/matomo/misc/log-analytics/import_logs.py"; "analyt_cmd" string => "/usr/bin/python3 $(matomo.log_importer)";
centos:: centos::
"analyt_cmd" string => "/usr/bin/python3 /var/www/matomo/misc/log-analytics/import_logs.py"; "analyt_cmd" string => "/usr/bin/python3 $(matomo.log_importer)";
matomo:: matomo::
"cmd" string => "/usr/bin/pkill -P `cat $(pid)` ; exec /bin/sh -c 'echo $$ > $(pid); /usr/bin/tail -n+1 -f $(log) | $(analyt_cmd) --token-auth=$(site[matomotoken]) --disable-bulk-tracking --idsite=$(siteid) --url=$(site[matomosite]) --exclude-path=/wp-login.php --exclude-path=/wp-json/* --recorders=1 --recorder-max-payload-size=1 --log-format-name=ncsa_extended --exclude-path=*.php --exclude-path=/wp-admin/* - > /dev/null' "; "cmd" string => "/usr/bin/pkill -P `cat $(pid)` ; exec /bin/sh -c 'echo $$ > $(pid); echo \"hello\" | /usr/bin/tail -n+1 -f $(log) | $(analyt_cmd) --token-auth=$(site[matomotoken]) --disable-bulk-tracking --idsite=$(siteid) --url=$(site[matomosite]) --exclude-path=/wp-login.php --exclude-path=/wp-json/\\* --recorders=1 --recorder-max-payload-size=1 --log-format-name=ncsa_extended --exclude-path=\\*.php --exclude-path=/wp-admin/\\* - > /dev/null'
";
!matomo:: !matomo::
"cmd" string => ""; "cmd" string => "";
any:: any::
@ -494,7 +500,21 @@ files:
"$(pid)" "$(pid)"
create => "true"; create => "true";
"$(logger_script)"
create => "true",
perms => m("755"),
content => '#!/bin/sh
if [ "$1" != "child" ]; then
"$(logger_script)" child &
else
setsid >/dev/null 2>&1
exec 0<&- 1>/dev/null 2>&1
$(cmd)
fi
',
handle => "loggerscript_$(site[domain])_created";
classes: classes:
"matomo" expression => isvariable("site[matomoid]"); "matomo" expression => isvariable("site[matomoid]");
@ -507,10 +527,22 @@ commands:
inform => "false", inform => "false",
module => "true"; module => "true";
start_matomo::
"$(logger_script)"
args => "$(logger_script)",
contain => wmde_cmd_useshell,
depends_on => {"loggerscript_$(site[domain])_created"};
# "/bin/sh"
# args => "$(logger_script) &",
# contain => wmde_cmd_useshell,
# depends_on => {"loggerscript_$(site[domain])_created"};
methods: methods:
start_matomo:: # start_matomo::
"call" usebundle => daemonize( "$(cmd)" ); # "call" usebundle => daemonize( "/bin/sh $(logger_script)" ),
# depends_on => {"loggerscript_$(site[domain])_created"};
reports: reports:
#start_matomo:: #start_matomo::