Skip to content

Commit

Permalink
chore: logs analysis scripts (#9382)
Browse files Browse the repository at this point in the history
Commiting logs analysis scripts that were on off1 in /srv/off/logs


---------

Co-authored-by: Alex Garel <[email protected]>
  • Loading branch information
stephanegigandet and alexgarel authored Nov 29, 2023
1 parent 9010d3e commit 593b7a8
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Thumbs.db

# Logs
logs/
!scripts/utils/logs
debug/
Store.debug.txt
*.log
Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions scripts/utils/logs/concatenate_by_ip.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/perl -w

use strict;
use warnings;

my %ip = ();

while (<STDIN>) {
if ($_ =~ /(^\S+) /) {
$ip{$1}++;
}
}

foreach my $ip (sort {$ip{$a} <=> $ip{$b}} keys %ip) {
print "$ip\t$ip{$ip}\n";
}

17 changes: 17 additions & 0 deletions scripts/utils/logs/concatenate_by_ip3.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/perl -w

use strict;
use warnings;

my %ip = ();

while (<STDIN>) {
if ($_ =~ /(^\S+)\.(\d+) /) {
$ip{$1}++;
}
}

foreach my $ip (sort {$ip{$a} <=> $ip{$b}} keys %ip) {
print "$ip\t$ip{$ip}\n";
}

17 changes: 17 additions & 0 deletions scripts/utils/logs/concatenate_by_user_agent.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/perl -w

use strict;
use warnings;

my %ip = ();

while (<STDIN>) {
if ($_ =~ /"([^"]+)"$/) {
$ip{$1}++;
}
}

foreach my $ip (sort {$ip{$a} <=> $ip{$b}} keys %ip) {
print "$ip\t$ip{$ip}\n";
}

File renamed without changes.
18 changes: 18 additions & 0 deletions scripts/utils/logs/subdomains.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr//bin/perl -w

use strict;
use warnings;

my %subdomains = ();

# input for script: /home/off/logs/access_log

while (<STDIN>) {
if ($_ =~ /\/([a-z-]+)\.openfoodfacts\.org/) {
$subdomains{$1}++;
}
}

foreach my $sd (sort {$subdomains{$b} <=> $subdomains{$a}} keys %subdomains) {
print $sd . "\t" . $subdomains{$sd} . "\n";
}
22 changes: 22 additions & 0 deletions scripts/utils/logs/top_errors.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/perl -w

use strict;
use warnings;

my %errors = ();

# [Tue Sep 13 11:03:23 2016] -e: Use of uninitialized value $tag in pattern match (m//) at /home/off/lib/ProductOpener/Tags.pm line 1811.

while (<STDIN>) {

chomp;
my $line = $_;
$line =~ s/\[.*?\] //;
$errors{$line}++;
}

foreach my $error (sort {$errors{$a} <=> $errors{$b}} keys %errors) {

print $errors{$error} . "\t" . $error . "\n";

}

0 comments on commit 593b7a8

Please sign in to comment.