Get rid of Unknow alerts

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Get rid of Unknow alerts

Post by reincarne »

Hi,
I have specific IIS pool which I monitor with Nagios.
I ran a simple script which browse locally the API pages and checks if they are up or down. I'm doing it with the CURL tool.
For some reason, Nagios sometimes receives an OK reply with the status UNKNOWN. How can I get rid of it? There is something deffinately wrong here, it happens only
with the CURL checks on that pool.
Does someone know why does it happen?

Thanks in advance.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Get rid of Unknow alerts

Post by abrist »

You may not be receiving a properly formatted return string from your script. If the script is not too large, could you post it in code wraps?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Get rid of Unknow alerts

Post by reincarne »

Sure, its a VBScript:

Dim line, args, objShell, temp, Link
Const ForReading = 1
Link = WScript.Arguments.item(0)

Set objShell = WScript.CreateObject ("WScript.shell")
line=""
Set objExec = objShell.Exec ("c:\curl -k curl -k " & Link)
Do
temp = objExec.StdOut.ReadLine()
if len(temp)>10 then line=temp
Loop While Not objExec.Stdout.atEndOfStream


if len(temp) >= 1 then
wscript.echo ("OK - The page is loading.")
wscript.quit(0)

ElseIf len(temp) < 1 then
wscript.echo ("Critical - Page is not loading")
wscript.quit(2)
End if
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Get rid of Unknow alerts

Post by abrist »

Just to clarify, you are receiving the string "OK - The page is loading.", but the object state in unknown, correct?
If so, then the status string is being returned, and it is the exit code that is not.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
reincarne
Posts: 146
Joined: Wed Jun 26, 2013 4:39 am

Re: Get rid of Unknow alerts

Post by reincarne »

abrist wrote:Just to clarify, you are receiving the string "OK - The page is loading.", but the object state in unknown, correct?
If so, then the status string is being returned, and it is the exit code that is not.
Yes, correct.
I didn't understand the part regarding the exit code?! Can you please explain.
Thanks.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Get rid of Unknow alerts

Post by abrist »

Exit codes are how plugins tell nagios what the reported state of the object is. In your script, that would be the "wscript.quit(n)" lines, where n=0 (OK) and n=2 (Critical). It seems like the exit code is not handled correctly and is not getting returned to nagios. Maybe we can get someone in here who knows vbs better than I, as to me, your script looks fine.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked