如何仅计算给定时间平均值

发布于 2024-08-20 14:07:59 字数 876 浏览 9 评论 0原文

目前,我在 rrdcgi 中使用以下 CDEF 设置来显示白天时间,即上午 7 点到晚上 11 点。是否有任何设置可以仅计算特定时间段的平均值。我需要显示 7 天的图表,因此平均值应该仅是 7 天的时间(上午 7 点到晚上 11 点)。

<h3>7 Day Performance</h3>
<RRD::GRAPH
        <RRD::GETVAR PATH>/rrdimg/7dayperformance.png
        --title="Performance"
        -w 1048 -h 266
        --imginfo '<IMG SRC=<RRD::GETVAR PATH>/rrdimg/%s WIDTH=%lu HEIGHT=%lu >'
        DEF:p1=<RRD::GETVAR PATH>/data1.rrd:data:AVERAGE
        DEF:p2=<RRD::GETVAR PATH>/data2.rrd:data:AVERAGE
        CDEF:p=p1,p2,2,AVG

        CDEF:gate=p1,POP,LTIME,86400,%,3600,/,FLOOR,DUP,23,LT,*,6,GT,INF,UNKN,IF   #for daytime image
        --end=midnight
        --start=end-7d
        AREA:gate#e0e0ff:"Day time"
        LINE2:p#ff6666:"performance"

编辑

我计划过滤掉上午 7 点到晚上 11 点的日志,并创建新的 rrd 文件来创建图表。这是一个好方法吗?我不这么认为,因为它还将包含空值。

Curretly I am using below CDEF settings in my rrdcgi to show day time i.e. 7AM to 11 PM. Is there any setting to calculate the average of perticular time period only. I need to show the 7 day graphs so the average should be of 7 day, day time (7AM to 11 PM) only.

<h3>7 Day Performance</h3>
<RRD::GRAPH
        <RRD::GETVAR PATH>/rrdimg/7dayperformance.png
        --title="Performance"
        -w 1048 -h 266
        --imginfo '<IMG SRC=<RRD::GETVAR PATH>/rrdimg/%s WIDTH=%lu HEIGHT=%lu >'
        DEF:p1=<RRD::GETVAR PATH>/data1.rrd:data:AVERAGE
        DEF:p2=<RRD::GETVAR PATH>/data2.rrd:data:AVERAGE
        CDEF:p=p1,p2,2,AVG

        CDEF:gate=p1,POP,LTIME,86400,%,3600,/,FLOOR,DUP,23,LT,*,6,GT,INF,UNKN,IF   #for daytime image
        --end=midnight
        --start=end-7d
        AREA:gate#e0e0ff:"Day time"
        LINE2:p#ff6666:"performance"

EDIT

I am planning to filter out the logs from 7AM to 11PM and create new rrd files to create graphs. Is this a good approch. I dont think so because it will also include the null values.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

卖梦商人 2024-08-27 14:07:59

当您使用VDEF计算平均值时,它将构建有效数据的平均值,因为您已经将非办公时间数据转换为UNKN,您所拥有的一切待办事项是使用 VDEF,您应该会得到您想要的东西。

When you use VDEF to calculate an average, it will build the average of the valid data, since you are already turning the non-office hours data to UNKN, all you have todo is to use VDEF and you should get what you are looking for.

女皇必胜 2024-08-27 14:07:59

这是否是同样的情况,如果我可以在图表中画一条第二条线,其中它在过去 7 天的同一时间范围内取平均值

(所以就像当前星期一中午 12:05 的值是 480 值减去星期日中午 12:05 的 1 天)或 1 天前 86,400 秒)或一周内 604800 秒,然后将所有 7 个数据平均为 1 个主要数据(从技术上讲,可能平均 6 个,因为我们正在尝试了解此时应该是什么),这就像基于历史数据来预测流量价值观。

12:05 太阳值=970

12:05 星期六值=900

12:05

星期五值=990 12:05 星期四值=940

12:05 星期三值=900

12:05 星期二值=940

5640/6,12:05 的平均值是 940,在图表中的 12:05 时,它会绘制它

,如果现在是周一,价值 = 480,但它应该是 940,我们的平均流量下降了 51% (不确定我是否需要做该线图,但我可以将其添加进去)

其设置的原因是由于互联网吨位每天随时发生流量水平变化,哈哈。所以说周二 1:05 可能会去

Could this be the same situation where if I could draw a 2nd line in graph where it averages on the same Time frame for the past 7 days

(so like current Monday time of 12:05PM is 480 value minus 1 day of sunday 12:05PM or 86,400 seconds ago for 1 day) or 604800 seconds in a week and then average all 7 into 1 main data (technically maybe average 6 cause we are trying to see what it SHOULD be at this moment) this is like projecting flow based on historical values.

12:05 Sun value=970

12:05 Sat value=900

12:05 Fri value=990

12:05 Thurs value=940

12:05 Wed value=900

12:05 Tues value=940

.

5640/6 and the average at 12:05 is 940 and at the 12:05 in the graph it would draw it

and if its now at monday for Value = 480 but it should be 940 we have a 51% drop or traffic from average (not sure if i need to do that line graph but i can add it in)

Reason why its setup is due to traffic level changes at all times per day due to internet tonnage lol. so say at like 1:05 Tuesday would probally go to

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文