internal PerformanceCounterData(string name, string description, PerformanceCounterType counterType, PerformanceCounterActionMapping[] mappings) { this.Name = name; this.Description = description; this.CounterType = counterType; this.Mappings = mappings; }
public CounterCreationData(String counterName, String counterHelp, PerformanceCounterType counterType) { this.counterName = counterName; this.counterHelp = counterHelp; this.counterType = counterType; }
public PerformanceCounter(String categoryName, String counterName, String instanceName, String machineName) { if (categoryName == null) { throw new ArgumentNullException("categoryName"); } if (counterName == null) { throw new ArgumentNullException("counterName"); } if (instanceName == null) { throw new ArgumentNullException("instanceName"); } if (machineName == null) { throw new ArgumentNullException("machineName"); } this.categoryName = categoryName; this.counterName = counterName; this.instanceName = instanceName; this.machineName = machineName; this.counterType = (PerformanceCounterType) Enum.Parse(typeof(PerformanceCounterType), counterName); }
public CounterDesc(string name, string desc, PerformanceCounterType type, Action <BasePerfMonAppender, CounterDesc> setter) { this.Name = name; this.Desc = desc; this.type = type; this.setter = setter; }
private static void Create(string categoryName, string counterHelp, PerformanceCounterType counterType) { var cd = new CounterCreationDataCollection { new CounterCreationData("Value", counterHelp, counterType) }; switch (counterType) { case PerformanceCounterType.AverageCount64: case PerformanceCounterType.AverageTimer32: cd.Add(new CounterCreationData("ValueBase", counterHelp, PerformanceCounterType.AverageBase)); break; case PerformanceCounterType.CounterMultiTimer: case PerformanceCounterType.CounterMultiTimerInverse: case PerformanceCounterType.CounterMultiTimer100Ns: case PerformanceCounterType.CounterMultiTimer100NsInverse: cd.Add(new CounterCreationData("ValueBase", counterHelp, PerformanceCounterType.CounterMultiBase)); break; case PerformanceCounterType.RawFraction: cd.Add(new CounterCreationData("ValueBase", counterHelp, PerformanceCounterType.RawBase)); break; case PerformanceCounterType.SampleFraction: cd.Add(new CounterCreationData("ValueBase", counterHelp, PerformanceCounterType.SampleBase)); break; } PerformanceCounterCategory.Create(categoryName, counterHelp, PerformanceCounterCategoryType.SingleInstance, cd); }
public PerfCounterCreationData(PerformanceCounterName name, PerformanceCounterType type, string displayName, string helpText) { counterName = name; counterType = type; counterDisplayName = displayName; counterHelpText = helpText; }
internal PerformanceCounterDefinition(string categoryName, string counterName, string counterHelp, PerformanceCounterType counterType) { _categoryName = categoryName; _counterName = counterName; _counterHelp = counterHelp; _counterType = counterType; }
internal static void RegisterCounters(string installationPath) { string filename = Path.Combine(installationPath, "Microsoft.Exchange.Diagnostics.Service.Common.EdsPerformanceCounters.xml"); SafeXmlDocument safeXmlDocument = new SafeXmlDocument(); safeXmlDocument.Load(filename); string text = LoadEdsPerformanceCounters.ReadStringElement(safeXmlDocument, "Category/Name"); Logger.LogInformationMessage("Found performance counter category {0}", new object[] { text }); if (!LoadEdsPerformanceCounters.SafeExists(text)) { Logger.LogInformationMessage("Registering EDS performance counters.", new object[0]); CounterCreationDataCollection counterCreationDataCollection = new CounterCreationDataCollection(); XmlNodeList xmlNodeList = safeXmlDocument.SelectNodes("Category/Counters/Counter"); using (xmlNodeList) { for (int i = 0; i < xmlNodeList.Count; i++) { string text2 = LoadEdsPerformanceCounters.ReadStringElement(xmlNodeList[i], "Name"); PerformanceCounterType counterType = (PerformanceCounterType)Enum.Parse(typeof(PerformanceCounterType), LoadEdsPerformanceCounters.ReadStringElement(xmlNodeList[i], "Type"), true); counterCreationDataCollection.Add(new CounterCreationData(text2, string.Empty, counterType)); Logger.LogInformationMessage("Loaded counter {0}", new object[] { text2 }); } } LoadEdsPerformanceCounters.SafeCreate(text, counterCreationDataCollection); return; } Logger.LogInformationMessage("Counters are already registered.", new object[0]); }
/// <summary> /// Add a custom performance counter. Counter won't be installed until InstallCounters() is called. /// </summary> public static void TrackCustomCounter(string name, string helpText, PerformanceCounterType type, TimeSpan sampleInterval, int maxSamplesToCache, string divisor) { if (m_Sampling) { return; } CounterCreationData ccd = new CounterCreationData(); ccd.CounterName = name; ccd.CounterHelp = helpText; ccd.CounterType = type; PerfHistory h = GetHistory(name, "Wisp", ""); try { h.Divisor = float.Parse(divisor); } catch (FormatException exc) { Log1.Logger("Performance").Error("Custom Counter " + h.Key + " has an invalid [Divisor] - must be in float format!"); h.Divisor = 1; } h.SampleInterval = sampleInterval; h.HelpText = helpText; h.MaxHistorySamplesToKeep = maxSamplesToCache; h.IsCustom = true; _Counters.Add(ccd); Log1.Logger("Performance").Debug("Tracking custom performance counter [" + name + "|Wisp|" + "]"); }
public Task RunPerformanceAsync(string name, PerformanceCounterType performanceCounterType, TimeframeType timeframeType, IProgress <Tuple <PerformanceCounterType, PerfCounterModel> > progress) { throw new NotImplementedException(); }
private void Add() { this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Adding Performance Counter Category: {0}", this.CategoryName)); CounterCreationDataCollection colCounterCreationData = new CounterCreationDataCollection(); colCounterCreationData.Clear(); if (PerformanceCounterCategory.Exists(this.CategoryName)) { this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Removing Performance Counter Category: {0}", this.CategoryName)); PerformanceCounterCategory.Delete(this.CategoryName); } foreach (ITaskItem counter in this.CounterList) { string counterName = counter.GetMetadata("CounterName"); string counterHelp = counter.GetMetadata("CounterHelp"); PerformanceCounterType counterType = (PerformanceCounterType)Enum.Parse(typeof(PerformanceCounterType), counter.GetMetadata("CounterType")); this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Adding Performance Counter: {0}", counterName)); CounterCreationData objCreateCounter = new CounterCreationData(counterName, counterHelp, counterType); colCounterCreationData.Add(objCreateCounter); } if (colCounterCreationData.Count > 0) { PerformanceCounterCategoryType categoryType = PerformanceCounterCategoryType.SingleInstance; if (this.MultiInstance) { categoryType = PerformanceCounterCategoryType.MultiInstance; } this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Creating Performance Counter Category: {0}", this.CategoryName)); PerformanceCounterCategory.Create(this.CategoryName, this.CategoryHelp, categoryType, colCounterCreationData); } }
/// <summary> /// Returns if a PerformanceCounterType is a base type for another counter type /// (AverageBase, CounterMultiBase, RawBase y SampleBase are Base Types) /// </summary> /// <param name="counterType">PerformanceCounterType</param> /// <returns>returns true if the type is a based counter type, otherwise false</returns> private static bool IsBaseType(PerformanceCounterType counterType) { return((counterType == PerformanceCounterType.AverageBase) || (counterType == PerformanceCounterType.CounterMultiBase) || (counterType == PerformanceCounterType.RawBase) || (counterType == PerformanceCounterType.SampleBase)); }
internal PerformanceCounterSample(string path, string instanceName, double cookedValue, UInt64 rawValue, UInt64 secondValue, uint multiCount, PerformanceCounterType counterType, UInt32 defaultScale, UInt64 timeBase, DateTime timeStamp, UInt64 timeStamp100nSec, UInt32 status) { _path = path; _instanceName = instanceName; _cookedValue = cookedValue; _rawValue = rawValue; _secondValue = secondValue; _multiCount = multiCount; _counterType = counterType; _defaultScale = defaultScale; _timeBase = timeBase; _timeStamp = timeStamp; _timeStamp100nSec = timeStamp100nSec; _status = status; }
public IICPerformanceCounter CreateCounter(string counterName, PerformanceCounterType counterType) { IICPerformanceCounter counter = new IICPerformanceCounter(); counter._rawAttr = new IICPerformanceCounterAttribute(counterName, counterType); _counters.Add(counter); return counter; }
public CounterDescriptor(string name, string help, PerformanceCounterType type) : this() { Name = name; Help = help; Type = type; }
/// <summary> /// Ensures the with category. /// </summary> /// <param name="category">The category.</param> /// <param name="counterName">Name of the counter.</param> /// <param name="type">The type.</param> /// <param name="deep">if set to <see langword="true"/> [deep].</param> /// <returns></returns> private PerformanceCounter EnsureWithCategory(string category, string counterName, PerformanceCounterType type, bool deep) { cacheLock.EnterUpgradeableReadLock(); try { if (categoryDict.ContainsKey(category)) { IDictionary <string, PerformanceCounter> perf = categoryDict[category]; return(EnsureCounter(category, counterName, type, perf)); } else { if (deep) { return(null); } return(EnsureCounter(category, counterName, type, null)); } } finally { cacheLock.ExitUpgradeableReadLock(); } }
private CounterCreationData CreateCounter( string counterName, PerformanceCounterType counterType) { return(new CounterCreationData( counterName, counterName, counterType)); }
public static PerformanceCounterType BaseCounterType( this PerformanceCounterType counterType) { switch (counterType) { case PerformanceCounterType.AverageTimer32: case PerformanceCounterType.AverageCount64: return(PerformanceCounterType.AverageBase); case PerformanceCounterType.CounterMultiTimer: case PerformanceCounterType.CounterMultiTimer100Ns: case PerformanceCounterType.CounterMultiTimerInverse: case PerformanceCounterType.CounterMultiTimer100NsInverse: return(PerformanceCounterType.CounterMultiBase); case PerformanceCounterType.RawFraction: return(PerformanceCounterType.RawBase); case PerformanceCounterType.SampleFraction: case PerformanceCounterType.SampleCounter: return(PerformanceCounterType.SampleBase); default: throw new ArgumentException(""); } }
internal PerformanceCounterSample(string path, string instanceName, double cookedValue, UInt64 rawValue, UInt64 secondValue, uint multiCount, PerformanceCounterType counterType, UInt32 defaultScale, UInt64 timeBase, DateTime timeStamp, UInt64 timeStamp100nSec, UInt32 status) { Path = path; InstanceName = instanceName; CookedValue = cookedValue; RawValue = rawValue; SecondValue = secondValue; MultipleCount = multiCount; CounterType = counterType; DefaultScale = defaultScale; TimeBase = timeBase; Timestamp = timeStamp; Timestamp100NSec = timeStamp100nSec; Status = status; }
public async Task RunPerformanceAsync(string name, PerformanceCounterType performanceCounterType, TimeframeType timeframeType, IProgress <Tuple <PerformanceCounterType, PerfCounterModel> > progress) { await Task.Run(async() => { var random = new Random(); int prevPoint = 0; while (true) { await Task.Yield(); int point = prevPoint > 0 ? prevPoint : startPoint; // Update the point price by a random factor of the range percent int number = (point + (int)(random.NextDouble() * random.Next(0, 30))) - random.Next(0, 50); if (number < minPoint) { number = random.Next(0, 10); } else if (number > maxPoint) { number = 100; } progress.Report(new Tuple <PerformanceCounterType, PerfCounterModel>(performanceCounterType, new PerfCounterModel { Timestamp = DateTime.Now, Value = number })); await Task.Delay(250); prevPoint = number; } }).ConfigureAwait(false); }
public CounterCreationDataInfo(string counterName, string instanceName, PerformanceCounterType counterType, string counterHelp) { this.counterName = counterName; this.instanceName = instanceName; this.counterHelp = counterHelp; this.counterType = counterType; }
void IPacket.ReadFields(PacketDefinition definition, SerializedPacket packet) { switch (definition.Version) { case 1: long baseValue; long counterTimeStamp; long counterFrequency; long systemFrequency; long timeStamp; long timeStamp100nSec; packet.GetField("baseValue", out baseValue); packet.GetField("counterTimeStamp", out counterTimeStamp); packet.GetField("counterFrequency", out counterFrequency); packet.GetField("systemFrequency", out systemFrequency); packet.GetField("timeStamp", out timeStamp); packet.GetField("timeStamp100nSec", out timeStamp100nSec); //conceptually we shouldn't persist this - it's always the same and it's always on our metric, however //we need it here for deserialization purposes because our metric packet object isn't available during //the deserialization process. int rawCounterType; packet.GetField("counterType", out rawCounterType); PerformanceCounterType counterType = (PerformanceCounterType)rawCounterType; //Now, create our sample object from this data m_Sample = new CounterSample((long)base.RawValue, baseValue, counterFrequency, systemFrequency, timeStamp, timeStamp100nSec, counterType, counterTimeStamp); break; default: throw new GibraltarPacketVersionException(definition.Version); } }
public static PerformanceCounter CreateSimpleCounter(string counterName, string counterHelp, PerformanceCounterType counterType, string categoryName, string categoryHelp) { CounterCreationDataCollection counterCollection = new CounterCreationDataCollection(); CounterCreationData counter = new CounterCreationData(counterName, counterHelp, counterType); counterCollection.Add(counter); if (PerformanceCounterCategory.Exists(categoryName)) { PerformanceCounterCategory.Delete(categoryName); } PerformanceCounterCategory appCategory = PerformanceCounterCategory.Create(categoryName, categoryHelp, PerformanceCounterCategoryType.SingleInstance, counterCollection); PerformanceCounter appCounter = new PerformanceCounter(categoryName, counterName, false); appCounter.RawValue = 0; return(appCounter); }
private BasicPerformanceCounter CreatePerformanceCounter(PerformanceCounterType type) { BasicPerformanceCounter counter = null; switch (type) { case PerformanceCounterType.CPU_Time: case PerformanceCounterType.RAM_Used: case PerformanceCounterType.DISK_Read: case PerformanceCounterType.DISK_Write: case PerformanceCounterType.Custom: counter = new BasicPerformanceCounter(type, _enabled); break; case PerformanceCounterType.NET_Received: case PerformanceCounterType.NET_Sent: counter = new NetworkPerformanceCounter(type, _enabled); break; } Debug.Assert(counter != null); _counters.Add(counter); return(counter); }
public static PerformanceCounter CreateCounter(string name, string description, PerformanceCounterType type) { if (_countersAllowed == false) { return null; } string categoryName = Application.ProductName + "." + name; if (PerformanceCounterCategory.Exists(categoryName) == false) { CounterCreationDataCollection counters = new CounterCreationDataCollection(); CounterCreationData counterData = new CounterCreationData(); counterData.CounterName = name; counterData.CounterHelp = description; counterData.CounterType = type; counters.Add(counterData); PerformanceCounterCategory category = PerformanceCounterCategory.Create(categoryName, "Category for the counters of " + Application.ProductName, PerformanceCounterCategoryType.SingleInstance, counters); } PerformanceCounter counter = new PerformanceCounter(categoryName, name, string.Empty, false); return counter; }
/// <summary> /// Gets the counter. /// </summary> /// <param name="category">The category.</param> /// <param name="counterName">Name of the counter.</param> /// <param name="type">The type.</param> /// <returns></returns> private PerformanceCounter GetCounter(string category, string counterName, PerformanceCounterType type) { if (string.IsNullOrEmpty(category) || string.IsNullOrEmpty(counterName)) { return(null); } try { PerformanceCounter pc = this.EnsureWithCategory(category, counterName, type, false); if (pc == null) { return(null); } pc.InstanceName = AppDomain.CurrentDomain.FriendlyName; return(pc); } catch (Exception ex) { Trace.WriteLine("Get counter failed! " + ex, "EnterpriseLoggingService.GetCounter"); } return(null); }
public async Task RunPerformanceAsync(string name, PerformanceCounterType performanceCounterType, TimeframeType timeframeType, IProgress<Tuple<PerformanceCounterType, PerfCounterModel>> progress) { await Task.Run(async () => { var random = new Random(); int prevPoint = 0; while (true) { await Task.Yield(); int point = prevPoint > 0 ? prevPoint : startPoint; // Update the point price by a random factor of the range percent int number = (point + (int)(random.NextDouble() * random.Next(0, 30))) - random.Next(0, 50); if (number < minPoint) { number = random.Next(0, 10); } else if (number > maxPoint) { number = 100; } progress.Report(new Tuple<PerformanceCounterType, PerfCounterModel>(performanceCounterType, new PerfCounterModel { Timestamp = DateTime.Now, Value = number })); await Task.Delay(250); prevPoint = number; } }).ConfigureAwait(false); }
public IPerformanceCounterNumeric AttachNumericCounter(string counterName, PerformanceCounterType counterType = PerformanceCounterType.CountOfItems) { // Check numeric counter type. switch (counterType) { case PerformanceCounterType.CountOfItems: case PerformanceCounterType.CountPerSecond: case PerformanceCounterType.AverageValue: case PerformanceCounterType.DeltaValue: case PerformanceCounterType.PercentValue: case PerformanceCounterType.ElapsedTime: break; default: throw new ArgumentException(string.Format(Resources.Strings.InvalidNumericCounterType, counterType)); } var counter = new PerformanceCounterNumeric(counterName, counterType, Severity.None, this); // Add new performance counter into the child collection. using (new WriteLock(Lock)) { _child.Add(counter); _childCounters.Add(counter); } return(counter); }
/// <summary> /// Get the PerformanceCounterType of the base type associated to this counter /// </summary> /// <param name="type">PerformanceCounterType of the counter to be added</param> /// <returns>returns PerformanceCounterType for the base counter in case the PerformanceCounterType passed as parameter requires a base counter, otherwise null</returns> /// <seealso cref="PerformanceCounterType"/> internal static PerformanceCounterType?GetBaseType(PerformanceCounterType type) { PerformanceCounterType?rtnValue = null; switch (type) { case PerformanceCounterType.AverageCount64: case PerformanceCounterType.AverageTimer32: rtnValue = PerformanceCounterType.AverageBase; break; case PerformanceCounterType.RawFraction: rtnValue = PerformanceCounterType.RawBase; break; case PerformanceCounterType.CounterMultiTimer: case PerformanceCounterType.CounterMultiTimerInverse: case PerformanceCounterType.CounterMultiTimer100Ns: case PerformanceCounterType.CounterMultiTimer100NsInverse: rtnValue = PerformanceCounterType.CounterMultiBase; break; case PerformanceCounterType.SampleCounter: case PerformanceCounterType.SampleFraction: rtnValue = PerformanceCounterType.SampleBase; break; default: rtnValue = null; break; } return(rtnValue); }
protected PerformanceCounterDefinition AddDefinition(string counterName, string counterHelp, PerformanceCounterType counterType) { var definition = new PerformanceCounterDefinition(_categoryName, counterName, counterHelp, counterType); _counterDefinitions.Add(definition.GetCreationData()); return definition; }
public CounterCreationData (string counterName, string counterHelp, PerformanceCounterType counterType) { CounterName = counterName; CounterHelp = counterHelp; CounterType = counterType; }
public IICPerformanceCounter CreateCounter(string counterName, PerformanceCounterType counterType) { IICPerformanceCounter counter = new IICPerformanceCounter(); counter._rawAttr = new IICPerformanceCounterAttribute(counterName, counterType); _counters.Add(counter); return(counter); }
/// <summary> /// Constructor /// </summary> /// <param name="name">Name of the counter</param> /// <param name="info">Information about the counter</param> /// <param name="counterType">Type of counter</param> /// <param name="baseAutoIncreased">if true, each time the performance counter increased/decreased its base will be increased/decrease on 1 point. Otherwise all that base management will need to be handed on client code</param> /// <seealso cref="PerformanceCounterType"/> public CounterAttribute(string name, string info, PerformanceCounterType counterType, bool baseAutoIncreased) : base() { this.name = name; this.info = info; this.counterType = counterType; this.baseAutoIncreased = baseAutoIncreased; }
public FluentCategoryConfigurator AddCounter( string name, string help = "", PerformanceCounterType type = PerformanceCounterType.NumberOfItems32) { _counters.Add(new CounterCreationData(name, help, type)); return this; }
public CounterCreationData(string counterName, string counterHelp, PerformanceCounterType counterType) { name = counterName; help = counterHelp; type = counterType; }
/// <summary> /// Constructor /// </summary> /// <param name="name">Name of the counter</param> /// <param name="info">Information about the counter</param> /// <param name="counterType">Type of counter</param> /// <param name="baseAutoIncreased">if true, each time the performance counter increased/decreased its base will be increased/decrease on 1 point. Otherwise all that base management will need to be handed on client code</param> /// <seealso cref="PerformanceCounterType"/> public PerformanceCounterAttribute(string name, string info, PerformanceCounterType counterType, bool baseAutoIncreased) : base() { this._name = name; this._info = info; this._counterType = counterType; this._baseAutoIncreased = baseAutoIncreased; }
void CreateCounter(string name, PerformanceCounterType type, CounterCreationDataCollection collection) { var ccd = new CounterCreationData(); ccd.CounterName = name; ccd.CounterType = type; collection.Add(ccd); }
// Methods public STPPerformanceCounter( string counterName, string counterHelp, PerformanceCounterType pcType) { this._counterName = counterName; this._counterHelp = counterHelp; this._pcType = pcType; }
public static PerformanceCounterData CreatePerformanceCounterData(string category, string format, string name, string help, PerformanceCounterType type) { return new PerformanceCounterData() { Category = category, Name = string.Format(format, name), Help = help, Type = type, }; }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, PerformanceCounterType counterType, long counterTimeStamp) { this.rawValue = rawValue; this.baseValue = baseValue; this.timeStamp = timeStamp; this.counterFrequency = counterFrequency; this.counterType = counterType; this.timeStamp100nSec = timeStamp100nSec; this.systemFrequency = systemFrequency; this.counterTimeStamp = counterTimeStamp; }
protected PerformanceCounterAttribute( string categoryName, string counterName, PerformanceCounterType counterType, PerformanceCounterType? baseCounterType) { this.CategoryName = categoryName; this.CounterName = counterName; this.BaseCounterName = counterName + "Base"; this.CounterType = counterType; this.BaseCounterType = baseCounterType; this.CategoryType=PerformanceCounterCategoryType.MultiInstance; this.sharedDataRef = sharedData; }
public CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, PerformanceCounterType counterType) : this(rawValue, baseValue, counterFrequency, systemFrequency, timeStamp, timeStamp100nSec, counterType, 0) { }
/// <summary> /// Converts a PerformanceCounterType to a string. /// </summary> /// <param name="Type">The type.</param> public static string PerformanceCounterTypeToString(PerformanceCounterType Type) { switch (Type) { case PerformanceCounterType.MemoryBytes: return "bytes"; case PerformanceCounterType.TimeMilliseconds: return "ms"; default: throw new InvalidOperationException("PerformanceCounterType has invalid value " + Type.ToString()); } }
private static float NormalizeValue(this float value, PerformanceCounterType counterType) { // TODO: figure out all scaling here. should be 0-100 range. switch (counterType) { case PerformanceCounterType.ElapsedTime: value *= 0.00001f; break; } return value; }
public CounterInfo(string host, string category, string name, string instance, PerformanceCounterType type, int samplingInterval, Predicate<double> condition = null, Func<double, double> transform = null) { Host = host; Category = category; Name = name; Instance = instance; Type = type; SamplingInterval = samplingInterval; Condition = condition; Transform = transform; }
public PmcCounter(string Name, string Help, PerformanceCounterType PmcType, Type HostCategory) { m_Name = string.Empty; m_Help = string.Empty; m_Type = PerformanceCounterType.NumberOfItems32; m_HostCategory = null; m_Bound = false; m_PerfCounter = null; m_Name = Name; m_Help = Help; m_Type = PmcType; m_HostCategory = HostCategory; }
public PerformanceCounterSample(string path, string instanceName, double cookedValue, ulong rawValue, ulong secondValue, uint multiCount, PerformanceCounterType counterType, uint defaultScale, ulong timeBase, DateTime timeStamp, ulong timeStamp100nSec, uint status) { this.Path = path; this.InstanceName = instanceName; this.CookedValue = cookedValue; this.RawValue = rawValue; this.SecondValue = secondValue; this.MultipleCount = multiCount; this.CounterType = counterType; this.DefaultScale = defaultScale; this.TimeBase = timeBase; this.Timestamp = timeStamp; this.Timestamp100NSec = timeStamp100nSec; this.Status = status; }
public void RegisterCounter(string counterName, string helpString, PerformanceCounterType performanceCounterType) { if (_items.ContainsKey(counterName)) throw new ArgumentException(Resources.CounterNameAlreadyExists); CounterCreationData counter = new CounterCreationData { CounterName = counterName, CounterHelp = helpString, CounterType = performanceCounterType }; _collection.Add(counter); _items.Add(counterName, counter); }
public async Task<int> GetPerformanceMeanValue(string name, PerformanceCounterType performanceCounterType, TimeframeType timeframeType) { var random = new Random(); random.NextDouble(); var numbers = new List<int>(); for (int i = 0; i < 100; i++) { await Task.Yield(); int number = random.Next(0, 100); numbers.Insert(i, number); } return numbers.Sum() / numbers.Count; }
public async Task RunPerformanceAsync(string name, PerformanceCounterType performanceCounterType, TimeframeType timeframeType, IProgress<Tuple<PerformanceCounterType, PerfCounterModel>> progress) { await Task.Run(async () => { while (true) { await Task.Yield(); var value = await GetPerformanceMeanValue(name, performanceCounterType, timeframeType); progress.Report( new Tuple<PerformanceCounterType, PerfCounterModel>(performanceCounterType, new PerfCounterModel { Timestamp = DateTime.Now, Value = value })); await Task.Delay(250); } }).ConfigureAwait(false); }
public void GetCounterSamples_ProcessorTime_HasReasonableValues(string counter, PerformanceCounterType counterType, double minValue, double maxValue, string instanceName, ulong timeBase) { var reader = new PerfmonCounterReader(); using (var cancellationTokenSource = new CancellationTokenSource()) { var sample = reader.GetCounterSamples(new[] { counter }, TimeSpan.FromSeconds(1), 1, cancellationTokenSource.Token) .SelectMany(set => set.CounterSamples) .First(); //TODO: this is bad form - replace with an object comparer Assert.Equal(counterType, sample.CounterType); Assert.InRange(sample.CookedValue, minValue, maxValue); Assert.Equal(instanceName, sample.InstanceName); Assert.Equal(timeBase, sample.TimeBase); Assert.True(sample.Path.ToLower().EndsWith(counter.ToLower())); } }
internal PerformanceCounterSample(string path, string instanceName, double cookedValue, ulong rawValue, ulong secondValue, long multiCount, PerformanceCounterType counterType, long defaultScale, ulong timeBase, DateTime timeStamp, ulong timeStamp100nSec, long status) { this._path = ""; this._instanceName = ""; this._timeStamp = DateTime.MinValue; this._path = path; this._instanceName = instanceName; this._cookedValue = cookedValue; this._rawValue = rawValue; this._secondValue = secondValue; this._multiCount = multiCount; this._counterType = counterType; this._defaultScale = defaultScale; this._timeBase = timeBase; this._timeStamp = timeStamp; this._timeStamp100nSec = timeStamp100nSec; this._status = status; }
/// <summary> /// Initializes a new instance of the <see cref="PerformanceCounterSettings" /> class. /// </summary> /// <param name="category">The name of the performance counter category for this performance counter.</param> /// <param name="counterType">The type of the performance counter.</param> /// <param name="name">The name of the performance counter.</param> public PerformanceCounterSettings(String category, PerformanceCounterType counterType, String name) { if (category == null) { throw new ArgumentNullException(nameof(category)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } Category = category; CounterType = counterType; Name = name; }