UnamSanctam / UnamWebPanel

MIT License
179 stars 58 forks source link

SELECT SUM(ms_hashrate) #349

Open anbu-squad opened 8 months ago

anbu-squad commented 8 months ago

Screenshot 2024-03-09 at 22-09-41 Unam Web Panel — Statistics

$queryCpuHashrateOnline = $conn->query("SELECT SUM(ms_hashrate) AS total_cpu_hashrate FROM miners WHERE ms_type = 'xmrig' AND ms_status = 2");
$resultCpuOnline = $queryCpuHashrateOnline->fetch(PDO::FETCH_ASSOC);
$totalCpuHashrateOnline = $resultCpuOnline['total_cpu_hashrate'] ?? 0;

$queryGpuHashrateOnline = $conn->query("SELECT SUM(ms_hashrate) AS total_gpu_hashrate FROM miners WHERE ms_type = 'ethminer' AND ms_status = 2");
$resultGpuOnline = $queryGpuHashrateOnline->fetch(PDO::FETCH_ASSOC);
$totalGpuHashrateOnline = $resultGpuOnline['total_gpu_hashrate'] ?? 0;

$queryCpuHashrateIdle = $conn->query("SELECT SUM(ms_hashrate) AS total_cpu_hashrate FROM miners WHERE ms_type = 'xmrig' AND ms_status = 3");
$resultCpuIdle = $queryCpuHashrateIdle->fetch(PDO::FETCH_ASSOC);
$totalCpuHashrateIdle = $resultCpuIdle['total_cpu_hashrate'] ?? 0;

$queryGpuHashrateIdle = $conn->query("SELECT SUM(ms_hashrate) AS total_gpu_hashrate FROM miners WHERE ms_type = 'ethminer' AND ms_status = 3");
$resultGpuIdle = $queryGpuHashrateIdle->fetch(PDO::FETCH_ASSOC);
$totalGpuHashrateIdle = $resultGpuIdle['total_gpu_hashrate'] ?? 0;

$formattedCpuHashrateOnline = unamFormatHashrate($totalCpuHashrateOnline);
$formattedGpuHashrateOnline = unamFormatHashrate($totalGpuHashrateOnline);

$formattedCpuHashrateIdle = unamFormatHashrate($totalCpuHashrateIdle);
$formattedGpuHashrateIdle = unamFormatHashrate($totalGpuHashrateIdle);
$minercardsdata = [
                                    [$larr['total'], '', $stats['total']],
                                    [$larr['mining'], 'bg-success', $stats['status_2'] ?? 0],
                                    ['CPU Hashrate (Online)', 'bg-info', $formattedCpuHashrateOnline],
                                    ['GPU Hashrate (Online)', 'bg-info', $formattedGpuHashrateOnline],
                                    ['CPU Hashrate (Idle)', 'bg-info', $formattedCpuHashrateIdle],
                                    ['GPU Hashrate (Idle)', 'bg-info', $formattedGpuHashrateIdle],
                                    ["{$larr['mining']} ({$larr['idle']})", 'bg-success', $stats['status_3'] ?? 0],
                                    [$larr['starting'], 'bg-warning', $stats['status_6'] ?? 0],
                                    [$larr['paused'], 'bg-warning', $stats['status_4'] ?? 0],
                                    [$larr['not_enough_free_vram'], 'bg-warning', $stats['status_5'] ?? 0],
                                    [$larr['error'], 'bg-danger', $stats['status_7'] ?? 0],
                                    [$larr['offline'], 'bg-danger', $stats['offline']]

                                ];
anbu-squad commented 8 months ago

I decided to add the total chashrate amount It seems correctly calculated But not sure

On Nanopool I have a hashrate performance significantly lower the complexity of the Igaret pool is possible

Alcinzal commented 8 months ago

It looks nice man, I made something similar: image

"Total Working Mining" means every miner that has a hashrate greater than 0.