Monitorizando Tareas programadas con Centreon

Print Friendly, PDF & Email

Something very common is that some Windows Server machines in our environment may have certain scheduled tasks that we often do not control or forget. In this post we will see how we can monitor the scheduled Windows tasks in our environment, How could you not, we will centralise it in Centreon.

A quick post, easy, Simple and family-friendly, you know 😉 The idea of this post will be to know if a scheduled task that we may have on a remote Windows machine has finished well or not, we will monitor it from Centreon thanks to the NSClient remote agent that this Windows machine must have. If you don't know Centreon's NSClient agent, I recommend you read This post before, and if you prefer with the traditional NSClient, This other one.

In this post, To monitor it we will use the check command 'check_tasksched’ provided by NSClient, and we can use it in multiple ways. We can monitor that all scheduled tasks on a machine have been completed correctly, or in a specific period of time… In this document, we'll look at how to monitor a specific scheduled task, whether your last execution was good or bad, and we'll do it with the following command, taking into account that in the arguments we have added that the scheduled task is enabled, we filter by your name/title and if your exit_code is not satisfactory sing us a Critique:

perl centreon_plugins.pl --plugin=apps::NSCLIENT::Restapi::plugin --mode=query --hostname=DIRECCION_IP_NSCLIENT --port=PUERTO_NSCLIENT --proto=https --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE" --legacy-password='MambruSefueALaGuerraQueDolorQueDolor' --command=check_tasksched --arg="filter=enabled eq 1 and title eq 'NOMBRE DE lA TAREA PROGRAMADA'" --arg="critical=exit_code != 0"

As always, once we have the command we need, we can take it to Centreon and register it in “Configuration” > “Commands” > “Checks”, with the following command line and with a single argument so that when the Services are registered then you only have to enter the name of the Windows Scheduled Task:

perl $CENTREONPLUGINS$/centreon-plugins/src/centreon_plugins.pl --plugin=apps::NSCLIENT::Restapi::plugin --mode=query --hostname=$HOSTADDRESS$ --port=8888 --proto=https --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE" --legacy-password='CONTRASEÑA' --command=check_tasksched --arg="filter=enabled eq 1 and title eq '$ARG1$'" --arg="critical=exit_code != 0"

What I said, create the Services, we associate them with the Command that we have just created and it will ask us 1 argument to be completed, being the name of the scheduled task that we want to check. Something perhaps to keep in mind is that we will have to configure how often we want the service to run in Centreon, since by default it will run every 5 minutes and our task is still executed once a day, we will use 'Normal Check Interval' for this, as well as the period of the check, if we prefer the check-in to be carried out at a particular time (and not 24 hours a day).

And as always, after exporting the configuration in Centreon, our monitored scheduled tasks will appear, No task will be left out of control, and especially if one ends in an incorrect way, We will find out.

Ready with this, As you can imagine, there are many possibilities with this command, It has numerous arguments with which we can make the filter that we need in particular, or if you don't need a lot of complexity, This post will surely come in handy. I wish you a good week, May it go wonderfully well, and that you take care of the one next to 😉 you

Recommended Posts

Author

nheobug@bujarra.com
Autor del blog Bujarra.com Cualquier necesidad que tengas, Do not hesitate to contact me, I will try to help you whenever I can, Sharing is living ;) . Enjoy documents!!!