NCPA API Endpoint windowscounters

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

NCPA API Endpoint windowscounters

Post by onegative »

G 'Day Customer Support,

So I have run into a problem and am unsure of the actual cause.
Using the NCPA Listener and working through the API Endpoint Tester I found that certain Perf Counters are being reported as not being found.

Example Counter: \PhysicalDisk(_Total)\Avg. Disk sec/Transfer

Clearly the counter exists because I can use both Perfmon and Powershell to extract the metric.

PS C:\> (Get-Counter "\PhysicalDisk(_Total)\Avg. Disk sec/Transfer").Countersamples

Path InstanceName CookedValue
---- ------------ -----------
\\servername\physicaldisk(_total)\avg. disk sec/transfer _total 0


But from NCPA API Endpoint Tester it reports as follows:

Code: Select all

https://localhost:3181/api/windowscounters/PhysicalDisk(_Total)/Avg. Disk sec/Transfer
{ "windowscounters": [ [ "Error: The specified object was not found on the computer." ], "c" ] }

And it does not appear to be associated with spaces because other counters that have spaces work fine.

listener.log:
2018-05-11 09:56:37,630:INFO:handler:127.0.0.1 - - [2018-05-11 09:56:37] "GET /api/windowscounters/PhysicalDisk(_Total)/Avg.%20Disk%20sec/Transfer HTTP/1.1" 200 368 0.017000


Can someone from support please test this specific counter and report back?

Thanks for your help,
Danny
Last edited by onegative on Mon May 14, 2018 11:20 am, edited 1 time in total.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA API Endpoint windowscounters

Post by lmiltchev »

This windows performance counter shows up fine for me in the API. I am running NCPA 2.1.3.
example01.PNG
From the command line:

Code: Select all

[root@main-nagios-xi libexec]# ./check_ncpa.py -H x.x.x.x -t mytoken -M 'windowscounters/PhysicalDisk(_Total)/Avg. Disk sec/Transfer'
OK: \PhysicalDisk(_Total)\Avg. Disk sec\Transfer was 0 c | '\PhysicalDisk(_Total)\Avg. Disk sec\Transfer'=0c;;;
What is the NCPA version that you are currently using?
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

Re: NCPA API Endpoint windowscounters

Post by onegative »

Hey lmiltchev,

I am on the same version 2.1.3 and I still think something is not right.
I see you ran this as a Nagios Check and yes if I do that it too returns a value.
But look at your return, what is the "c" doing as part of your value...that does not appear to be a reliable return value.
If you remove the "Run as a Nagios check" the response cannot be handled appropriately as shown in the error message and look there is that weird lowercase "c" character again...it just happens that the "Run as a Nagios check" is just accepting the return value as a string and it doesn't care that the "0c" is not an actual integer and it is just passing it as ascii text.

Code: Select all

{
    "windowscounters": [
        [
            "Error: The specified object was not found on the computer."
        ],
        "c"
    ]
}
If you use the following Powershell query look at the returns.
I still believe this is broke as the actual value being returned is an integer and the "c" I believe is being reported back by the .Countersamples.
It appears to me that the parser is confused and is somehow grabbing the InstanceName as that lowercase "c" appears to be the only place it is originating from...DEBUG from the listener does not give me enough to really know what is happening and I think only the developer will really understand what is happening here...I included the DEBUG out below.

Code: Select all

PS C:\> (Get-Counter "\PhysicalDisk(*)\Avg. Disk sec/Transfer").Countersamples

Path                                                          InstanceName          CookedValue
----                                                          ------------          -----------
\\dg0123-ibm-4048\physicaldisk(0 c:)\avg. disk sec/transfer   0 c:         0.000166624356556804
\\dg0123-ibm-4048\physicaldisk(_total)\avg. disk sec/transfer _total       0.000166624356556804
listener.log DEBUG output:

CHECK=FALSE
2018-05-11 12:50:08,851:INFO:handler:127.0.0.1 - - [2018-05-11 12:50:08] "GET /api/windowscounters/PhysicalDisk(_Total)/Avg.%20Disk%20sec/Transfer HTTP/1.1" 200 382 0.208000
2018-05-11 12:50:11,362:DEBUG:handler:Initializing WebSocket
2018-05-11 12:50:11,364:DEBUG:handler:Validating WebSocket request
2018-05-11 12:50:11,382:DEBUG:psapi:Imported windowscounters into the API tree.
2018-05-11 12:50:11,384:DEBUG:psapi:Imported windowslogs into the API tree.
2018-05-11 12:50:11,384:ERROR:windowscounters:(-1073738824, 'AddCounter', 'The specified object was not found on the computer.')
Traceback (most recent call last):
File "C:\ncpa\agent\listener\windowscounters.py", line 43, in counter_method
File "C:\ncpa\agent\listener\windowscounters.py", line 59, in get_counter_val
error: (-1073738824, 'AddCounter', 'The specified object was not found on the computer.')

CHECK=TRUE
2018-05-11 12:50:11,500:INFO:handler:127.0.0.1 - - [2018-05-11 12:50:11] "GET /api/windowscounters/PhysicalDisk(_Total)/Avg.%20Disk%20sec/Transfer?check=true HTTP/1.1" 200 441 0.137000
2018-05-11 12:50:13,585:DEBUG:handler:Initializing WebSocket
2018-05-11 12:50:13,585:DEBUG:handler:Validating WebSocket request
2018-05-11 12:50:13,607:DEBUG:psapi:Imported windowscounters into the API tree.
2018-05-11 12:50:13,607:DEBUG:psapi:Imported windowslogs into the API tree.
2018-05-11 12:50:13,608:INFO:handler:127.0.0.1 - - [2018-05-11 12:50:13] "GET /api/windowscounters/PhysicalDisk(_Total)/Avg.%20Disk%20sec/Transfer HTTP/1.1" 200 382 0.023000

Thanks for your help,
Danny
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA API Endpoint windowscounters

Post by lmiltchev »

I just got a word from our developers that the issue with this particular Windows performance counter will be fixed in NCPA 2.1.5.

https://github.com/NagiosEnterprises/nc ... 1560d35a85

Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

Re: NCPA API Endpoint windowscounters

Post by onegative »

OK...

That works and thanks for checking with the Jake,
Danny
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA API Endpoint windowscounters

Post by lmiltchev »

You are welcome, Danny! Is it OK to close this thread?
Be sure to check out our Knowledgebase for helpful articles and solutions!
onegative
Posts: 175
Joined: Tue Feb 17, 2015 12:06 pm

Re: NCPA API Endpoint windowscounters

Post by onegative »

Yes close please...
Danny
Locked