CheckTaskSched not working correctly

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

CheckTaskSched not working correctly

Post 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 ....
User avatar
nozlaf
Posts: 172
Joined: Sun Nov 09, 2014 9:50 pm
Location: Victoria, Australia

Re: CheckTaskSched not working correctly

Post 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
Looking forward to seeing you all at #NagiosCon2019?
-Dedicated Lover of Nconf,PNP4Nagios and Nagvis
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: CheckTaskSched not working correctly

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: CheckTaskSched not working correctly

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: CheckTaskSched not working correctly

Post 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:
Last edited by cocoyanouck on Tue Apr 26, 2016 3:34 am, edited 1 time in total.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: CheckTaskSched not working correctly

Post 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
}
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: CheckTaskSched not working correctly

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: CheckTaskSched not working correctly

Post 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
    }
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
cocoyanouck
Posts: 96
Joined: Fri Apr 08, 2016 3:17 am

Re: CheckTaskSched not working correctly

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: CheckTaskSched not working correctly

Post by tmcdonald »

Can you please post your definition so we can verify that what you have is correct?
Former Nagios employee
Locked