RRD用于测量CPU和内存使用情况

时间:2021-12-21 17:00:07

I would like to measure CPU and Memory usages for a server during continuous integration, And I would represent them into several graphs. I use Round Robin Database files (*.rrd) to do it in java with RRD4J library.

我想在持续集成期间测量服务器的CPU和内存使用情况,我会将它们表示为几个图形。我使用Round Robin Database文件(* .rrd)在带有RRD4J库的java中执行此操作。

I don't know how to define Round Robin Archives... I have tried this kind of RRA:

我不知道如何定义Round Robin Archives ...我尝试过这种RRA:

rrdDefCPU.addDatasource("CPU", DsType.COUNTER, 150, 0, 100);
rrdDefCPU.addArchive("RRA:AVERAGE:0.5:8:300"); 

Or

rrdDefCPU.addDatasource("CPU", DsType.COUNTER, 600, 0, 100);
rrdDefCPU.addArchive("RRA:AVERAGE:0.5:1:600"); 

In both cases, I record one measure per second, but I still 2 points on the graph for a period of 5 minutes. I want a graph with more of values ​on the same period.

在这两种情况下,我每秒记录一个度量,但我仍然在图表上有2个点,为期5分钟。我想要一个在同一时期有更多值的图表。

1 个解决方案

#1


0  

If you are not seeing more detail in your 5 minute interval, then I guess your step size is 5 minutes and you got it from copying the demo code. Please show your RrdDef constructor in your question.

如果你在5分钟的时间间隔内没有看到更多的细节,那么我猜你的步长是5分钟,你可以通过复制演示代码来获得它。请在您的问题中显示您的RrdDef构造函数。

RrdDef rrdDef = new RrdDef(rrdPath, startTime, 300); // step size 300s

Also, you probably want a GAUGE for cpu/memory usage, not a COUNTER which only goes up. If you use COUNTER by mistake, you get spiky output because RRD interprets a down move as an overflow and adds a very large amount to that observation.

此外,你可能想要一个用于CPU /内存使用的GAUGE,而不是一个仅上升的COUNTER。如果您错误地使用COUNTER,则会得到尖锐的输出,因为RRD将向下移动解释为溢出并为该观察添加了非常大的量。

In your code, you are varying the Heartbeat size, which combines with Xff to determine what size gap is tolerated in the input. If you have continuous data, you won’t see any effect from changing HB.

在您的代码中,您改变了Heartbeat大小,它与Xff结合以确定输入中容许的大小差距。如果您有连续数据,则不会看到更改HB的任何影响。

#1


0  

If you are not seeing more detail in your 5 minute interval, then I guess your step size is 5 minutes and you got it from copying the demo code. Please show your RrdDef constructor in your question.

如果你在5分钟的时间间隔内没有看到更多的细节,那么我猜你的步长是5分钟,你可以通过复制演示代码来获得它。请在您的问题中显示您的RrdDef构造函数。

RrdDef rrdDef = new RrdDef(rrdPath, startTime, 300); // step size 300s

Also, you probably want a GAUGE for cpu/memory usage, not a COUNTER which only goes up. If you use COUNTER by mistake, you get spiky output because RRD interprets a down move as an overflow and adds a very large amount to that observation.

此外,你可能想要一个用于CPU /内存使用的GAUGE,而不是一个仅上升的COUNTER。如果您错误地使用COUNTER,则会得到尖锐的输出,因为RRD将向下移动解释为溢出并为该观察添加了非常大的量。

In your code, you are varying the Heartbeat size, which combines with Xff to determine what size gap is tolerated in the input. If you have continuous data, you won’t see any effect from changing HB.

在您的代码中,您改变了Heartbeat大小,它与Xff结合以确定输入中容许的大小差距。如果您有连续数据,则不会看到更改HB的任何影响。