z

Commercial Support Clients: Clients with support contracts can get escalated support assistance by visiting Nagios Answer Hub. These forums are for community support services. Although we at Nagios try our best to help out on the forums here, we always give priority support to our support clients.

Monitor localhost URL

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.

Re: Monitor localhost URL

Postby apteancloud » Mon May 17, 2021 7:58 am

From NagiosXI Server:

Code: Select all
CHS_Admin@NagiosXIAzPrd:~$ curl -k -L -vvv "http://10.179.3.25:51011/api/status"
*   Trying 10.179.3.25...
* TCP_NODELAY set
* connect to 10.179.3.25 port 51011 failed: Connection refused
* Failed to connect to 10.179.3.25 port 51011: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 10.179.3.25 port 51011: Connection refused
apteancloud
 
Posts: 47
Joined: Wed Sep 09, 2020 4:05 am

Re: Monitor localhost URL

Postby vtrac » Mon May 17, 2021 11:58 am

Hi,
Hope you are having a good day!!
Since you do have NSClient++ installed on that "local" url machine, looks like your only choice is to write your own PS1 script, let call it "check_localurl.ps1".

put that under:
Code: Select all
C:\Program Files\NSClient++\scripts\


Now, edit the "nsclient.ini" by follow the step in the URL below:
https://docs.nsclient.org/howto/external_scripts/

You can use "chek_nrpe" to calls "check_localurl.ps1":
Code: Select all
/usr/local/nagios/libexec/check_nrpe -2 -H x.x.x.x  -c check_localurl


Best Regards,
Vinh
User avatar
vtrac
 
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: Monitor localhost URL

Postby apteancloud » Tue May 18, 2021 6:57 am

I have set the PS script as:
Code: Select all
((Invoke-WebRequest http://server.local:51011/api/status -UseBasicParsing).Content |ConvertFrom-Json).status
Output: Started


At nsclient.ini, under [/settings/external scripts/scripts]:
Code: Select all
ssm_output_ps1 = cmd /c echo scripts\SSMoutput.ps1; exit($lastexitcode) | powershell.exe -command -


On NagiosXI, I get this output:
Capture.JPG


Now, this is good. However, what happens when the status changes to 'Stopped'. How do I ensure Nagios changes to CRITICAL when the status is anything other than 'Started'?

This is what I see at NagiosXI
Capture1.JPG

Capture2.JPG
You do not have the required permissions to view the files attached to this post.
apteancloud
 
Posts: 47
Joined: Wed Sep 09, 2020 4:05 am

Re: Monitor localhost URL

Postby vtrac » Tue May 18, 2021 9:44 am

Hi,
How are you doing?

Instead of a command line (like what you did), please put that into a PowerShell script.

I am NOT a PowerShell programmer, but here's my thought:
Code: Select all
$a1 = ((Invoke-WebRequest http://server.local:51011/api/status -UseBasicParsing).Content |ConvertFrom-Json).status

if ($a1 -eq "Started") { exit 0 }
else  { exit 2 }


Exit Status:
0 = OK
1 = Warning
2 = Critical

Best Regards,
Vinh
User avatar
vtrac
 
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: Monitor localhost URL

Postby apteancloud » Tue May 18, 2021 10:41 am

Made it!

You are correct to input the exit code and that did the trick. For exit 2, Nagios turns CRITICAL. For exit 0, Nagios turns OK.
Thank you very much. :ugeek:
apteancloud
 
Posts: 47
Joined: Wed Sep 09, 2020 4:05 am

Re: Monitor localhost URL

Postby vtrac » Tue May 18, 2021 10:54 am

Great!! .... may I close this thread? .... :-)


Regards,
Vinh
User avatar
vtrac
 
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: Monitor localhost URL

Postby apteancloud » Tue May 18, 2021 11:20 am

Just give me a day so that I can confirm on thread closure.
apteancloud
 
Posts: 47
Joined: Wed Sep 09, 2020 4:05 am

Re: Monitor localhost URL

Postby vtrac » Tue May 18, 2021 11:37 am

Will do ..... :-)
User avatar
vtrac
 
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: Monitor localhost URL

Postby apteancloud » Tue Jun 08, 2021 8:41 pm

I realised I never responded back. Please archive this thread. Thanks again for pointing me to right direction.. :D
apteancloud
 
Posts: 47
Joined: Wed Sep 09, 2020 4:05 am

Re: Monitor localhost URL

Postby scottwilkerson » Wed Jun 09, 2021 7:11 am

apteancloud wrote:I realised I never responded back. Please archive this thread. Thanks again for pointing me to right direction.. :D

Locking thread
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
scottwilkerson
DevOps Engineer
 
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Previous

Return to Nagios XI

Who is online

Users browsing this forum: No registered users and 18 guests