Closed skloeckner closed 7 years ago
How are you running gwsocket? I'd try this (make sure port 7890 is opened)
1.- Start the websocket server
$ gwsocket &
2.- Send data from the server to the browser
$ tail -f /var/log/syslog > /tmp/wspipein.fifo
3.- Then create an html file, e.g., logs.html
that connects to the server (make sure you are pointing to the right IP/host where the gwsocket server is running and the port is open). In your case, it seems you are running gwsocket on the same machine as your syslog, so localhost would work.
<!DOCTYPE html>
<html lang="en">
<script>
window.onload = function() {
function $(selector) {
return document.querySelector(selector);
}
var socket = new WebSocket('ws://localhost:7890');
socket.onopen = function(event) {
$('#messages').innerHTML = 'Connected<br>';
};
socket.onmessage = function(event) {
$('#messages').innerHTML += event.data + '<br>';
};
socket.onclose = function(event) {
$('#messages').innerHTML = 'Disconnected ' + event.reason;
};
};
</script>
<div id="page-wrapper">
<pre id="messages">Connecting...</pre>
</div>
4.- Open the html file (Ctrl+o) and you should see your data from the server in the browser. Or just use file:///home/user/logs.html
Let me know if that helps.
I think I see now. I presumed it would just spit the output directly into my browser out of the pipe.
I did not know I needed to run some sort of web server or HTML file. From the demos, it did not seem necessary. Perhaps I presumed too much :D
Still, very cool indeed. Got it working.
I like your other project, goaccess. I was wondering if I could customize some of those subsections of the dashboard because it looks wicked awesome by default. I mainly just wanted straight output like this but for multiple commands on a ceph cluster. Perhaps I will review or open a ticket if I have a question.
Thanks for the quick reply.
That's right, you need to connect your web-page/app using a WebSocket to the gwsocket server. I'll make some changes to the documentation to make it a bit more clear. Thanks for the feedback :)
You can customize GoAccess' dashboard to a certain extend. Please take a look at the man page for more details.
Closing this. Feel free to reopen it if needed.
Hello there, I bookmarked this project a while ago and it turns out I need it as a temporary solution. Very neat indeed.
I followed the install instructions:
It appears to be using the pipes in /tmp/wspipein.fifo as I can cat /tmp/wspipein.fifo on Ubuntu 16.04, yet, nothing shows up in my browser.
I can confirm, gwsocket does get the requests and the pipe is working(I am just redirecting my syslog output to /tmp/wspipein.fifo):
Browser:
http://imgur.com/a/N7Ako
Am I missing something?