以下业务逻辑公式将聚合度量标准跟踪期时间段内的 Uptime 事件的值并计算其平均值。
Option Explicit ' Global variables declaration Dim SumOfValues 'accumulates values of events Dim NumOfValues 'counts number of events Sub OnRegistration (dispatcher) 'Registration of "UpTime" event to be sent to "OnUpTimeEvent" procedure dispatcher.RegisterByContractPartyAndService "OnUpTimeEvent" , "UpTime" End Sub Sub OnLoad (time) 'Initialization of global variables at the beginning of calculation SumOfValues = 0 NumOfValues = 0 End Sub Sub OnPeriodStart (time) 'We reinitialize SumOfValues & NumOfValues at the beginning of each tracking period SumOfValues = 0 NumOfValues = 0 End Sub Sub OnUpTimeEvent (upTimeEvent) 'We perform aggregation of event values, but only when inside a timeslot If Context.IsWithinTimeSlot Then SumOfValues = SumOfValues + upTimeEvent ("Value") NumOfValues= NumOfValues + 1 End If End Sub Function Result If NumOfValues = 0 Then Result = NULL Else Result = SumOfValues / NumOfValues End If End Function
版权所有 © 2012 CA。 保留所有权利。 | 就该主题发送电子邮件至 CA Technologies |