首页 文章

Siddhi查询网络利用率

提问于
浏览
0

我目前正在评估siddhi用于snmp环境 . POC围绕网络接口利用而构建 .

流定义为:

define stream interfaceStatsEvents (nodeName string, sdate double, ifSpeed long, ifIndex string, ifAdminStatus string, ifOperStatus string,
ifInDiscards long, ifInErrors long, ifOutDiscards long, ifOutErrors long, ifInOctets long, ifOutOctets long)

用于计算接口利用率的查询为:

from every (e1 = interfaceStatsEvents -> e2 = interfaceStatsEvents[nodeName == e1.nodeName and ifIndex == e1.ifIndex]) 
select e1.nodeName, e1.ifIndex, ((e2.ifInOctets - e1.ifInOctets) * 8 * 100) / (((e2.sdate - e1.sdate) / 1000) * e1.ifSpeed) as utilization 
insert into interfaceUtilization;

问题是查询似乎只运行一次 . 4 事件已添加到interfaceStatsEvents流中 . 期望为interfaceUtilization生成3个事件,而不是仅生成单个事件 .

有没有人知道原因或如何修复查询?

1 回答

  • 0

    这里的问题是你正在使用整个模式的每一个,因此这将输出每个e1,e2组合

    from every (e1 = interfaceStatsEvents -> e2 = interfaceStatsEvents[nodeName == e1.nodeName and ifIndex == e1.ifIndex])
    

    要获得预期的输出,即每个e1后跟e2,你必须将查询更改为

    from every e1 = interfaceStatsEvents -> e2 = interfaceStatsEvents[nodeName == e1.nodeName and ifIndex == e1.ifIndex]
    

    这里每个只适用于e1而不适用于e1-e2组合 .

相关问题