Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read counters #62

Open
skonet opened this issue Apr 24, 2016 · 12 comments
Open

Cannot read counters #62

skonet opened this issue Apr 24, 2016 · 12 comments

Comments

@skonet
Copy link

skonet commented Apr 24, 2016

Hello,

First, I would like to thank you for this project, it is exactly what I need to monitor machines (locally or remotely)!

Now my issue: I finally managed to configure InfluxDB access, and this works ('config show' generates a successful 'ping' to InfluxDB).
However, I cannot configure counters, even standard ones.
I created two XML files for metrics:

<?xml version="1.0" encoding="utf-16"?>
<Influx-Capacitor>
  <CounterGroups>
    <CounterGroup Name="processor" SecondsInterval="10">
      <Counter>
        <CategoryName>Processor</CategoryName>
        <CounterName>% Processor Time</CounterName>
        <InstanceName>*</InstanceName>
      </Counter>
      <Counter>
        <CategoryName>Processeur</CategoryName>
        <CounterName>% temps processeur</CounterName>
        <InstanceName>*</InstanceName>
      </Counter>
    </CounterGroup>
  </CounterGroups>
</Influx-Capacitor>

and

<?xml version="1.0" encoding="utf-16"?>
<Influx-Capacitor>
  <CounterGroups>
    <CounterGroup Name="processor2" SecondsInterval="5" RefreshInstanceInterval="0">
      <Counter>
        <CategoryName>Processor</CategoryName>
        <CounterName>% Processor Time</CounterName>
        <InstanceName>_Total</InstanceName>
      </Counter>
    </CounterGroup>
  </CounterGroups>
</Influx-Capacitor>

Please note that my Win7 SP1 is installed in French, so I tried both English and French names for perf counters.
I activated service log file and got these lines:

WARN - 24/04/2016 22:20:02: Unable to get performance counter .Processor.% Processor Time.*. La catégorie n'existe pas.
WARN - 24/04/2016 22:20:02: Unable to get performance counter .Processeur.% temps processeur.*. La catégorie n'existe pas.
ERROR - 24/04/2016 22:20:02: Engine processor: La référence d'objet n'est pas définie à une instance d'un objet.
WARN - 24/04/2016 22:20:02: Unable to get performance counter .Processor.% Processor Time._Total. La catégorie n'existe pas.
ERROR - 24/04/2016 22:20:02: Engine processor2: La référence d'objet n'est pas définie à une instance d'un objet.
INFO - 24/04/2016 22:20:02: Service Influx-Capacitor version 1.0.18.0 started.
ERROR - 24/04/2016 22:20:07: Engine processor2: La référence d'objet n'est pas définie à une instance d'un objet.
ERROR - 24/04/2016 22:20:12: Engine processor: La référence d'objet n'est pas définie à une instance d'un objet.
ERROR - 24/04/2016 22:20:12: Engine processor2: La référence d'objet n'est pas définie à une instance d'un objet.

In English it says that the category does not exist, which is rather annoying for Processor (English) or Processeur (French). Note that perfmon find these categories with no problem.
Finally I tried to create the counter directly in console (see attached PNG file).
console_counter
I enter category 'Processor' -> OK
I enter counter '% Processor Time' -> NOK ('There are several matches to the entry')
If I enter counter '% Processor Time' -> OK, but counter not found!

Thanx for your help!
Stéphane.

@skonet
Copy link
Author

skonet commented Apr 24, 2016

As a complement, I saw in event viewer a PerfOS event (eventID = 2011), which occurs just at service restart:

event_viewer

Hope this helps :-)

@poxet
Copy link
Owner

poxet commented Apr 25, 2016

Perhaps it is a language problem. I had some issues with that when trying on a machine that has a Swedish operating system.

When you configured the counters did you type "% Processor Time" and "_Total" or did you press the Tab-key to get the values? If you have not already, try using the Tab-key for all fields possible when create the counters, then you are sure that the counters are entered the same way as they are read.

Also, try running the console program as administrator and see if that helps when creating or reading the counters.

@skonet
Copy link
Author

skonet commented Apr 25, 2016

Thanks for your suggestion, it helped me to progress:

  • using the TAB key (and running as administrator), I was able to list some categories and counters (I must admit I did not understand the role of TAB key before your message!)
  • what puzzles me is that using TAB key, there some missing values in categories (e.g. Memory or Processor) and missing values in counters (e.g. for category Process only % Privileged Time is proposed!)

Any idea?

@poxet
Copy link
Owner

poxet commented Apr 26, 2016

