Monitor Windows Scheduled task with NRPE and NSClient++

NSClient++ (which is widely used to monitor Windows server with Nagios) natively allows to monitor Windows scheduled tasks.

This is a very powerful module, but with a complex syntax, and the official documentation has some errors.

Here is two command lines which I managed to write, and which were useful for me. I hope they can help others :

1- show task names list (except the disabled ones)

This command is not intended to be used in Nagios, but is helpful for the next one :

Of course, <IP> must be replaced by its value, and (…) by the appropriate check_nrpe options (-p and -n)

 2- trigger an alerte when a task has a non-zero return code

Here, <NAME> must be replaced by the task’s filename (usually found in C:\Windows\Tasks). It is given by the previous command.

Usage example :

On that server, I created two scheduled tasks :

sched

The first command line gives their names :

And I can use the name ‘test_sched.job’ to define the check_command to add to the Nagios configuration :

You’ll find more information and options on the official documentation page


One Response

  1. Andre says:

    Sorry, didnt work with NSClient 4.1.101. I belive it was changed

    /usr/lib/nagios/plugins/check_nrpe -H 10.251.103.72 -c alias_sched_task -a “filter=title=’TesteNagios.job’ AND exit_code ne 0″ “syntax=%title%: Last result=%exit_code% at %most_recent_run_time% GMT” MaxCrit=1 ignore-perf-data

    Parsing failed: TesteNagios.job’ AND exit_code ne 0′ AND exit_code ne 0

    nsclient.log (NSClient 4.1.101)

    2013-11-19 12:30:31: e:D:\source\nscp\trunk\include\parsers/filter/where_filter_impl.hpp:89: Parsing failed of ‘title eq ‘filter=title=’TesteNagios.job’ AND exit_code ne 0′ AND exit_code ne 0′ at: TesteNagios.job’ AND exit_code ne 0′ AND exit_code ne 0

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Crocoware technical blog
CyberChimps