Page 1 of 2

Monitor localhost URL

Posted: Mon May 03, 2021 5:01 am
by apteancloud
Hi,

Is there a way to monitor localhost URLs. I want to monitor http://localhost:51011/api/status. How do I set it up?
Its a Windows host machine and we are using nsclient++

Regards

Re: Monitor localhost URL

Posted: Mon May 03, 2021 1:11 pm
by ssax
You should be able to add a plugin to the windows nsclient host, define the command in the nsclient.ini, and then call the plugin and pass in the URL and it should do it.

What specifically are you trying to monitor at that web address, just that it's up? Or some specific content? What specifically?

I found this that may work for you:

https://www.claudiokuenzler.com/blog/68 ... lternative

Re: Monitor localhost URL

Posted: Mon May 03, 2021 9:06 pm
by apteancloud
Basically, the host machine where that URL is set in such a way, it can only be accessed at localhost, not as a public endpoint. In which case, I would have used check_http.
So, from the host machine, if I hit http://myhost.local:51011/api/status or http://localhost:51011/api/status, it gives me output as:

Code: Select all

{"status":"Started","startTime":"2021-03-26T08:34:50.873063Z","appserverURL":"AppServer://myhost.local:5162/TEST_WC","scalingInterval":1000,"cleanupInterval":10000,"stateServerPortRangeStart":58100,"stateServerMaxInstances":40,"stateServerMinInstances":30,"stateServerPrestartedInstances":30,"stateServerPrestartRampUp":1,"stateServerEnablePrestart":false,"stateServerTenant":"Test-Host","stateServerStartupTimeout":1800000}
What I am trying to achieve with this check is a regex search for keyword "Started". If found, all OK.

Re: Monitor localhost URL

Posted: Tue May 04, 2021 4:38 pm
by vtrac
Hi,
Hope you are having a good day!!

What happens if you run "check_http" from your XI command prompt:
(NOTE: x.x.x.x is your remote windows IP address)

Code: Select all

/usr/local/nagios/libexec/check_http -H x.x.x.x -p 51011 -u '/api/status' -U -v
If the above does not work, then I would suggest that you write a powershell script and call its from your XI machine.


Best Regards,
Vinh

Re: Monitor localhost URL

Posted: Wed May 05, 2021 6:34 am
by apteancloud
When I run the command you mentioned, this is what I get:

Code: Select all

[nagios@NagiosXIAzDev ~]$ /usr/local/nagios/libexec/check_http -H 10.179.3.25 -p 51011 -u '/api/status' -U -v
connect to address 10.179.3.25 and port 51011: Connection refused
HTTP CRITICAL - Unable to open TCP socket
The output from the remote server is:

Code: Select all

{"status":"Started","startTime":"2021-04-30T08:28:54.4085873Z","appserverURL":"AppServer://APPSRVURL","scalingInterval":500,"cleanupInterval":10000,"stateServerEnablePrestart":false,"stateServerTenant":"Live","stateServerStartupTimeout":1800000}
And from there I want to do a regex for "Started" and "scalingInterval". If found, Nagios will say OK, else CRITICAL.

On the Powershell side, I can write something like this and it gives me the JSON output:

Code: Select all

PS C:\Program Files\NSClient++\scripts> (Invoke-WebRequest http://APPSRVURL:51010/api/status).Content
{"status":"Started","startTime":"2021-04-30T08:28:54.4085873Z","appserverURL":"AppServer://APPSRVURL","scalingInterval":500,"cleanupInterval":10000,"stateServerEnablePrestart":false,"stateServerTenant":"Live","stateServerStartupTimeout":1800000}
But how do I make Nagios talk and capture that PowerShell output and give me an OK/CRITICAL state?

Re: Monitor localhost URL

Posted: Wed May 05, 2021 3:27 pm
by vtrac
Hi,
First, let see if you can "ping" the remote host from your XI machine.
Please open a command prompt from your XI machine (please update outputs or screenshots):

Code: Select all

ping 10.179.3.25
If you are able to "ping 10.179.3.25", then run the below command and see if port "51011" open from your XI to your remote machine:
(please post outputs or screenshots)

Code: Select all

nmap -Pn -p 51011 10.179.3.25
Also, please upload the "profile.zip":
Admin > System Config > System Profile > "Download profile"

Best Regards,
Vinh

Re: Monitor localhost URL

Posted: Wed May 12, 2021 9:20 am
by apteancloud
Outputs:

Code: Select all

CHS_Admin@NagiosXIAzPrd:~$ ping 10.179.3.25
PING 10.179.3.25 (10.179.3.25) 56(84) bytes of data.
64 bytes from 10.179.3.25: icmp_seq=1 ttl=128 time=0.916 ms
64 bytes from 10.179.3.25: icmp_seq=2 ttl=128 time=0.958 ms
64 bytes from 10.179.3.25: icmp_seq=3 ttl=128 time=0.902 ms
64 bytes from 10.179.3.25: icmp_seq=4 ttl=128 time=1.29 ms
64 bytes from 10.179.3.25: icmp_seq=5 ttl=128 time=0.894 ms
64 bytes from 10.179.3.25: icmp_seq=6 ttl=128 time=1.14 ms
64 bytes from 10.179.3.25: icmp_seq=7 ttl=128 time=13.4 ms
64 bytes from 10.179.3.25: icmp_seq=8 ttl=128 time=0.905 ms
64 bytes from 10.179.3.25: icmp_seq=9 ttl=128 time=0.952 ms
64 bytes from 10.179.3.25: icmp_seq=10 ttl=128 time=0.843 ms
^C64 bytes from 10.179.3.25: icmp_seq=11 ttl=128 time=0.952 ms
64 bytes from 10.179.3.25: icmp_seq=12 ttl=128 time=0.934 ms
^C
--- 10.179.3.25 ping statistics ---
12 packets transmitted, 12 received, 0% packet loss, time 11095ms
rtt min/avg/max/mdev = 0.843/2.013/13.464/3.454 ms

Code: Select all

CHS_Admin@NagiosXIAzPrd:~$ nmap -Pn -p 51011 10.179.3.25

Starting Nmap 7.60 ( https://nmap.org ) at 2021-05-12 14:07 UTC
Nmap scan report for 10.179.3.25
Host is up (0.00091s latency).

PORT      STATE  SERVICE
51011/tcp closed unknown

Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds
I can hit the site on the remote server though.
Capture1.JPG

Re: Monitor localhost URL

Posted: Wed May 12, 2021 2:43 pm
by vtrac
Hi,
See if you can talk to your network admin to open port "51011".

Can you try this on your XI command prompt? .... (NOTE: x.x.x.x is the remote windows IP address)

Code: Select all

curl -k -L -vvv "http://x.x.x.x:51011/api/status"
Using "check_http" is the easiest if you can get port "51011" open.


Regards,
Vinh

Re: Monitor localhost URL

Posted: Thu May 13, 2021 9:58 am
by apteancloud
Hi,

Opening Port was denied :cry:

Any other suggestions?

Re: Monitor localhost URL

Posted: Thu May 13, 2021 10:42 am
by vtrac
Hi,
Can you run the below command on your XI command prompt?

Code: Select all

curl -k -L -vvv "http://x.x.x.x:51011/api/status"
Regards,
Vinh