Este commit está contenido en:
Your Name
2020-05-28 16:48:03 +00:00
padre 96f6a157af
commit 52ad179104
Se han modificado 3 ficheros con 41 adiciones y 0 borrados

Ver fichero

@@ -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

Ver fichero

@@ -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'))

Ver fichero

@@ -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>