metrics/access/ingest: detect product image paths and included in dump.
This commit is contained in:
parent
6203b52a42
commit
dc9afe2adf
@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
const REGEX_LINE = '/\S+ \S+ \S+ \[([^:]+:\d+:\d+:\d+ [^\]]+)\] "(\S+)(?: (\S+) \S+)?" (\S+) (\S+) "[^"]*" "[^"]*" .* size:(\S+) \S+(?: +"?(\S+-\S+-\S+-\S+-[^\s"]+|-)"? "?(dvd|ftp|-)"?)?/';
|
const REGEX_LINE = '/\S+ \S+ \S+ \[([^:]+:\d+:\d+:\d+ [^\]]+)\] "(\S+)(?: (\S+) \S+)?" (\S+) (\S+) "[^"]*" "[^"]*" .* size:(\S+) \S+(?: +"?(\S+-\S+-\S+-\S+-[^\s"]+|-)"? "?(dvd|ftp|-)"?)?/';
|
||||||
const REGEX_PRODUCT = '#/(?:(tumbleweed)|distribution/(?:leap/)?(\d+\.\d+)|openSUSE(?:_|:/)(?:leap(?:_|:/))?(factory|tumbleweed|\d+\.\d+))#i';
|
const REGEX_PRODUCT = '#/(?:(tumbleweed)|distribution/(?:leap/)?(\d+\.\d+)|openSUSE(?:_|:/)(?:leap(?:_|:/))?(factory|tumbleweed|\d+\.\d+))#i';
|
||||||
|
const REGEX_IMAGE = '#(?:/(?:iso|live)/[^/]+-(DVD|NET|GNOME-Live|KDE-Live|Rescue-CD|Kubic-DVD)-[^/]+\.iso(?:\.torrent)?|/jeos/[^/]+-(JeOS)\.[^/]+\.(?:qcow2|vhdx|vmdk|vmx)$)#';
|
||||||
|
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$total_invalid = 0;
|
$total_invalid = 0;
|
||||||
$total_product = [];
|
$total_product = [];
|
||||||
$unique_product = [];
|
$unique_product = [];
|
||||||
|
$total_image_product = [];
|
||||||
|
|
||||||
$file = $argc == 2 ? $argv[1] : 'php://stdin';
|
$file = $argc == 2 ? $argv[1] : 'php://stdin';
|
||||||
$handle = fopen($file, 'r');
|
$handle = fopen($file, 'r');
|
||||||
@ -40,6 +42,15 @@ while (($line = fgets($handle)) !== false) {
|
|||||||
if (!isset($unique_product[$product][$uuid])) $unique_product[$product][$uuid] = 0;
|
if (!isset($unique_product[$product][$uuid])) $unique_product[$product][$uuid] = 0;
|
||||||
$unique_product[$product][$uuid] += 1;
|
$unique_product[$product][$uuid] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preg_match(REGEX_IMAGE, $match[3], $match_image)) {
|
||||||
|
// Remove empty match groups and select non-all match.
|
||||||
|
$values = array_filter($match_image);
|
||||||
|
$image = next($values);
|
||||||
|
if (!isset($total_image_product[$product])) $total_image_product[$product] = [];
|
||||||
|
if (!isset($total_image_product[$product][$image])) $total_image_product[$product][$image] = 0;
|
||||||
|
$total_image_product[$product][$image] += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$position = ftell($handle);
|
$position = ftell($handle);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
@ -54,6 +65,7 @@ echo json_encode([
|
|||||||
'total' => $total,
|
'total' => $total,
|
||||||
'total_product' => $total_product,
|
'total_product' => $total_product,
|
||||||
'unique_product' => $unique_product,
|
'unique_product' => $unique_product,
|
||||||
|
'total_image_product' => $total_image_product,
|
||||||
'total_invalid' => $total_invalid,
|
'total_invalid' => $total_invalid,
|
||||||
'bytes' => $position,
|
'bytes' => $position,
|
||||||
]) . "\n"; // JSON_PRETTY_PRINT for debugging.
|
]) . "\n"; // JSON_PRETTY_PRINT for debugging.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user