Skip to main content

In this article, we will describe how to monitor the scheduled tasks of a Windows server.

We will use NSClient++ and the NRPE protocol.

 

How do I emplement it?

  1. Install NSClient++ on the Windows server if it’s not already done.
    We packaged NSClient++ with our Centreon plugins, you can found the last releases on the dedicated GitHub repository.
     
  2. Install the Centreon NRPE plugin on the poller which is monitoring this host
    yum install centreon-nrpe3-plugin
  3. Create a new service on Centreon using the OS-Windows-NSClient05-Task-Generic-NRPE-custom template and link it to the Windows server host.
     
  4. Edit your host configuration and add the OS-Windows-NSClient-05-NRPE-custom template. 
    Define the macro NRPECLIENT to check_centreon_nrpe3 and the macro NRPEEXTRAOPTIONS to -u -2 -P 8192 .

     

  5. Generate and export the configuration on the poller

By default, the service will check all enabled tasks that have already been executed.

 

How to filter on specific folders and tasks?

Before filtering out folders and tasks, it's important to keep in mind that we need to double backslashes in macro values on the GUI, but it's not necessary on the CLI.

Centreon-Engine will only use one backslash because the other is considered an escape character.

 

To filter on a specific folder, I can edit my service and define the FILTER macro value to enabled eq 1 and has_run eq 1 and folder eq '\\my\\task\\folder' .

Example:

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H 10.5.43.24 -p 5666 -t 30 -u -2 -P 8192 -c check_tasksched -a "filter=enabled eq 1 and has_run eq 1 and folder eq '\Microsoft\Windows\BrokerInfrastructure'" "warning=task_status = 'running' and most_recent_run_time < -60m" "critical=task_status not in ('running') and exit_code > 0" "perf-config=*(ignored:true)" 1" "warning=task_statu                                                                                                       CRITICAL: \Microsoft\Windows\BrokerInfrastructure/BgTaskRegistrationMaintenanceTask: 268435456 != 0

If I want to filter on multiple folders, I can use the value enabled eq 1 and has_run eq 1 and folder in ('\\my\\first\\folder','\\my\\second\\folder') .

Example:

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H 10.5.43.24 -p 5666 -t 30 -u -2 -P 8192 -c check_tasksched -a "filter=enabled eq 1 and has_run eq 1 and folder in ('\Microsoft\Windows\BrokerInfrastructure','\Microsoft\Windows\Wininet')" "warning=task_status = 'running' and most_recent_run_time < -60m" "critical=task_status not in ('running') and exit_code > 0" "perf-config=*(ignored:true)"
CRITICAL: \Microsoft\Windows\BrokerInfrastructure/BgTaskRegistrationMaintenanceTask: 268435456 != 0, \Microsoft\Windows\Wininet/CacheTask: 267009 != 0

A task folder can contain mutliple tasks, so if I need to filter a specific task in a folder, I can use the value enabled eq 1 and has_run eq 1 and folder eq '\\my\\task\\folder' and title eq 'MyTaskName' .

Example:

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H 10.5.43.24 -p 5666 -t 30 -u -2 -P 8192 -c check_tasksched -a "filter=enabled eq 1 and has_run eq 1 and folder eq'\Microsoft\Windows\WindowsColorSystem' and title eq 'Calibration Loader'" "warning=task_status = 'running' and most_recent_run_time < -60m" "critical=task_status not in ('running') and exit_code > 0" "perf-config=*(ignored:true)"
OK: All tasks are ok

To finish, if I want to display the state of all mathing tasks, I can add show-all in the EXTRAOPTIONS macro on the service.

Example:

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H 10.5.43.24 -p 5666 -t 30 -u -2 -P 8192 -c check_tasksched -a "filter=enabled eq 1 and has_run eq 1 and folder eq '\Microsoft\Windows\CertificateServicesClient'" "warning=task_status = 'running' and most_recent_run_time < -60m" "critical=task_status not in ('running') and exit_code > 0" "perf-config=*(ignored:true)" show-all
OK: \Microsoft\Windows\CertificateServicesClient/KeyPreGenTask: -2146893776 != 0, \Microsoft\Windows\CertificateServicesClient/SystemTask: 0 != 0, \Microsoft\Windows\CertificateServicesClient/UserTask: 0 != 0, \Microsoft\Windows\CertificateServicesClient/UserTask-Roam: 0 != 0

 

See also

Read more about the available options and filters on the NSClient++ official documentation.

Be the first to reply!

Reply