简体   繁体   English

实时监控node.js服务器

[英]Realtime monitoring node.js server

Basicly, I need a tool that can draw realtime graphs for a collected data that calculated by a node server. 基本上,我需要一个工具,可以为节点服务器计算的收集数据绘制实时图形。

I tried to install Graphite , but got no luck on the installation(newbie in linux results too much dependencies installation failures). 我尝试安装Graphite ,但在安装上没有运气(linux中的新手导致太多依赖安装失败)。 So I'm looking for if there are other tools can do the similar jobb with easy install guide? 所以,我正在寻找是否有其他工具可以使用简单的安装指南做类似的jobb?

I also looked abit highcharts , but there is barely any documentation for node.js. 我也看了abit highcharts ,但是node.js几乎没有任何文档。 If anyone has experienced these tools and give some advices would be much appreciated! 如果有人经历过这些工具并给出一些建议将非常感谢!

Without knowing what kind of analytics data you are calculating and what type of graph you are using it is a little difficult to give you a good example. 在不知道您正在计算什么类型的分析数据以及您使用的图表类型的情况下,为您提供一个很好的示例有点困难。 But here it is anyway, this is for a simple scenario. 但无论如何,这是一个简单的场景。

When the server changes some analytics data, use socket.io to send a message to the client, containing the new analytics data. 当服务器更改某些分析数据时,请使用socket.io向客户端发送包含新分析数据的消息。 Something like this: 像这样的东西:

io.sockets.emit('analyticsUpdate', x, y);

On the client, create your Highcharts graph as normal but then add a load() event to the chart options, and use socket.io to retrieve the new data and update your chart like so: 在客户端上,正常创建Highcharts图,然后将load()事件添加到图表选项,并使用socket.io检索新数据并更新图表,如下所示:

    var chart;
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type: 'spline',
            events: {
                load: function() {
                    socket.on('analyticsUpdate', function (x, y) {
                         // Simple case where you have a single series
                         // and your data can simply be appended to the series

                         var series = this.series[0];
                         series.addPoint([x, y], true, true);
                    };
                }
            }
        }
    });

So whenever the server updates some analytics data, socket.io emits a message. 因此,只要服务器更新某些分析数据,socket.io就会发出消息。 The client is always listening for messages from the server, and so whenever it receives a new message it updates the graph. 客户端始终在侦听来自服务器的消息,因此每当收到新消息时,它都会更新图形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM