Skip to content

Commit

Permalink
Daily log size calc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatacconi committed Mar 8, 2024
1 parent 150fc4e commit af6274d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/shareds/DiskUsage.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<v-card>
<v-card-title>Log's directory usage</v-card-title>
<v-card-title>Log's partition usage</v-card-title>
<v-card-text id="usage-data-area-container">
<template v-if="calcStatExecuted">
<div>
Expand Down Expand Up @@ -32,10 +32,10 @@
(
<strong>{{ diskUsageData['total-log-space-yesterday'] }}</strong> <span>{{ diskUsageData['unit'] }}</span> average logs per day
<template v-if=" diskUsageData['day-left'] != '' && diskUsageData['day-left'] > 0 && diskUsageData['day-left'] <= 365 ">
, {{ diskUsageData['day-left'] }} day/s left.
, {{ diskUsageData['day-left'] }} day/s left
</template>
<template v-else>
, -- day/s left.
, >365 day/s left
</template>
)
</span>
Expand Down
7 changes: 5 additions & 2 deletions routes/api/task-stat.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,16 +861,19 @@ static function (array $file) {
$free_space = $free_space_disp = disk_free_space($LOGS_DIR);
$used_space = $used_space_disp = $total_space - $free_space;

//[0] => /var/www/html/crunz-ui-test/./var/logs/00478b4c76f2f1a05be37b9c156ffe08_KO_202403051740_202403051740_aVsr.log

$date_focus = strtotime('yesterday');
$aFILE = glob($LOGS_DIR .'/'. '*_'.date("Y-m-d", $date_focus).'*_'.date("Y-m-d", $date_focus).'_*.log');
$aFILE = glob($LOGS_DIR .'/'. '*_'.date("Ymd", $date_focus).'*_'.date("Ymd", $date_focus).'*_*.log');

$total_space_yesterday = 0;
foreach ($aFILE as $file) {
$total_space_yesterday += filesize($file);
}

$num_len = strlen($used_space);
if($unit = 'AUTO'){

if($unit == 'AUTO'){
if($num_len < 4){
$unit = 'B';
}else if($num_len >= 4 && $num_len < 8){
Expand Down

0 comments on commit af6274d

Please sign in to comment.