diff --git a/monitorix b/monitorix index 8c6df7c..419cf24 100755 --- a/monitorix +++ b/monitorix @@ -117,6 +117,8 @@ sub create_index { my $table_back_color; my $title_back_color; my $title_fore_color; + my $piwik_code = ""; + my ($piwik_url, $piwik_sid, $piwik_img); # keep backwards compatibility for v3.2.1 and less if(ref($config{theme}) ne "HASH") { @@ -143,6 +145,34 @@ sub create_index { $title_fore_color = $config{theme}->{$theme}->{title_fg}; } + # Piwik tracking code + if(lc($config{piwik_tracking}->{enabled} eq "y")) { + $piwik_url = $config{piwik_tracking}->{url} || ""; + $piwik_sid = $config{piwik_tracking}->{sid} || ""; + $piwik_img = $config{piwik_tracking}->{img} || ""; + $piwik_code = <<"EOF"; + + + + + +EOF + } + # force to only one trailing slash (my $base_url = $config{base_url}) =~ s/\/*$/\//; (my $base_cgi = $config{base_cgi}) =~ s/\/*$/\//; @@ -158,6 +188,7 @@ sub create_index { + $piwik_code


diff --git a/monitorix.cgi b/monitorix.cgi index bbd20e9..9e2bdda 100755 --- a/monitorix.cgi +++ b/monitorix.cgi @@ -378,6 +378,37 @@ if(!$silent) { my $title; my $str; + my $piwik_code = ""; + my ($piwik_url, $piwik_sid, $piwik_img); + + # Piwik tracking code + if(lc($config{piwik_tracking}->{enabled} eq "y")) { + $piwik_url = $config{piwik_tracking}->{url} || ""; + $piwik_sid = $config{piwik_tracking}->{sid} || ""; + $piwik_img = $config{piwik_tracking}->{img} || ""; + $piwik_code = <<"EOF"; + + + +

+ + +EOF + } + print("\n"); print("\n"); print(" \n"); @@ -388,6 +419,7 @@ if(!$silent) { } print(" \n"); print(" \n"); + print(" $piwik_code\n"); print("
\n"); print(" \n"); print(" \n"); diff --git a/monitorix.conf b/monitorix.conf index 30f23cf..5b646ee 100644 --- a/monitorix.conf +++ b/monitorix.conf @@ -60,6 +60,14 @@ imap_log_date_format = %b %d secure_log_date_format = %b %e + + enabled = n + url = "://example.com/piwik/" + sid = "1" + img = "http://example.com/piwik/piwik.php?idsite=1" + + + # Graphs (de)activation # -----------------------------------------------------------------------------