none
WMI performance query doesn't return correct data RRS feed

  • Question

  • 		private void GetAspNetInfo(Dictionary<string, Dictionary<string, object>> res)
    		{
    			if (_counter == null)
    				_counter = new PerformanceCounter("ASP.NET Apps v4.0.30319", "Requests Total", "__Total__");
    			Console.WriteLine(">>>>>>>> {0}\t{1}", _counter.CategoryName + " " + _counter.CounterName, _counter.NextValue());
    
    			if (_searcher2 == null)
    				_searcher2 = new ManagementObjectSearcher("SELECT * FROM Win32_PerfFormattedData_ASPNET4030319_ASPNETAppsv4030319");
    			Report(_searcher2);
    		}
    
    		private static void Report(ManagementObjectSearcher searcher)
    		{
    			DataLog.Info(string.Format("\r\n--------------------- {0} ---------------------\r\n", searcher.Query));
    			foreach (var obj in searcher.Get())
    			{
    				var message = FormatMessage(obj);
    				Console.WriteLine("\r\n{0}\r\n{1}\r\n", obj["Name"], message);
    			}
    		}
    
    		private static string FormatMessage(ManagementBaseObject obj)
    		{
    			var properties =
    				obj.Properties.Cast<PropertyData>().Where(val => val.Value != null && val.Value.Equals(0)).
    				Select(val => string.Format("{0}={1}", val.Name, val.Value)).ToList();
    			var message = string.Join(" ", properties);
    			return message;
    		}

    The code above prints the correct result for data retrieved via PerformanceCounter, but the WMI query returns all zero values.

    Any ideas why this can be happening?

    Tuesday, October 20, 2015 7:52 AM

All replies

  • Hi Andrey_F,

    You could use below query instead.

    select * from Win32_PerfRawData_ASPNET4030319_ASPNETv4030319
    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 21, 2015 5:42 AM
    Moderator
  • You could use below query instead.
    It returns all zero values, too.

    • Edited by Andrey_F Wednesday, October 21, 2015 11:54 AM
    Wednesday, October 21, 2015 7:37 AM
  • Hi Andrey_F,

    To further help you about this issue, I am trying to invoke someone experienced to help look into this thread, this may take some time and as soon as we get any result, we will post back.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 27, 2015 9:04 AM
    Moderator