Ejemplo n.º 1
0
        private IComparable GetDerivedGauge(CounterMonitorAttributeState attributeState)
        {
            if (attributeState.FirstValue == null)
            {
                return(null);
            }
            INumericUtil util = NumericUtils.GetUtil(attributeState.FirstValue.GetType());

            if (DifferenceMode)
            {
                if (attributeState.SecondValue == null)
                {
                    return(util.Zero);
                }
                if (attributeState.FirstValue.CompareTo(attributeState.SecondValue) < 0)
                {
                    return(util.Sub(util.Add(attributeState.FirstValue, _modulus), attributeState.SecondValue));
                }
                return(util.Sub(attributeState.FirstValue, attributeState.SecondValue));
            }
            return(attributeState.FirstValue);
        }
Ejemplo n.º 2
0
        protected override void ProcessNewMeasurement(ObjectName objectName, CounterMonitorAttributeState state, string errorCode, string errorDescription)
        {
            if (errorCode == null)
            {
                INumericUtil util         = NumericUtils.GetUtil(state.FirstValue.GetType());
                IComparable  derivedGauge = GetDerivedGauge(state);

                if (derivedGauge.CompareTo(state.Threshold) > 0 && Notify)
                {
                    MonitorNotification notif = new MonitorNotification(MonitorNotification.ThresholdValueExceeded, this,
                                                                        -1, null, null, derivedGauge,
                                                                        GetThreshold(objectName), ObservedAttribute,
                                                                        objectName);
                    SendNotification(notif);
                }
                if (Offset != null && util.Zero.CompareTo(Offset) != 0)
                {
                    while (derivedGauge.CompareTo(state.Threshold) > 0)
                    {
                        state.Threshold = util.Add(state.Threshold, Offset);
                        if (util.Zero.CompareTo(Modulus) != 0)
                        {
                            if (Modulus != null && util.Zero.CompareTo(Modulus) != 0 && state.Threshold.CompareTo(Modulus) > 0)
                            {
                                state.Threshold = util.Sub(state.Threshold, Modulus);
                            }
                        }
                    }
                }
            }
            else if (Notify)
            {
                MonitorNotification notif = new MonitorNotification(errorCode, this, -1, errorDescription, null, null, null, ObservedAttribute, objectName);
                SendNotification(notif);
            }
        }