check_nagioslogserver.php

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
User avatar
tylerhoadley
Posts: 43
Joined: Tue Jul 02, 2013 1:41 pm

check_nagioslogserver.php

Post by tylerhoadley »

Not sure if I should post this here or in XI support forums but I'm having a issue getting the "check_nagioslogserver.php" check to go critical on '1 matching entries found'. I thought I had tested this last week where I would leave =warn='' and crit='1' in the check and would report as CRITICAL, but now it will only result in OK status.

Code: Select all

[root@nagios libexec]# ./check_nagioslogserver.php --url='https://SERVER/nagioslogserver/' --apikey='KEY' --minutes='30' --warn='' --crit='1' --query='{"query":{"filtered":{"query":{"bool":{"should":[{"query_string":{"query":"*"}}]}},"filter":{"bool":{"must":[{"range":{"@timestamp":{"from":1442861603011,"to":1442948003012}}},{"fquery":{"query":{"query_string":{"query":"message:(\"EVENTIDCODE\")"}},"_cache":true}},{"fquery":{"query":{"query_string":{"query":"Hostname:(\"WINSERVERNAME\")"}},"_cache":true}}]}}}}}'
OK: 1 matching entries found |logs=1;;1

[root@nagios libexec]# ./check_nagioslogserver.php --url='https://SERVER/nagioslogserver/' --apikey='KEY' --minutes='30' --warn='1' --crit='2' --query='{"query":{"filtered":{"query":{"bool":{"should":[{"query_string":{"query":"*"}}]}},"filter":{"bool":{"must":[{"range":{"@timestamp":{"from":1442861603011,"to":1442948003012}}},{"fquery":{"query":{"query_string":{"query":"message:(\"EVENTIDCODE\")"}},"_cache":true}},{"fquery":{"query":{"query_string":{"query":"Hostname:(\"WINSERVERNAME\")"}},"_cache":true}}]}}}}}'
OK: 1 matching entries found |logs=1;1;2
Anyone have some insight into the php warn/critical calculation/result?

If I should post this in the XI Support forum, please let me know, but figured this check is supported by the log server side rather than the XI side.

Thanks,
User avatar
tylerhoadley
Posts: 43
Joined: Tue Jul 02, 2013 1:41 pm

Re: check_nagioslogserver.php

Post by tylerhoadley »

Well, I believe I figured this out... Hopefully someone else out there finds this helpful on the 1 match found

I used this as my warn/crit args

Code: Select all

--crit="@1:~"
CRITICAL: 1 matching entries found |logs=1;;@1:~
Cheers
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_nagioslogserver.php

Post by hsmith »

Thank you for sharing your fix!
Former Nagios Employee.
me.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: check_nagioslogserver.php

Post by eloyd »

Wow, that is one ugly check. PLEASE tell me you're not typing that by hand? :-)

I do have a question about your solution. That's obviously a Nagios range specifier, but my interpretation is that you're alerting on anything that is in the range of 1 through negative infinity. Not sure how the top end can be negative infinity, but I'm glad it's working for you.

Can I ask you to try something? Just use zero for the critical value? In theory, if the result is not in the range specified (zero) then it should alert.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_nagioslogserver.php

Post by hsmith »

I'm interested in this as well.
Former Nagios Employee.
me.
User avatar
tylerhoadley
Posts: 43
Joined: Tue Jul 02, 2013 1:41 pm

Re: check_nagioslogserver.php

Post by tylerhoadley »

the basis of the check is to alert on anything 1 or greater. These queries are defined in the nagios log server, however to test them without impacting our XI environment, I ran them locally via cmd before enabling the checks in XI. At the time of writing this, our XI version is/was 5.2.7, log server 1.4.1.

I'll test 0, but believe that came back critical if 0 was the result. I will have to wait for a 1 result on one of the many checks I have setup. I'm sure one will pop up today so will test and post once I can.

However with the args supplied, I've had no issues with 1 or greater going critical in XI.
User avatar
tylerhoadley
Posts: 43
Joined: Tue Jul 02, 2013 1:41 pm

Re: check_nagioslogserver.php

Post by tylerhoadley »

I came across this via the url found within the --help arg on the check. up until this check, I was unaware of the @ or ~ characters being used (XI customer for a few years now and core user for years prior). I always thought 1 was the same as ≥1, however it did not tell nagios to go critical. Finally if you read over the url link below, "@1:~" means ≥1 to positive infinite. in the comment "@~:1" would be negative infinite to ≤1.

https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT

# ./check_nagioslogserver.php --help

<Snipped>

--warn=<WARNING> The warning values, see:
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
--crit=<CRITICAL> The critical values, see
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_nagioslogserver.php

Post by hsmith »

Thank you for sharing :)
Former Nagios Employee.
me.
User avatar
tylerhoadley
Posts: 43
Joined: Tue Jul 02, 2013 1:41 pm

Re: check_nagioslogserver.php

Post by tylerhoadley »

came in this morning, noticed a critical 1 on a check so tested it out with --crit=0.

Code: Select all

# ./check_nagioslogserver.php --url='https://kgnslogpr.empire.ca/nagioslogserver/' --apikey='KEY' --minutes='30' --crit='0' --query='{"query":{"filtered":{"query":{"bool":{"should":[{"query_string":{"query":"*"}}]}},"filter":{"bool":{"must":[{"range":{"@timestamp":{"from":1442861603011,"to":1442948003012}}},{"fquery":{"query":{"query_string":{"query":"message:(\"EVENTIDCODE\")"}},"_cache":true}},{"fquery":{"query":{"query_string":{"query":"Hostname:(\"WINSERVERNAME\")"}},"_cache":true}}]}}}}}'
OK: 1 matching entries found |logs=1;;

# echo $?
0
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_nagioslogserver.php

Post by hsmith »

I'll see if I can get this tested tomorrow.
Former Nagios Employee.
me.
Locked