시놀로지 로그 표시 잡음 필터 추가
This commit is contained in:
@@ -51,7 +51,7 @@ Control은 라즈베리파이/리눅스 호스트의 팬과 시스템 상태를
|
|||||||
- `public/api.php?action=settings_reset`: 설정 모달 값을 기본값으로 초기화
|
- `public/api.php?action=settings_reset`: 설정 모달 값을 기본값으로 초기화
|
||||||
- `public/api.php?action=touch_display_save`: `/boot/firmware/config.txt`, `/boot/firmware/cmdline.txt`에 DSI 터치 디스플레이 부팅 설정 저장
|
- `public/api.php?action=touch_display_save`: `/boot/firmware/config.txt`, `/boot/firmware/cmdline.txt`에 DSI 터치 디스플레이 부팅 설정 저장
|
||||||
- `public/api.php?action=touch_display_runtime_save`: DSI 터치 디스플레이 백라이트 밝기와 백라이트 전원 즉시 적용
|
- `public/api.php?action=touch_display_runtime_save`: DSI 터치 디스플레이 백라이트 밝기와 백라이트 전원 즉시 적용
|
||||||
- `public/api.php?action=synology_log`: 라즈베리파이에 저장된 시놀로지 원격 로그 최근 500줄 조회
|
- `public/api.php?action=synology_log`: 라즈베리파이에 저장된 시놀로지 원격 로그를 표시용 필터로 걸러 최근 500줄 조회
|
||||||
- `public/api.php?action=dmesg`: dmesg 로그 조회
|
- `public/api.php?action=dmesg`: dmesg 로그 조회
|
||||||
- `public/api.php?action=reboot`: 확인 단어와 관리자 암호 재검증 후 sudo reboot 실행
|
- `public/api.php?action=reboot`: 확인 단어와 관리자 암호 재검증 후 sudo reboot 실행
|
||||||
|
|
||||||
|
|||||||
+77
-3
@@ -121,9 +121,10 @@ function dmesg_log(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function text_log_tail(string $path, string $label, int $limit = 500): array
|
function text_log_tail(string $path, string $label, int $limit = 500, ?callable $lineFilter = null, int $displayLimit = 500): array
|
||||||
{
|
{
|
||||||
$limit = max(1, min(1000, $limit));
|
$limit = max(1, min(10000, $limit));
|
||||||
|
$displayLimit = max(1, min(1000, $displayLimit));
|
||||||
$stat = sh(['/usr/bin/stat', '-c', '%s|%Y', $path], true, 3);
|
$stat = sh(['/usr/bin/stat', '-c', '%s|%Y', $path], true, 3);
|
||||||
if ((int)$stat['code'] !== 0) {
|
if ((int)$stat['code'] !== 0) {
|
||||||
return [
|
return [
|
||||||
@@ -157,20 +158,93 @@ function text_log_tail(string $path, string $label, int $limit = 500): array
|
|||||||
preg_split('/\R/', trim((string)$tail['out'])) ?: [],
|
preg_split('/\R/', trim((string)$tail['out'])) ?: [],
|
||||||
static fn($line): bool => trim((string)$line) !== ''
|
static fn($line): bool => trim((string)$line) !== ''
|
||||||
));
|
));
|
||||||
|
$rawLineCount = count($lines);
|
||||||
|
if ($lineFilter !== null) {
|
||||||
|
$lines = array_values(array_filter($lines, $lineFilter));
|
||||||
|
}
|
||||||
|
if (count($lines) > $displayLimit) {
|
||||||
|
$lines = array_slice($lines, -$displayLimit);
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
'available' => true,
|
'available' => true,
|
||||||
'lines' => array_reverse($lines),
|
'lines' => array_reverse($lines),
|
||||||
'line_count' => count($lines),
|
'line_count' => count($lines),
|
||||||
|
'raw_line_count' => $rawLineCount,
|
||||||
'size_bytes' => $size,
|
'size_bytes' => $size,
|
||||||
'updated_at' => $mtime > 0 ? date('Y-m-d H:i:s', $mtime) : null,
|
'updated_at' => $mtime > 0 ? date('Y-m-d H:i:s', $mtime) : null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function synology_remote_log_visible(string $line): bool
|
||||||
|
{
|
||||||
|
if (str_contains($line, 'Last message ') && str_contains($line, 'suppressed by syslog-ng')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/\ssynotifyd\[\d+\]\s/', $line)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/\ssynoelasticd\[\d+\]\s/', $line)) {
|
||||||
|
$noise = [
|
||||||
|
'(UpsertByID)',
|
||||||
|
'(SetByID)',
|
||||||
|
'(DelByID)',
|
||||||
|
'(DelByQuery)',
|
||||||
|
'(Commit) Commit: fileindex_',
|
||||||
|
];
|
||||||
|
foreach ($noise as $needle) {
|
||||||
|
if (str_contains($line, $needle)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/\sfileindexd\[\d+\]\s/', $line)) {
|
||||||
|
$noise = [
|
||||||
|
'ProcessOP BEGIN: IndexUpsert',
|
||||||
|
'ProcessOP DONE!: IndexUpsert',
|
||||||
|
'ProcessOP SKIPPED: IndexUpsert',
|
||||||
|
'ProcessOP BEGIN: IndexReindex',
|
||||||
|
'ProcessOP DONE!: IndexReindex',
|
||||||
|
'ProcessOP SKIPPED: IndexReindex',
|
||||||
|
'(Process) Worker<',
|
||||||
|
'PrepareTmpOPtree',
|
||||||
|
'CheckClearOldTmpOPtree',
|
||||||
|
'BuildTree',
|
||||||
|
'Commit [fileindex_',
|
||||||
|
];
|
||||||
|
foreach ($noise as $needle) {
|
||||||
|
if (str_contains($line, $needle)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/\sscemd\[\d+\]\s/', $line)) {
|
||||||
|
$noise = [
|
||||||
|
'Could not open file `/dev/i2c-1',
|
||||||
|
'Could not open file `/dev/i2c/1',
|
||||||
|
'Fail to initLedBrightnessConfig',
|
||||||
|
'No brightness setting',
|
||||||
|
'Fail to init config list',
|
||||||
|
'Fail to set led brightness.',
|
||||||
|
];
|
||||||
|
foreach ($noise as $needle) {
|
||||||
|
if (str_contains($line, $needle)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function synology_remote_log(): array
|
function synology_remote_log(): array
|
||||||
{
|
{
|
||||||
return text_log_tail('/var/log/remote/synology/chaegeon.log', 'synology remote');
|
return text_log_tail('/var/log/remote/synology/chaegeon.log', 'synology remote', 5000, 'synology_remote_log_visible');
|
||||||
}
|
}
|
||||||
|
|
||||||
function command_first_line(array $cmd, bool $root = false, int $timeout = 3): string
|
function command_first_line(array $cmd, bool $root = false, int $timeout = 3): string
|
||||||
|
|||||||
Reference in New Issue
Block a user