Removed sys_getloadavg() (#1188)

This commit is contained in:
Roman Kelesidis 2023-12-05 16:18:33 +07:00 committed by GitHub
commit ff46ec48a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 2 additions and 35 deletions

View file

@ -9,7 +9,6 @@
- Improved cookie management 🍪 [\#1171](https://github.com/torrentpier/torrentpier/pull/1171) ([belomaxorka](https://github.com/belomaxorka)) - Improved cookie management 🍪 [\#1171](https://github.com/torrentpier/torrentpier/pull/1171) ([belomaxorka](https://github.com/belomaxorka))
- Replaced strpos() with simplified realization [\#1172](https://github.com/torrentpier/torrentpier/pull/1172) ([belomaxorka](https://github.com/belomaxorka)) - Replaced strpos() with simplified realization [\#1172](https://github.com/torrentpier/torrentpier/pull/1172) ([belomaxorka](https://github.com/belomaxorka))
- Replaced some 'switch' with the 'match' expression [\#1173](https://github.com/torrentpier/torrentpier/pull/1173) ([belomaxorka](https://github.com/belomaxorka)) - Replaced some 'switch' with the 'match' expression [\#1173](https://github.com/torrentpier/torrentpier/pull/1173) ([belomaxorka](https://github.com/belomaxorka))
- Replaced some time() with TIMENOW constant [\#1174](https://github.com/torrentpier/torrentpier/pull/1174) ([belomaxorka](https://github.com/belomaxorka))
- Feature to ban specific torrent clients [\#1175](https://github.com/torrentpier/torrentpier/pull/1175) ([kovalensky](https://github.com/kovalensky)) - Feature to ban specific torrent clients [\#1175](https://github.com/torrentpier/torrentpier/pull/1175) ([kovalensky](https://github.com/kovalensky))
- Code re-formatting [\#1176](https://github.com/torrentpier/torrentpier/pull/1176) ([kovalensky](https://github.com/kovalensky)) - Code re-formatting [\#1176](https://github.com/torrentpier/torrentpier/pull/1176) ([kovalensky](https://github.com/kovalensky))
- Removed useless width for BBCode buttons [\#1180](https://github.com/torrentpier/torrentpier/pull/1180) ([belomaxorka](https://github.com/belomaxorka)) - Removed useless width for BBCode buttons [\#1180](https://github.com/torrentpier/torrentpier/pull/1180) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -38,14 +38,6 @@ foreach ($sql as $i => $query) {
echo '</table>'; echo '</table>';
echo '<div align="center"><pre>'; echo '<div align="center"><pre>';
if ($l = sys('la')) {
$l = explode(' ', $l);
for ($i = 0; $i < 3; $i++) {
$l[$i] = round($l[$i], 1);
}
echo "\n\n<b>loadavg: </b>$l[0] $l[1] $l[2]\n\n";
}
echo 'gen time: <b>' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . "</b> sec\n"; echo 'gen time: <b>' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . "</b> sec\n";
echo '</pre></div>'; echo '</pre></div>';

View file

@ -174,14 +174,6 @@ echo '</table>';
echo !$client_full ? '<p style = "text-align:right;">Simple stats for clients are being cached for one hour.</p>' : ''; echo !$client_full ? '<p style = "text-align:right;">Simple stats for clients are being cached for one hour.</p>' : '';
echo '<div align="center"><pre>'; echo '<div align="center"><pre>';
if ($l = sys('la')) {
$l = explode(' ', $l);
for ($i = 0; $i < 3; $i++) {
$l[$i] = round($l[$i], 1);
}
echo "\n\n<b>loadavg: </b>$l[0] $l[1] $l[2]\n\n";
}
echo 'gen time: <b>' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . "</b> sec\n"; echo 'gen time: <b>' . sprintf('%.3f', array_sum(explode(' ', microtime())) - TIMESTART) . "</b> sec\n";
echo '</pre></div>'; echo '</pre></div>';
echo '</body></html>'; echo '</body></html>';

View file

@ -334,18 +334,13 @@ function hide_bb_path(string $path): string
return ltrim(str_replace(BB_PATH, '', $path), '/\\'); return ltrim(str_replace(BB_PATH, '', $path), '/\\');
} }
function sys($param) function sys(string $param)
{ {
switch ($param) { switch ($param) {
case 'la':
return function_exists('sys_getloadavg') ? implode(' ', sys_getloadavg()) : 0;
break;
case 'mem': case 'mem':
return memory_get_usage(); return memory_get_usage();
break;
case 'mem_peak': case 'mem_peak':
return memory_get_peak_usage(); return memory_get_peak_usage();
break;
default: default:
trigger_error("invalid param: $param", E_USER_ERROR); trigger_error("invalid param: $param", E_USER_ERROR);
} }

View file

@ -54,7 +54,6 @@ foreach ($cron_jobs as $job) {
$msg[] = 'start'; $msg[] = 'start';
$msg[] = date('m-d'); $msg[] = date('m-d');
$msg[] = date('H:i:s'); $msg[] = date('H:i:s');
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid()); $msg[] = sprintf('%05d', getmypid());
$msg[] = $job['cron_title']; $msg[] = $job['cron_title'];
$msg = implode(LOG_SEPR, $msg); $msg = implode(LOG_SEPR, $msg);
@ -78,7 +77,6 @@ foreach ($cron_jobs as $job) {
$msg[] = ' end'; $msg[] = ' end';
$msg[] = date('m-d'); $msg[] = date('m-d');
$msg[] = date('H:i:s'); $msg[] = date('H:i:s');
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid()); $msg[] = sprintf('%05d', getmypid());
$msg[] = round(utime() - $cron_start_time) . '/' . round(utime() - TIMESTART) . ' sec'; $msg[] = round(utime() - $cron_start_time) . '/' . round(utime() - TIMESTART) . ' sec';
$msg = implode(LOG_SEPR, $msg); $msg = implode(LOG_SEPR, $msg);

View file

@ -53,14 +53,6 @@ if ($show_dbg_info) {
$stat .= humn_size(sys('mem_peak'), 2) . ' / '; $stat .= humn_size(sys('mem_peak'), 2) . ' / ';
$stat .= humn_size(sys('mem'), 2); $stat .= humn_size(sys('mem'), 2);
if ($l = sys('la')) {
$l = explode(' ', $l);
for ($i = 0; $i < 3; $i++) {
$l[$i] = round($l[$i], 1);
}
$stat .= " &nbsp;|&nbsp; " . $lang['LIMIT'] . " $l[0] $l[1] $l[2]";
}
$stat .= ' &nbsp;]'; $stat .= ' &nbsp;]';
if (SQL_DEBUG) { if (SQL_DEBUG) {

View file

@ -847,7 +847,7 @@ class Attach
$this->attach_filename = preg_replace('#([\xC2\xC3])([\x80-\xBF])#', 'chr(ord(\'$1\')<<6&0xC0|ord(\'$2\')&0x3F)', $this->attach_filename); $this->attach_filename = preg_replace('#([\xC2\xC3])([\x80-\xBF])#', 'chr(ord(\'$1\')<<6&0xC0|ord(\'$2\')&0x3F)', $this->attach_filename);
$this->attach_filename = rawurlencode($this->attach_filename); $this->attach_filename = rawurlencode($this->attach_filename);
$this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename); $this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename);
$this->attach_filename = trim($this->attach_filename . '_' .make_rand_str(13)); $this->attach_filename = trim($this->attach_filename . '_' . make_rand_str(13));
} }
$this->attach_filename = str_replace(['&amp;', '&', ' '], '_', $this->attach_filename); $this->attach_filename = str_replace(['&amp;', '&', ' '], '_', $this->attach_filename);
$this->attach_filename = str_replace('php', '_php_', $this->attach_filename); $this->attach_filename = str_replace('php', '_php_', $this->attach_filename);

View file

@ -891,7 +891,6 @@ class SqlDb
$msg[] = round($this->sql_starttime); $msg[] = round($this->sql_starttime);
$msg[] = date('m-d H:i:s', $this->sql_starttime); $msg[] = date('m-d H:i:s', $this->sql_starttime);
$msg[] = sprintf('%-6s', $q_time); $msg[] = sprintf('%-6s', $q_time);
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid()); $msg[] = sprintf('%05d', getmypid());
$msg[] = $this->db_server; $msg[] = $this->db_server;
$msg[] = Dev::short_query($this->cur_query); $msg[] = Dev::short_query($this->cur_query);