tail syslog
Este commit está contenido en:
@@ -14,6 +14,7 @@ services:
|
||||
- ./tail:/tail
|
||||
- /opt/docker/production/nginx/logs/access.log:/access.log:ro
|
||||
- /opt/docker/production/fail2ban/fail2ban.log:/fail2ban.log:ro
|
||||
- /var/log/syslog:/syslog:ro
|
||||
networks:
|
||||
mynet:
|
||||
ipv4_address: 172.28.0.101
|
||||
|
||||
@@ -38,4 +38,17 @@ app.disable('x-powered-by').use('/tail', (req, res, next) => {
|
||||
transform.destroy()
|
||||
})
|
||||
ts.createReadStream('/fail2ban.log', { beginAt: 'end' }).pipe(transform).pipe(res)
|
||||
}).use('/syslog', (req, res, next) => {
|
||||
res.header('Content-Type', 'text/event-stream')
|
||||
res.header('Connection', 'keep-alive')
|
||||
res.header('Cache-Control', 'no-cache')
|
||||
const transform = new Transform({
|
||||
transform: (chunk, enc, cb) => {
|
||||
cb(null, Buffer.from(chunk.toString().replace(/\n/, '\n\ndata: ')))
|
||||
}
|
||||
})
|
||||
res.on('close', () => {
|
||||
transform.destroy()
|
||||
})
|
||||
ts.createReadStream('/syslog', { beginAt: 'end' }).pipe(transform).pipe(res)
|
||||
}).use(express.static(__dirname + '/public'))
|
||||
|
||||
27
production/tail/tail/public/syslog.html
Archivo normal
27
production/tail/tail/public/syslog.html
Archivo normal
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
var source = new EventSource('/syslog'),
|
||||
timeout,
|
||||
scroll = true
|
||||
source.onmessage = function (event) {
|
||||
document.getElementById('result').innerHTML += '<li>' + event.data.replace(/ kernel:/i,' <span style="color:white;background-color:black;">kernel:</span>') + '</li>'
|
||||
timeout ? window.clearTimeout(timeout) : null
|
||||
timeout = window.setTimeout(window.location.reload, 4 * 60 * 1000, false)
|
||||
document.body.addEventListener("click", function(event) {
|
||||
scroll = scroll ? false : true
|
||||
})
|
||||
scroll ? window.scrollTo(0,document.body.scrollHeight) : null
|
||||
}
|
||||
source.onerror = function (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<ol id="result"></ol>
|
||||
</body>
|
||||
</html>
|
||||
Referencia en una nueva incidencia
Block a user