Page 1 of 2

CheckTaskSched not working correctly

Posted: Mon Apr 25, 2016 4:55 am
by cocoyanouck
Hi,

I've another problem about my configuration.

I want to supervise a windows task "prix.job" and to receive notifications if the job is disabled or if the task is not working more than 30 min.

In windows.cfg :

Code: Select all

define service {
      use                generic-service
      host-name      workflow
      notification_interval      15
      service_description        prix.job more than 30 min
      check_command            CheckTaskSched!prix.job!30
}
In command.cfg :

Code: Select all

define command {
     command_name      CheckTaskSched
     command_line         $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckTaskSched -a "filter=title = '$ARG1$' AND status = 'enabled' AND most_recent_run_time < -$ARG2$" "syntax=%title% (%most_recent_run_time%)" MaxWarn=1
}
The output is OK ; when I delete the job, i have the right output (task doesn't exist), but when I disable prix.job, I still have output OK (task=enabled) while the task is not running.
I've tested to write status= 'running' or status= 'disabled', but this is the same problem.

In the command line, if i test :

Code: Select all

.\check_nrpe -H 132.147.160.138 -c CheckTaskSched "filter=title=prix.job"
The output is :

Code: Select all

OK : All tasks are OK {...} 'prix.job_exit_code'=0;0;0
But if I change the command, for example, filter=title=izeHZD, I have the same output ....

Re: CheckTaskSched not working correctly

Posted: Mon Apr 25, 2016 8:38 am
by nozlaf
I cant help but notice that nsclient docs are a bit sketchy on the ability to filter on enabled tasks

http://docs.nsclient.org/0.4.4/referenc ... hed.filter

shows

Code: Select all

enabled	TODO.
as the description of the enabled key


However i see that Box293 has a guide for how to do something very similar

http://sites.box293.com/nagios/guides/c ... uled-tasks

Re: CheckTaskSched not working correctly

Posted: Mon Apr 25, 2016 8:44 am
by cocoyanouck
Thanks, I'll will read this guide.

However, I've the same problem concerning the filter title.

If i filter by title='sqidjoidjqsijd', I've the output "all tasks are Ok".... so I think I've made a mistake.

Edit : about the guide, I need CheckTaskSched2.dll and I've not seen anything on the directory script, so I think this is a solution for NSClient++ 0.4.1 and less, but not fore 0.4.4 or 0.5.0.

Re: CheckTaskSched not working correctly

Posted: Mon Apr 25, 2016 8:04 pm
by Box293
cocoyanouck wrote:Edit : about the guide, I need CheckTaskSched2.dll and I've not seen anything on the directory script, so I think this is a solution for NSClient++ 0.4.1 and less, but not fore 0.4.4 or 0.5.0.
I've udpated the guide. https://sites.google.com/a/box293.com/n ... asks?pli=1

Here is the command for newer versions of NSClient++:

Command:

Code: Select all

check_nrpe -H 192.168.142.137 -t 30 -c check_tasksched -a "filter=title eq 'Test_Task'" 'critical=most_recent_run_time < -5m' empty-state=critical 'empty-syntax=CRITICAL: Test_Task NOT found' 'detail-syntax=${title} is stale more than -5m'
Output When Task Is Running To Schedule:

Code: Select all

OK: All tasks are ok|'Test_Task_exit_code'=0;0;0 'Test_Task_most_recent_run_time'=1461632103;0;1461632019
Output When Task Is NOT Running To Schedule:

Code: Select all

CRITICAL: Test_Task is stale more than -5m|'Test_Task_exit_code'=0;0;0 'Test_Task_most_recent_run_time'=1461631503;0;1461631793
Output When Task Is NOT found

Code: Select all

CRITICAL: Test_Task NOT found
Pay close attention that the command is now check_tasksched and the arguments are slightly different.

Re: CheckTaskSched not working correctly

Posted: Tue Apr 26, 2016 2:37 am
by cocoyanouck
Better with the good command ;) Thank you !
The output is correct when the task is stale more than the selected time.

To conclude, i need to place this command with two arguments (title, time) in command.cfg.

I've written this command_line :

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -t 5666 -c check_tasksched -a "filter=title eq '$ARG1$'" 'critical=most_recent_run_time < -$ARG2$' empty-state=critical 'empty-syntax=CRITICAL:$ARG1$ NOT found' 'detail-syntax=${title} is stale more than -$ARG2$'
Obviously, I don't know how to correctly translate this command with arguments :oops:

Re: CheckTaskSched not working correctly

Posted: Tue Apr 26, 2016 2:45 am
by Box293
Try:

Code: Select all

define command {
     command_name      CheckTaskSched
     command_line         $USER1$/check_nrpe -H $HOSTADDRESS$ -t 5666 -c check_tasksched -a "filter=title eq '$ARG1$'" 'critical-most_recent_run_time < $ARG2$' empty-state=critical 'empty-syntax=CRITICAL:$ARG1$ NOT found' 'detail-syntax=${title} is stale more than $ARG2$'
}

Code: Select all

define service {
      use                generic-service
      host-name      workflow
      notification_interval      15
      service_description        prix.job more than 30 min
      check_command            CheckTaskSched!prix.job!-30
}

Re: CheckTaskSched not working correctly

Posted: Tue Apr 26, 2016 3:41 am
by cocoyanouck
Sounds not OK.

Define command : http://hpics.li/4a47d8a

Define service : http://hpics.li/1ff72de

Output : http://hpics.li/21abe32

Edit : I've tested to only write the command with filter title ARG1, and it's OK.
When I add most recent run time = ARG2, it's KO.

Re: CheckTaskSched not working correctly

Posted: Tue Apr 26, 2016 4:50 pm
by Box293
I make some spelling mistakes. Try this:

Code: Select all

define command {
       command_name                  		CheckTaskSched
       command_line                  		$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_tasksched -a "filter=title eq '$ARG1$'" 'critical=most_recent_run_time < $ARG2$' empty-state=critical 'empty-syntax=CRITICAL:$ARG1$ NOT found' 'detail-syntax=${title} is stale more than $ARG2$'
}

    define service {
          use                generic-service
          host-name      workflow
          notification_interval      15
          service_description        prix.job more than 30 min
          check_command            CheckTaskSched!prix.job!-30m
    }

Re: CheckTaskSched not working correctly

Posted: Wed Apr 27, 2016 2:38 am
by cocoyanouck
Great, it's works !

Thank you again.

Just a little point : when the task is critical, I've this output :

prix.job more than 30 min
CRITICAL 27-04-2016 09:32:59 0d 0h 1m 41s 1/3 CRITICAL: prix.job is stale more than $ARG2$$

So I suppose that I need to modify something in "define command" to replace ARG2 by 30m in the output.

Re: CheckTaskSched not working correctly

Posted: Wed Apr 27, 2016 1:29 pm
by tmcdonald
Can you please post your definition so we can verify that what you have is correct?