예제 #1
0
        private void RecordMetricMap(WMIQuery thisQuery, ManagementBaseObject properties)
        {
            Dictionary <string, Object> propsOut = new Dictionary <string, Object>();

            propsOut.Add(EventTypeAttr, thisQuery.eventName);
            if (thisQuery.membersToRename != null && thisQuery.membersToRename.Count > 0)
            {
                foreach (var member in thisQuery.membersToRename)
                {
                    string label;
                    if (member.Value.Equals(PerfmonPlugin.UseCounterName))
                    {
                        label = member.Key;
                    }
                    else
                    {
                        label = member.Value;
                    }

                    var splitmem = member.Key.Trim().Split('.');
                    if (properties[splitmem[0]] is ManagementBaseObject)
                    {
                        var memberProps = ((ManagementBaseObject)properties[splitmem[0]]);
                        if (splitmem.Length == 2)
                        {
                            GetValueParsed(propsOut, label, memberProps.Properties[splitmem[1]]);
                        }
                        else
                        {
                            foreach (var memberProp in memberProps.Properties)
                            {
                                GetValueParsed(propsOut, memberProp.Name, memberProp);
                            }
                        }
                    }
                    else
                    {
                        GetValueParsed(propsOut, label, properties.Properties[member.Key]);
                    }
                }
            }
            else
            {
                foreach (PropertyData prop in properties.Properties)
                {
                    GetValueParsed(propsOut, prop.Name, prop);
                }
            }

            output.metrics.Add(propsOut);
        }
예제 #2
0
        private void RecordMetricMap(WMIQuery thisQuery, ManagementBaseObject properties)
        {
            Dictionary <string, Object> propsOut = new Dictionary <string, Object>
            {
                { EventTypeAttr, thisQuery.eventName }
            };

            /*if (rmembers != null)
             * {
             *
             *  membersToRename = new Dictionary<string, string>();
             *  foreach (var member in rmembers)
             *  {
             *      membersToRename.Add(member.counter, member.attrname);
             *  }
             * }*/

            if (thisQuery.queryAttributes != null && thisQuery.queryAttributes.Count > 0)
            {
                foreach (var queryAttribute in thisQuery.queryAttributes)
                {
                    string label;
                    if (queryAttribute.attrname.Equals(PerfmonPlugin.UseCounterName))
                    {
                        label = queryAttribute.counter;
                    }
                    else
                    {
                        label = queryAttribute.attrname;
                    }

                    var splitmem = queryAttribute.counter.Trim().Split('.');
                    if (properties[splitmem[0]] is ManagementBaseObject memberProps)
                    {
                        if (splitmem.Length == 2)
                        {
                            GetValueParsed(propsOut, label, memberProps.Properties[splitmem[1]], queryAttribute.parser);
                        }
                        else
                        {
                            foreach (var memberProp in memberProps.Properties)
                            {
                                GetValueParsed(propsOut, memberProp.Name, memberProp, queryAttribute.parser);
                            }
                        }
                    }
                    else
                    {
                        GetValueParsed(propsOut, label, properties.Properties[queryAttribute.counter], queryAttribute.parser);
                    }
                }
            }
            else
            {
                foreach (PropertyData prop in properties.Properties)
                {
                    GetValueParsed(propsOut, prop.Name, prop, "");
                }
            }

            PluginOutput.metrics.Add(propsOut);
        }