Links list videos:
Các thứ chạy command laravel thì nằm hết trong func handler
$this->info() để in kêt quả ra ngoài màn hình.
câu lệnh tạo file command: php artisan make:command GetAllocationClusterDailyKubecost
php artisan kubecost:getAllocationClusterDaily
1) Option
Để hứng được option {--days=}
trong 1 function
Khi gõ command:
php artisan prometheus:pullAvailabilityMetrics --days=1
hoặc không có option cũng được:php artisan prometheus:pullAvailabilityMetrics
https://viblo.asia/p/laravel-commands-5y8Rr6YbRob3
2) Print result.
$this->info($days);
echo sprintf("Process date %s, workload %s, duration %s, counter 5xx = %s, counter total = %s, error rate = %s, Max mem/cpu = %s/%s, Avg mem/cpu = %s/%s, Outage Duration = %s successfully",
$date,
$workloadName,
$duration,
$counter5xx,
$counterTotal,
(isset($errorRate) ? $errorRate : 'NULL'),
$maxMemUsage,
$maxCpuUsage,
$avgMemUsage,
$avgCpuUsage,
$outageDuration,
) . PHP_EOL;