Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,196 of 9,196 pages
About the help in other languages
All help pages

View counts across nodes

From Exponential 6.0.15 the view counter (ezview_counter, $node.view_count) counts the page views of every node that serves an installation, of every host of a siteaccess and of every web server in front, not only the…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/features/6.0/view-count-across-nodes.md

On this page

View counts across nodes

From Exponential 6.0.15 the view counter (ezview_counter, $node.view_count) counts the page views of every node that serves an installation, of every host of a siteaccess and of every web server in front, not only the access log of the node it runs on. One node copies every node's logs and counts the copies; each copy keeps a resume state of its own, and a node that takes over after a failover goes on where the other one stopped, without counting a line twice.

This page is for administrators of a cluster (several web servers behind a load balancer) or of a server with several access logs per site. The whole setup, with every setting, the scheduling (Plesk, systemd, cron), rotation and troubleshooting, is in the guide View counts in a cluster.

In short

Before 6.0.15From 6.0.15
Logs per siteaccessone (StorageDir/LogFileName)as many as needed (LogFiles[])
Nodesthe node the cronjob runs onevery node of Nodes[], copied by exp:viewcount:collect
Who countsevery node that runs the cronjobthe node PrimaryCommand names
A state moved to another diskread again from the first linegoes on from where it stopped (by the log's first line)
Existing settingsunchanged; a setting of an older form is read and noted

What is new

  • logfile.ini [AccessLogFileSettings] LogFiles[]: more access logs of a siteaccess.
  • logfile.ini [ViewCountSettings] Nodes[], NodeName, MirrorDir, PrimaryCommand, RemoteShell.
  • exp:viewcount:collect (bin/php/expviewcountcollect.php): takes over the state of the node that counted before and copies every node's logs to MirrorDir/<node>/<path> (local logs with PHP, remote ones with rsync over ssh).
  • exp:viewcount:update reads the copies in cluster mode and runs only on the counting node (--force anyway).
  • The cronjob parts view_count_nodes (both), view_count_collect and view_count_copies (each half).
  • The log reader knows a log by its first line as well as by its inode (the event moved), and the state of a copy is named by its path below the state folder, so a state fits every node.
  • runcronjobs.php and the two commands change to the installation when a hosting panel starts them elsewhere.

Settings

# settings/override/logfile.ini.append.php
[ViewCountSettings]
Nodes[]
Nodes[]=web1
Nodes[]=web2
PrimaryCommand=/usr/local/bin/xsh lb:site:primary www.example.com --is-me -q

# settings/siteaccess/site/logfile.ini.append.php
[AccessLogFileSettings]
StorageDir=/var/www/vhosts/system/www.example.com/logs
LogFileName=access_ssl_log
LogFiles[]=/var/log/vcc/example/site-access.log
php runcronjobs.php -q -s site view_count_nodes      # every 15 minutes, on every node

Limits

  • The nodes are reached over RemoteShell (ssh) and rsync as the user the run is for; it needs a key and read access to the logs, or the copy runs as root (view_count_collect) and the count as the site user (view_count_copies).
  • Lines a rotation takes away before they were copied are lost when the rotated file cannot be recognized (Plesk's append to .webstat and truncate); keep the interval short.
  • Older rotations are counted once by hand (--log-file with a --state-dir of their own).

Tests

tests/tests/kernel/classes/viewcount/expViewCountCollectorTest.php (several nodes and hosts, a log that grows, a rotation, a state taken over from another node, the counting node) and expViewCountConfigurationTest.php (old settings only, new only, both, the older form of LogFileName, Nodes[]), DB-less.

Related: View count statistics · Clustering overview · exp:viewcount:collect

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x