Status issue

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
kalyanpabolu
Posts: 246
Joined: Fri Jul 03, 2020 4:18 am

Status issue

Post by kalyanpabolu »

Hello,

I have one powershell script to check the URL status. I am able to monitor it from Nagios. The issue is,, I am getting OK status even if the site is not working.

Could you please help me with the same? Below is the code:

Code: Select all

[string] $_URL = 'http://www.chalhoubgroup.com'
function CheckSiteURLStatus($_URL) {
try {
$request= [System.Net.WebRequest]::Create($_URL)
$response = $request.getResponse()
if ($response.StatusCode -eq "200") {
write-host "`nSite - $_URL is up (Return code: $($response.StatusCode) - $([int] $response.StatusCode)) `n" -ForegroundColor green 
}
else {
write-host "`n Site - $_URL is down `n" ` -ForegroundColor red
}
} catch {
write-host "`n Site - $_URL is not accessable.`n" ` -ForegroundColor red
}
}
 
CheckSiteURLStatus $_URL

===========

Below is the command I am executing:

[root@HO1-NAGIOSXI libexec]# /usr/local/nagios/libexec/check_ncpa.py -H 10.1.0.29 -t '[email protected]' -M 'plugins/check_RSO.ps1'
Site is not accessable.
You do not have the required permissions to view the files attached to this post.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Status issue

Post by dchurch »

Try adding exit 0 for OK, exit 1 for a warning, and exit 2 to indicate a critical.

e.g.

Code: Select all

...
write-host "`n Site - $_URL is not accessable.`n" ` -ForegroundColor red
exit 2
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
kalyanpabolu
Posts: 246
Joined: Fri Jul 03, 2020 4:18 am

Re: Status issue

Post by kalyanpabolu »

Hello,

Thanks a lot!!
It worked.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Status issue

Post by scottwilkerson »

kalyanpabolu wrote:Hello,

Thanks a lot!!
It worked.
Great!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked