1
0
mirror of https://github.com/cp6/my-idlers.git synced 2024-11-16 23:42:32 +01:00

allow custom yabs option

This commit is contained in:
Ahmad Shamli 2024-05-19 21:24:36 +08:00 committed by GitHub
parent 25ff23d98d
commit cad54a32d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -188,15 +188,17 @@ class Yabs extends Model
$disk = $data['mem']['disk']; $disk = $data['mem']['disk'];
$gb5_single = $gb5_multi = $gb5_id = $gb6_single = $gb6_multi = $gb6_id = null; $gb5_single = $gb5_multi = $gb5_id = $gb6_single = $gb6_multi = $gb6_id = null;
foreach ($data['geekbench'] as $gb) { if ($data['geekbench']) {
if ($gb['version'] === 5) { foreach ($data['geekbench'] as $gb) {
$gb5_single = $gb['single']; if ($gb['version'] === 5) {
$gb5_multi = $gb['multi']; $gb5_single = $gb['single'];
$gb5_id = self::gb5IdFromURL($gb['url']); $gb5_multi = $gb['multi'];
} elseif ($gb['version'] === 6) { $gb5_id = self::gb5IdFromURL($gb['url']);
$gb6_single = $gb['single']; } elseif ($gb['version'] === 6) {
$gb6_multi = $gb['multi']; $gb6_single = $gb['single'];
$gb6_id = self::gb6IdFromURL($gb['url']); $gb6_multi = $gb['multi'];
$gb6_id = self::gb6IdFromURL($gb['url']);
}
} }
} }
@ -249,66 +251,84 @@ class Yabs extends Model
]); ]);
//fio //fio
foreach ($data['fio'] as $ds) { if ($data['fio']) {
if ($ds['bs'] === '4k') { foreach ($data['fio'] as $ds) {
$d4k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; if ($ds['bs'] === '4k') {
$d4k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d4k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d4k_mbps = self::KBstoMBs($ds['speed_rw']); $d4k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
} $d4k_mbps = self::KBstoMBs($ds['speed_rw']);
if ($ds['bs'] === '64k') { }
$d64k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; if ($ds['bs'] === '64k') {
$d64k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d64k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d64k_mbps = self::KBstoMBs($ds['speed_rw']); $d64k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
} $d64k_mbps = self::KBstoMBs($ds['speed_rw']);
if ($ds['bs'] === '512k') { }
$d512k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; if ($ds['bs'] === '512k') {
$d512k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d512k = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d512k_mbps = self::KBstoMBs($ds['speed_rw']); $d512k_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
} $d512k_mbps = self::KBstoMBs($ds['speed_rw']);
if ($ds['bs'] === '1m') { }
$d1m = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000; if ($ds['bs'] === '1m') {
$d1m_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s'; $d1m = ($ds['speed_rw'] > 999999) ? ($ds['speed_rw'] / 1000 / 1000) : $ds['speed_rw'] / 1000;
$d1m_mbps = self::KBstoMBs($ds['speed_rw']); $d1m_type = ($ds['speed_rw'] > 999999) ? 'GB/s' : 'MB/s';
$d1m_mbps = self::KBstoMBs($ds['speed_rw']);
}
} }
} }
DiskSpeed::create([ DiskSpeed::create([
'id' => $yabs_id, 'id' => $yabs_id,
'server_id' => $server_id, 'server_id' => $server_id,
'd_4k' => $d4k, 'd_4k' => isset($d4k) ? $d4k : 0.0,
'd_4k_type' => $d4k_type, 'd_4k_type' => isset($d4k_type) ? $d4k_type : 'MB/s',
'd_4k_as_mbps' => $d4k_mbps, 'd_4k_as_mbps' => isset($d4k_mbps) ? $d4k_mbps : 0.0,
'd_64k' => $d64k, 'd_64k' => isset($d64k) ? $d64k : 0.0,
'd_64k_type' => $d64k_type, 'd_64k_type' => isset($d64k_type) ? $d64k_type : 'MB/s',
'd_64k_as_mbps' => $d64k_mbps, 'd_64k_as_mbps' => isset($d64k_mbps) ? $d64k_mbps : 0.0,
'd_512k' => $d512k, 'd_512k' => isset($d512k) ? $d512k : 0.0,
'd_512k_type' => $d512k_type, 'd_512k_type' => isset($d512k_type) ? $d512k_type : 'MB/s',
'd_512k_as_mbps' => $d512k_mbps, 'd_512k_as_mbps' => isset($d512k_mbps) ? $d512k_mbps : 0.0,
'd_1m' => $d1m, 'd_1m' => isset($d1m) ? $d1m : 0.0,
'd_1m_type' => $d1m_type, 'd_1m_type' => isset($d1m_type) ? $d1m_type : 'MB/s',
'd_1m_as_mbps' => $d1m_mbps 'd_1m_as_mbps' => isset($d1m_mbps) ? $d1m_mbps : 0.0,
]); ]);
//iperf //iperf
foreach ($data['iperf'] as $st) { if ($data['iperf']) {
($has_ipv4) ? $match = 'IPv4' : $match = 'IPv6'; foreach ($data['iperf'] as $st) {
if ($st['mode'] === $match) { ($has_ipv4) ? $match = 'IPv4' : $match = 'IPv6';
if ($st['send'] !== "busy " || $st['recv'] !== "busy ") { if ($st['mode'] === $match) {
NetworkSpeed::create([ if ($st['send'] !== "busy " || $st['recv'] !== "busy ") {
'id' => $yabs_id, NetworkSpeed::create([
'server_id' => $server_id, 'id' => $yabs_id,
'location' => $st['loc'], 'server_id' => $server_id,
'send' => self::speedAsFloat($st['send']), 'location' => $st['loc'],
'send_type' => self::speedType($st['send']), 'send' => self::speedAsFloat($st['send']),
'send_as_mbps' => self::speedAsMbps($st['send']), 'send_type' => self::speedType($st['send']),
'receive' => self::speedAsFloat($st['recv']), 'send_as_mbps' => self::speedAsMbps($st['send']),
'receive_type' => self::speedType($st['recv']), 'receive' => self::speedAsFloat($st['recv']),
'receive_as_mbps' => self::speedAsMbps($st['recv']) 'receive_type' => self::speedType($st['recv']),
]); 'receive_as_mbps' => self::speedAsMbps($st['recv'])
]);
}
} }
} }
} else {
NetworkSpeed::create([
'id' => $yabs_id,
'server_id' => $server_id,
'location' => 'None',
'send' => 0.0,
'send_type' => 'MB/s',
'send_as_mbps' => 0.0,
'receive' => 0.0,
'receive_type' => 'MB/s',
'receive_as_mbps' => 0.0
]);
} }
//Update server //Update server
$update_server = DB::table('servers') $update_server = DB::table('servers')
->where('id', $server_id) ->where('id', $server_id)