Exclude specific IP addresses from OPS preprint statistics

Dear PKP staffs and Forum members,

I am currently operating OPS3.3.0.8 (PHP7.4).
Is it possible to exclude specific IP addresses from the aggregation logic of OPS preprint statistics plugin?
On our site, we would like to exclude IPs for operation monitoring, staff confirmation IPs, robot access IPs, etc.

Please let me know if you have any tips or advice.

Best regards,
Minoru Tanabe.

Hi @Minoru_Tanabe,

The usage stats plugin already filters robots. The list is in the OPS folder lib/pkp/lib/counterBots/ i.e. for the OPS stable branch it is this list here GitHub - atmire/COUNTER-Robots at 7134f6dbc157ecbf44c8f6829f13b4f873fdd805.
For excluding other IP addresses from logging or aggregation there is unfortunately no ‘easy’ way at the moment - you would need to change the code :frowning: If you would like to do that you could either 1) not log those events or 2) not consider them for the aggregation.
1)
This is the option to chose if you hash the IPs.
You would need something like:

$ipsToExclude = [ip1, ip2, ip3...];
if (!in_array($usageEvent['ip'], $ipsToExclude)) {
  $this->_writeUsageEventInLogFile($usageEvent);
}

instead of this line usageStats/UsageStatsPlugin.inc.php at 9379fee1be5759ba6106034bbe71b3dc9b13603a · pkp/usageStats · GitHub.
2)
You would need something like:

$ipsToExclude = [ip1, ip2, ip3...];
if (in_array($entryData['ip'], $ipsToExclude)) continue;

after this line usageStats/UsageStatsLoader.inc.php at stable-3_3_0 · pkp/usageStats · GitHub.

In some of our future releases we might consider this feature. You can follow this issue for that: Possibility to add list of IPs that should not be considered in usage statistics · Issue #8540 · pkp/pkp-lib · GitHub.

Best wishes,
Bozana

Hi @bozana,

Thank you for your advice.
I understand that we have to touch inside the source code.
Changing the source code is a little risky, so we’ll wait for the next package.
We currently exclude specific IPs in a different way. It’s a way to exclude specific IPs from the stats log file in our shell script before running the task of OPS stats.
As a result, we are currently able to exclude IPs without any problems, so we would like to operate with this method for the time being.
Thank you for your continued support.

Best regards,
Minoru Tanabe.

Hi @Minoru_Tanabe,

That sound great! Much better solution than changing the source code (when the IPs are not hashed)!

Thanks and best wishes,
Bozana

1 Like

Hi @bozana ,

The IPs in the usage_events log of OPS are not currently hashed, so they can be filtered out without any problems.
In order to execute statistical processing more reliably, you should disable the Acron plugin and schedule statistical tasks with crontab, including pre-processing and post-processing.

Best regards,
Minoru Tanabe