feat: Update Proxmox extension with various improvements and bug fixes
- Change listStates method to accept nullable integer for limit parameter. - Modify TechnitiumDns class to return structured error messages on failure. - Enhance VNC and xterm popup routes with user authorization checks. - Update backups view to improve loading states and add unique keys for dynamic elements. - Refactor cloud-init view to ensure proper data binding and improve user experience. - Add wire:key attributes to various elements in views for better Livewire performance. - Improve error handling and user feedback in the firewall view. - Update server overview and statistics views to handle potential null values gracefully. - Add new migration files to extend database schema with user-set icons and notes for Proxmox nodes.
This commit is contained in:
@@ -31,15 +31,21 @@ class PollServerStatistics extends Command
|
||||
public function handle(): void
|
||||
{
|
||||
// Poll all servers regardless of status or power condition
|
||||
$servers = Server::all();
|
||||
$this->info('Polling statistics for ' . $servers->count() . ' servers...');
|
||||
$serverCount = Server::count();
|
||||
$this->info('Polling statistics for ' . $serverCount . ' servers...');
|
||||
|
||||
$successCount = 0;
|
||||
$errorCount = 0;
|
||||
$maxAutomaticStatistics = 24;
|
||||
|
||||
foreach ($servers as $server) {
|
||||
foreach (Server::with('node')->cursor() as $server) {
|
||||
try {
|
||||
if (!$server->node) {
|
||||
$this->warn('Server ID ' . $server->id . ' has no node assigned, skipping.');
|
||||
$errorCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$proxmox = new Proxmox;
|
||||
$status = $proxmox->request(
|
||||
'/nodes/' . $server->node->name . '/qemu/' . $server->vm_id . '/status/current'
|
||||
@@ -180,9 +186,7 @@ class PollServerStatistics extends Command
|
||||
$this->info('Bandwidth threshold: ' . $threshold . ' GiB');
|
||||
|
||||
$throttledCount = 0;
|
||||
$servers = Server::all();
|
||||
|
||||
foreach ($servers as $server) {
|
||||
foreach (Server::with('node')->cursor() as $server) {
|
||||
try {
|
||||
$monthlyTraffic = $this->calculateServerMonthlyTraffic($server);
|
||||
|
||||
@@ -210,8 +214,7 @@ class PollServerStatistics extends Command
|
||||
return 10;
|
||||
}
|
||||
|
||||
$totalTraffic = 0;
|
||||
$serverCount = 0;
|
||||
$trafficValues = [];
|
||||
|
||||
foreach ($allServers as $server) {
|
||||
$firstStat = ServerStatistics::where('server_id', $server->id)
|
||||
@@ -228,17 +231,18 @@ class PollServerStatistics extends Command
|
||||
$netinDiff = max(0, $latestStat->netin - $firstStat->netin);
|
||||
$netoutDiff = max(0, $latestStat->netout - $firstStat->netout);
|
||||
$totalBytes = $netinDiff + $netoutDiff;
|
||||
$totalTraffic += $totalBytes / (1024 * 1024 * 1024);
|
||||
$serverCount++;
|
||||
$trafficValues[] = $totalBytes / (1024 * 1024 * 1024);
|
||||
}
|
||||
}
|
||||
|
||||
if ($serverCount === 0) {
|
||||
if (empty($trafficValues)) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
$averageBandwidth = $totalTraffic / $serverCount;
|
||||
$threshold95Percent = $averageBandwidth * 0.95;
|
||||
// Calculate actual 95th percentile by sorting and taking the value at the 95th rank
|
||||
sort($trafficValues);
|
||||
$index = (int) ceil(0.95 * count($trafficValues)) - 1;
|
||||
$threshold95Percent = $trafficValues[$index];
|
||||
|
||||
return round(max($threshold95Percent, 10), 2);
|
||||
});
|
||||
@@ -273,7 +277,7 @@ class PollServerStatistics extends Command
|
||||
{
|
||||
try {
|
||||
$proxmox = new Proxmox;
|
||||
$config = $proxmox->request('/nodes/' . $server->node->name . '/qemu/' . $server->vm_id . '/config')->json()['data'];
|
||||
$config = $proxmox->request('/nodes/' . $server->node->name . '/qemu/' . $server->vm_id . '/config')->json()['data'] ?? [];
|
||||
|
||||
$updates = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user