예제 #1
0
        /// <summary>
        /// Gets the mapping state for an indicator-value from a specific monitored systems.
        /// </summary>
        /// <param name="monitoredSystemID">The ID of the system that aquired the value.</param>
        /// <param name="pluginName">The plugin that aquired the value.</param>
        /// <param name="indicator">The indicator that aquired the value.</param>
        /// <param name="value">The indicator-value itself.</param>
        /// <returns>The appropiate mapping state.</returns>
        public MappingState GetMetricValue(int monitoredSystemID, string pluginName, string indicator, string value)
        {
            MappingState state = MappingState.OK;

            #region Metric Statements

            string statementWarning;
            string statementCritical;

            this.GetMetric(monitoredSystemID, pluginName, indicator, out statementWarning, out statementCritical);

            #endregion

            // Is the state Warning?
            if (statementWarning != "" && RegExUtility.Match(value, statementWarning))
            {
                state = MappingState.Warning;
            }

            // Is the state Critical?
            if (statementCritical != "" && RegExUtility.Match(value, statementCritical))
            {
                state = MappingState.Critical;
            }

            return(state);
        }
예제 #2
0
        /// <summary>
        /// Gets the filter-value for an indicator-value from a specific monitored systems.
        /// </summary>
        /// <param name="monitoredSystemID">The ID of the systems that aquired the value.</param>
        /// <param name="pluginName">The plugin that aquired the value.</param>
        /// <param name="indicator">The indicator that aquired the value.</param>
        /// <param name="value">The indicator-value itself.</param>
        /// <returns>True if the value passes the filter, false if not.</returns>
        public bool GetFilterValue(int monitoredSystemID, string pluginName, string indicator, string value)
        {
            Boolean passed = false;

            string filter = GetFilter(monitoredSystemID, pluginName, indicator);


            // filter only if there's a valid statement, else return all values
            if (filter == null || filter.Trim().Equals("") || filter.Trim().Equals("."))
            {
                passed = true;
                return(passed);
            }

            // does the value pass the filter
            if (RegExUtility.Match(value, filter))
            {
                passed = true;
            }

            return(passed);
        }
예제 #3
0
        /// <summary>
        /// Method to filter the values.
        /// </summary>
        /// <param name="unfilteredValues">The list of all values.</param>
        /// <returns>A list containing IndicatorName | IndicatorValue | IndicatorValueDataType.</returns>
        private List <Tuple <string, object, MISD.Core.DataType> > FilterValues(List <Tuple <string, object, MISD.Core.DataType> > unfilteredValues)
        {
            // Collect old filters
            List <Tuple <string, string> > oldFilters = new List <Tuple <string, string> >();

            foreach (IndicatorSettings current in this.Plugin.GetIndicatorSettings())
            {
                oldFilters.Add(new Tuple <string, string>(current.IndicatorName, current.FilterStatement));
            }
            // Get filter expression
            List <Tuple <string, string> > pluginFilters = ServerConnection.GetFilters(this.Plugin.GetName(), oldFilters.ToArray()).ToList();

            foreach (Tuple <string, string> current in pluginFilters)
            {
                if (current.Item1 == this.Indicator)
                {
                    this.Filter = current.Item2;
                }
            }

            // filter only if there's a valid statement, else return all values
            if (this.Filter == null || this.Filter.Trim().Equals("") || this.Filter.Trim().Equals("."))
            {
                return(unfilteredValues);
            }

            // Filter values
            List <Tuple <string, object, MISD.Core.DataType> > filteredValues = new List <Tuple <string, object, MISD.Core.DataType> >();

            foreach (Tuple <string, object, MISD.Core.DataType> current in unfilteredValues)
            {
                if (RegExUtility.Match(current.Item1, this.Filter))
                {
                    filteredValues.Add(current);
                }
            }
            return(filteredValues);
        }
        /// <summary>
        /// Method to filter the values.
        /// </summary>
        /// <param name="unfilteredValues">The list of all values.</param>
        /// <returns>A list containing IndicatorName | IndicatorValue | IndicatorValueDataType.</returns>
        private List <Tuple <string, object, MISD.Core.DataType> > FilterValues(List <Tuple <string, object, MISD.Core.DataType> > unfilteredValues)
        {
            // Get old or default filter from plugin assembly
            if (this.Filter == null)
            {
                foreach (IndicatorSettings indicatorSetting in this.Plugin.GetIndicatorSettings())
                {
                    if (indicatorSetting.IndicatorName == this.Indicator)
                    {
                        this.Filter = indicatorSetting.FilterStatement;
                    }
                }
            }

            // Get filter expression
            this.Filter = ServerConnection.Instance.GetFilter(this.Plugin.GetName(), this.Indicator, this.Filter);

            // Filter values
            if (this.Filter == null || this.Filter.Trim() == "" || this.Filter.Trim() == ".")
            {
                // Here is no filtering required.
                return(unfilteredValues);
            }
            else
            {
                List <Tuple <string, object, MISD.Core.DataType> > filteredValues = new List <Tuple <string, object, MISD.Core.DataType> >();
                foreach (Tuple <string, object, MISD.Core.DataType> current in unfilteredValues)
                {
                    if (RegExUtility.Match(current.Item1, this.Filter))
                    {
                        filteredValues.Add(current);
                    }
                }
                return(filteredValues);
            }
        }