Once the module is setup and ready, a drush command should be provided that will allow running monitor tasks by tag.

This command should be compatible with drush 8 and 9.

Additionally, this ticket should include updating the associated drush command documentation here:
https://www.drupal.org/docs/8/modules/system-monitor/drush

The update should include a sample usage of the command and what it does.

Comments

merauluka created an issue. See original summary.

merauluka’s picture

Issue summary: View changes

Updated the original ticket description to include updating the documentation page as part of this ticket.

merauluka’s picture

Title: Implement drush command to run monitor tasks by task group » Implement drush command to run monitor tasks by task tag
Issue summary: View changes

Updated ticket description to more accurate describe the work needed.

merauluka’s picture

Now that I have worked on the monitor tagging issue, I think that we'll want to have a option in this drush command to run either tasks or full monitors with certain tags. So if someone wants to tag a monitor, then running the drush command would trigger all active tasks in that monitor. And if they run it at the task level, it would run all tasks that contain the tag.

One thing I'm not sure of though, If we do it this way, should we run all tasks with the tag, regardless of whether they're active in a monitor, or should we only run active tasks? Maybe we should make the default for active tasks and an override that runs all tasks, regardless of whether or not they're associated with a monitor?

But maybe that doesn't make sense. Because if we run an inactive monitor, it wouldn't/shouldn't trigger notifications I'd think.

What are your thoughts @robpowell?

robpowell’s picture

Clarification on the requirements, I would prefer to make the drush 8 command then update all the command to drush 9 in another ticket.

I think we should honor disabled property of the task. It sounds like the drush command should be able to do the following:

  • run monitor(s)
  • run task(s)
  • run task(s) via tag
  • run monitor(s) via tag

If I have this right, the drush command should have two parameters, type to to run (monitor/task) and machine names of entities. There will also be an option to accept flag name. Do this sound right to you?

robpowell’s picture

Assigned: robpowell » merauluka
Status: Active » Needs review
merauluka’s picture

Status: Needs review » Needs work

@robpowell That sounds right on the money.

robpowell’s picture

Assigned: merauluka » robpowell
robpowell’s picture

StatusFileSize
new672 bytes

So having an interesting bug where the drush command fails when running ddev . drush sm:run monitor. If I look at watchdog logs,

 ID   Date          Type      Severity  Message                                                                
 130  24/Jan 20:44  system_m  info      No active monitors could be run because no active monitors were found. 
                    onitor                                                                                     

If I run the service through the a form, basically debugging outside of drush, It passes without issue

 /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    $system_monitor_task = \Drupal::service('plugin.manager.system_monitor_task');
    $system_monitor_task->runSystemMonitorTasks();
    $system_monitor_task->runSystemMonitorTasks([], []);
}

When I go to /admin/config/system/system-monitor/configure I get a message "success" which means the task ran. To run, you will need to download and enable https://gitlab.com/merauluka/system-monitor-demo.

robpowell’s picture

Status: Needs work » Needs review
robpowell’s picture

StatusFileSize
new12.44 KB

Ah ha! It turns out exploding an empty string gives you an array with an empty value NOT an empty array. Here's the code in its entirety.

merauluka’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me! Let's merge.

  • 67a5d5b committed on 8.x-1.x
    Issue #3074971 by robpowell, merauluka: Implement drush command to run...
robpowell’s picture

merged into 8.x-1.x

robpowell’s picture

Assigned: robpowell » Unassigned
Status: Reviewed & tested by the community » Fixed

  • 67a5d5b committed on 9.x-1.x
    Issue #3074971 by robpowell, merauluka: Implement drush command to run...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.