Monitor Webservice - Can't get it working

Started by stoffmann, March 18, 2020, 08:59:16 AM

Previous topic - Next topic

stoffmann

Hi,

I'm trying to monitor a webservice running on one of my already monitored servers. (replaced by <SERVERNAME> in the following)

The address the service can be reached in a browser is: http://<SERVERNAME>:8683/BasicDataService/help


I created a Network Service below the monitored servers node with the following parameters:

Service Type: HTTP
Port: 8683
IP Address: tried empty and servers ip address
Request: <SERVERNAME>:/BasicDataService/help
Response: ^HTTP/1\.[01] 200.*
Poller Node: default


The agents configuration file on <SERVERNAME> looks like this:


#
# NetXMS agent configuration file
# Created by agent installer at Thu Mar  5 10:38:03 2020
#

MasterServers = <NETXMSMASTERSERVER>
ConfigIncludeDir = D:\Program Files\NetXMSAgent\etc\nxagentd.conf.d
LogFile = D:\Program Files\NetXMSAgent\log\agent.log
DebugLevel = 6
FileStore = D:\Program Files\NetXMSAgent\var
SubAgent = filemgr.nsm
SubAgent = ping.nsm
SubAgent = logwatch.nsm
SubAgent = winperf.nsm
SubAgent = wmi.nsm
SubAgent = portcheck.nsm


The service is always reported as "Not Responding"

What am I doing wrong?

Regards

Stefan

Filipp Sudanov

Network service is using portcheck subagent. This subagent provides a number or parameters that we can directly request for debugging purposes (https://www.netxms.org/documentation/adminguide/service-monitoring.html#portcheck-configuration).

So you can try on the server:
nxget <agent_ip_address> 'ServiceCheck.HTTP(www.google.com,80,/)'
The possible responses are:
0 Success, connection to target was established and expected response was received.
1 Invalid arguments were passed.
2 Cannot connect to target.
3 Invalid / Unexpected response from target

For response = 3 Portcheck can save HTTP server reply in a file that can be inspected to understand if the regex is wrong. For this to happen the following should be specified in agent config:
[portcheck]
FailedDirectory=/tmp/




stoffmann

Thank You for Your reply. I think I'm a step further know.
The portcheck log tells me the following:

HTTP/1.1 401 Unauthorized
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
WWW-Authenticate: NTLM
Date: Mon, 23 Mar 2020 10:51:21 GMT
Connection: close


So it looks like an authentication problem. Which credentials is NetXMS using? Can I change them somwhere?
I have to use NTLM for authentication.

Thanks in advance




stoffmann

I investigated further and found out the when I use Powershell to test the service like this:

Invoke-WebRequest -uri http://myserver.net:8683/BasicDataService/help/operations/GetDatabases -UseDefaultCredentials

I have to use the -UseDefaultCredentials, otherwise I alo get error 401 Unauthorized. So ist mußt have to do with authentication.
Howx can I change authentication for NetXMS Webservice monitoring?


Filipp Sudanov

Portcheck subagent does not support authentication. There's another subagent - netsvc - that is based on libcurl and supports authentication by specifying address like: proto://user:pass@host
The difference is that it's not possible to use netsvc as data source for "Network service". The only way to access netsvc is to create a DCI.

stoffmann