That is very strange, I am not sure what the reason could be for that. A wild guess (which i don't really believe in myself) is that the categories or counters are in French.

Anyway, I have created a version now where it is possible to get some more information. The version is 1.0.18.1 and it can be retrieved here http://influx-capacitor.com/Home/Download (as msi or Chocolatey package).

There is a function that lists all counter categories. Type "counter categories" in the console. (Is the category "Memory" or "Processor" there?)

Also, you can now see what culture you are running on (on top when you start the console). Default it changes the culture to en-US, but this can be changed. If you remove the Culture setting from App.config you will run on your native language.

Now when running the "counter categories" command you will see the name difference between your culture and en-US. Do you get any results there?

This might help us to get a step further.

@skonet
Copy link
Author

skonet commented Apr 26, 2016

Thanks for your version 1.0.18.1!

I ran "counter categories" with program default (en-US) culture, which gives this:

> counter categories
Outlook
TCPv4
Thread
Event Tracing for Windows
IPHTTPS Global
HTTP Service Url Groups
SMSvcHost 3.0.0.0
Process
Network Interface
ServiceModelService 4.0.0.0
HTTP Service Request Queues
IPv6
Security System-Wide Statistics
Job Object
Server
Terminal Services
.NET Data Provider for Oracle
HTTP Service
ASP.NET Apps v4.0.30319
Event Tracing for Windows Session
Browser
Per Processor Network Interface Car
IPv4
IPsec Driver
Print Queue
TCPv6
Security Per-Process Statistics
.NET Data Provider for SqlServer
ASP.NET State Service
WFP
Job Object Details
IPsec AuthIP IPv4
Generic IKEv1, AuthIP, and IKEv2
MSDTC Bridge 3.0.0.0
ServiceModelOperation 3.0.0.0
Telephony
Power Meter
UDPv4
IPsec IKEv2 IPv6
Redirector
IPsec IKEv2 IPv4
NBT Connection
.NET CLR Data
ASP.NET v4.0.30319
IPsec IKEv1 IPv4
ServiceModelEndpoint 3.0.0.0
IPsec IKEv1 IPv6
.NET Memory Cache 4.0
.NET CLR Networking 4.0.0.0
Synchronization
Teredo Relay
.NET CLR Networking
ASP.NET Applications
Per Processor Network Activity Cycl
UDPv6
Windows Workflow Foundation
MSDTC Bridge 4.0.0.0
Terminal Services Session
Processor Information
Teredo Server
WF (System.Workflow) 4.0.0.0
ICMPv6
LogicalDisk
ASP.NET
Teredo Client
WFPv4
Windows Media Player Metadata
Server Work Queues
IPsec AuthIP IPv6
WFPv6
SMSvcHost 4.0.0.0
ServiceModelService 3.0.0.0
PhysicalDisk
ICMP
Netlogon
There are 75 categories in total.
>

Note that categories and counters are missing here too (processor, memory, % processor time).
Then I switched to fr-FR culture in service and console .config files, then I get:

> counter categories
Counters only in english:
There are 0 categories in total.

Counters only in fr-FR:
There are 0 categories in total.
>

Then I ran "counter create", and was able to list categories and counters in French, with the same missing categories/counters (e.g. mémoire, processeur and % temps processeur)!

Could you isolate the code that lists categories / counters with culture in a small separate source code so that I can debug it on my platform (I have VisualStudio) ?

@poxet
Copy link
Owner

poxet commented Apr 27, 2016

If you look for a class named CounterCategoryListCommand and set a breakpoint on line 24, you should be able to debug the method that loads the list of categories.

@skonet
Copy link
Author

skonet commented Apr 27, 2016

Hello,
Thanx for your help!

I rebuilt the whole application (hope so, I am no expert of VS2015 ;-), and here is the interesting part:

  • from VS2015 or running directly the rebuilt console, I get all categories / counters (with en-US culture) !
  • after some Google searches, I got several interesting hints (see below)
  • seems like the project options may interfer (I am running Win7 SP1 x64 FR) => do you build with "any CPU" as platform target?

Google results:

http://stackoverflow.com/questions/14139538/performance-counters-go-missing
http://stackoverflow.com/questions/15925092/performancecountercategory-getcategories-is-inconsistent-with-perfmon

Best regards.

@skonet
Copy link
Author

skonet commented Apr 27, 2016

A small complement : when I use "counter create", with category = "Process", the browsing of possible counters is very slow (frozen?).
After debugging line 37:
var counterNames = _counterBusiness.GetCounterNames(categoryName, machineName);
counterNames contains more than 3500 values for category 'Process', with many duplicates (linked to different instances?)...

@poxet
Copy link
Owner

poxet commented Apr 27, 2016

I am not sure how the build server is set up in regards to AnyCPU/x86/x64 but perhaps we should specifically build one x64 and another x86 version. I will have a look at that.

In regards to many counters in response to GetCounterNames. That is a problem... Some processes are named the same but have different ids. How long does it take for the function to respond with the 3500 values?

@skonet
Copy link
Author

skonet commented Apr 27, 2016

In fact the function itself responds quickly. But when you press to browse possible counter for "process" category, you get n times the same value (the duplicated counters).
For instance, I have more than 100 times "% Processor Time", so the user might think nothing changes on screen when pressing (where in fact 100+ times the same value is displayed).

@poxet
Copy link
Owner

poxet commented Apr 27, 2016

Ah, now I get what you mean. That could probably be filtered down to just have one of each. :)

Do you want to contribute with that? If not, I can have a look at it later on.

@skonet
Copy link
Author

skonet commented Apr 27, 2016

You understood it well, the idea is to eliminate duplicates from the list.
I am afraid I cannot help on the implementation, I do not know C# at all :-(
I can read the source code and guess what it does (from other languages and Perfmon experience), but writing C# code is another story...
Sorry for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants