Syslog 우선순위 계산기

PRI 값을 디코딩하고, 필터 표현식을 구축하며, RFC 5424 시설/심각도 코드를 참조합니다.

PRI = (facility × 8) + severity  |  유효 범위: 0–191

RFC 5424 심각도 참조
코드키워드설명rsyslogjournald
0emerg시스템을 사용할 수 없음*.emergemerg
1alert즉시 조치를 취해야 함*.alertalert
2crit심각한 조건*.critcrit
3err오류 조건*.errerr
4warning경고 조건*.warningwarning
5notice정상적이나 중요한 조건*.noticenotice
6info정보 메시지*.infoinfo
7debug디버그 레벨 메시지*.debugdebug
RFC 5424 시설 참조
코드키워드설명
const FACILITIES = [ [0,'kern','Kernel messages'], [1,'user','User-level messages'], [2,'mail','Mail system'], [3,'daemon','System daemons'], [4,'auth','Security/authorization messages'], [5,'syslog','Messages generated internally by syslogd'], [6,'lpr','Line printer subsystem'], [7,'news','Network news subsystem'], [8,'uucp','UUCP subsystem'], [9,'cron','Clock daemon'], [10,'authpriv','Security/authorization messages (private)'], [11,'ftp','FTP daemon'], [12,'ntp','NTP subsystem'], [13,'security','Log audit'], [14,'console','Log alert'], [15,'solaris-cron','Scheduling daemon'], [16,'local0','Local use 0'], [17,'local1','Local use 1'], [18,'local2','Local use 2'], [19,'local3','Local use 3'], [20,'local4','Local use 4'], [21,'local5','Local use 5'], [22,'local6','Local use 6'], [23,'local7','Local use 7'], ]; const SEVERITIES = [ [0,'emerg','System is unusable'], [1,'alert','Action must be taken immediately'], [2,'crit','Critical conditions'], [3,'err','Error conditions'], [4,'warning','Warning conditions'], [5,'notice','Normal but significant'], [6,'info','Informational'], [7,'debug','Debug-level messages'], ]; // Populate selects and facility table (function init() { const fSel = document.getElementById('facilitySelect'); const sSel = document.getElementById('severitySelect'); const fTable = document.getElementById('facilityTable'); FACILITIES.forEach(([code, kw, desc]) => { const opt = document.createElement('option'); opt.value = code; opt.textContent = `${code} - ${kw} (${desc.substring(0, 25)}...)`; fSel.appendChild(opt); const tr = document.createElement('tr'); tr.innerHTML = `${code}${kw}${desc}`; fTable.appendChild(tr); }); fSel.value = '20'; // local4 default SEVERITIES.forEach(([code, kw, desc]) => { const opt = document.createElement('option'); opt.value = code; opt.textContent = `${code} - ${kw}`; sSel.appendChild(opt); }); sSel.value = '5'; // notice default })(); function decodePri() { const pri = parseInt(document.getElementById('priVal').value); const div = document.getElementById('decodeResult'); const section = document.getElementById('decodeResultSection'); section.style.display = 'block'; if (isNaN(pri) || pri < 0 || pri > 191) { div.innerHTML = 'Invalid PRI. Valid range: 0–191.'; return; } const facCode = Math.floor(pri / 8); const sevCode = pri % 8; const fac = FACILITIES[facCode] || [facCode, 'unknown', 'Unknown']; const sev = SEVERITIES[sevCode]; div.innerHTML = ` PRI ${pri} = facility ${facCode} + severity ${sevCode}
Facility: ${fac[0]} — ${fac[1]} (${fac[2]})
Severity: ${sev[0]} — ${sev[1]} (${sev[2]})

Filter expressions:
syslogd: ${fac[1]}.${sev[1]}
rsyslog: if $syslogfacility-text == '${fac[1]}' and $syslogseverity <= ${sevCode} then /var/log/custom.log
journald: journalctl SYSLOG_FACILITY=${facCode} PRIORITY=${sevCode}`; } function encodePri() { const fac = parseInt(document.getElementById('facilitySelect').value); const sev = parseInt(document.getElementById('severitySelect').value); const pri = fac * 8 + sev; const facInfo = FACILITIES[fac]; const sevInfo = SEVERITIES[sev]; const div = document.getElementById('encodeResult'); const section = document.getElementById('encodeResultSection'); section.style.display = 'block'; div.innerHTML = ` PRI = ${pri}
Facility ${fac} (${facInfo[1]}) × 8 + Severity ${sev} (${sevInfo[1]}) = ${pri}
Syslog header: <${pri}>
Filter: ${facInfo[1]}.${sevInfo[1]}`; }