CheckTaskSched with tasks ending codes

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

CheckTaskSched with tasks ending codes

Post by dlukinski »

Hello XI support

How to use CheckTaskSched to check if specific task exit code was more then or less then some value?

Thank you
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: CheckTaskSched with tasks ending codes

Post by rkennedy »

Are you using the warning / critical parameters? How do you have this check currently configured?

Here's a link with a bit more information about CheckTaskSched - http://docs.nsclient.org/reference/CheckTaskSched.html
Former Nagios Employee
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: CheckTaskSched with tasks ending codes

Post by dlukinski »

rkennedy wrote:Are you using the warning / critical parameters? How do you have this check currently configured?

Here's a link with a bit more information about CheckTaskSched - http://docs.nsclient.org/reference/CheckTaskSched.html
I have it done as sample (from box293)
- check_nrpe!CheckTaskSched!-a "filter=title eq 'Backup - Copy to ATL' AND most_recent_run_time < -5m" "syntax=%title%: Last Run Time = %most_recent_run_time% GMT" MaxCrit=1

Tried making it something like this:
check_nrpe!CheckTaskSched!-a "filter=title eq 'Backup - Copy to ATL' AND exit_code > 8" "syntax=%title%: Last result=%exit_code% at %most_recent_run_time%" MaxWarn=0

, but getting Service check pending with (No output on stdout) stderr: /bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: CheckTaskSched with tasks ending codes

Post by tmcdonald »

Can you post the exact arguments you are using with this service check? Sometimes things in the CCM get escaped when they are saved and later run.
Former Nagios employee
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: CheckTaskSched with tasks ending codes

Post by dlukinski »

tmcdonald wrote:Can you post the exact arguments you are using with this service check? Sometimes things in the CCM get escaped when they are saved and later run.

Latest version of check looks this way: check_nrpe!CheckTaskSched!-a "filter=title eq 'Backup - Copy to ATL' AND exit_code ne 8" "syntax=%title%: Last result=%exit_code% at %most_recent_run_time% GMT" MaxCrit+8

It produces this result (as warning) - Backup - Copy to ATL: Last result=3 at 2016-Jan-07 05:30:00 GMT

So only question left: how to make it work as "exit_code > 8" (which seem to be incorrect syntax if used exatly as written)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: CheckTaskSched with tasks ending codes

Post by tmcdonald »

Usually gt is used for "Greater-Than" and lt is used for "Less-Than". Does that work?
Former Nagios employee
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: CheckTaskSched with tasks ending codes

Post by dlukinski »

tmcdonald wrote:Usually gt is used for "Greater-Than" and lt is used for "Less-Than". Does that work?
It becomes "task not found"

Essentially I have to get critical alerts when specific task exit code is over 8
- just can't make it work anyhow with CheckTaskSched
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: CheckTaskSched with tasks ending codes

Post by rkennedy »

Just to double check, are you trying to get Nagios to return OK / WARN / CRIT alerts out of the exit_code filter?

The reason I ask is because in the documentation it states -

Code: Select all

 filter (CheckTaskSched, check_tasksched)¶
    Filter which marks interesting items.
    Interesting items are items which will be included in the check.
    They do not denote warning or critical state but they are checked use this to filter out unwanted items.
    Avalible options:
Also, what version of NSClient++ are you running?
Former Nagios Employee
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: CheckTaskSched with tasks ending codes

Post by ssax »

In addition to rkennedy's post.

Ok, after messing around with this I think I'm getting close, add the debug on the end of the command and it looks like MaxCrit is using the COUNT of how many it finds so you would need to change it to 0:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X -c CheckTaskSched -a "filter=title eq 'Backup - Copy to ATL' AND exit_code gt 8" "syntax=%title%: Last result=%exit_code% at %most_recent_run_time% GMT" MaxCrit=0 debug
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: CheckTaskSched with tasks ending codes

Post by dlukinski »

ssax wrote:In addition to rkennedy's post.

Ok, after messing around with this I think I'm getting close, add the debug on the end of the command and it looks like MaxCrit is using the COUNT of how many it finds so you would need to change it to 0:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X -c CheckTaskSched -a "filter=title eq 'Backup - Copy to ATL' AND exit_code gt 8" "syntax=%title%: Last result=%exit_code% at %most_recent_run_time% GMT" MaxCrit=0 debug
Whenever I use gt - result is ": No tasks found" This makes sense because task is ending with "3" currently and we want to be notified if exit_code is over 8. However XI service creates warning this way, where we want warning to be created when result is gt 8..

check_nrpe!CheckTaskSched!-a "filter=title eq 'Copy to ATL' AND exit_code gt 8" "syntax=%title%: Last result=%exit_code% at %most_recent_run_time% GMT" MaxCrit=0 debug!!!!!!
Locked