Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The new Drush 9 version has a complete new way of defining Drush commands. Therefore, all the Drush commands in modules need to be rewritten for Drush 9.
Proposed resolution
- Rewrite the drush commands to the Drush 9 format.
- Implement sensu format and verbode mode for 'run' command.
Remaining tasks
- Rewrite all drush commands to the Drush 9 format.
Comments
Comment #2
BryanDeNijsI wrote a patch that ports the Drush commands for Drush 9.
Remaining tasks: support sensu format and verbose mode for the 'run' command.
Comment #3
BryanDeNijsComment #4
BryanDeNijsWhoops. Typo in the first patch.. Here is a new one.
Comment #5
BryanDeNijsAccording to the Nagios Developer Guidelines (http://nagios-plugins.org/doc/guidelines.html), exit code 3 means "unknown" and exit code 2 means "critical". This was reversed in the old version of this module.
I don't know if software other than Nagios interprets the exit codes differently, but this patch fixes it for Nagios.
Comment #6
BerdirNeeds a reroll.
Comment #7
BryanDeNijsRerolled onto 8.x-1.x-dev (removed the composer.json file out of the patch)
Comment #8
BerdirThanks. I think the extra part from composer.json is recommend and should be added back?
Tested this quickly manually. It looks like the sensor argument for monitoring:run is now required, which means we can't run all sensors?
The output argument to monitoring:run also doesn't seem to work, I always get a table.
And, it would be helpful to add aliases for the old commands.
Comment #9
BryanDeNijs#8: You're right. I was a bit to fast.
Here is a new patch with the composer.json addition and a fix for the monitoring:run command.
The aliases are already added so they should already work.
About the output and the verbose argument: That's true. It's still a @todo.
I didn't (and don't) have the time to write something for that. I'm sorry. Maybe somebody else can help with that.
EDIT: However, Drush 9 provides a --format argument where you can set an output format (table, csv, html. json, list, var_export, yaml)
--format=json outputs a nice JSON array. Maybe it is not needed to write something new for that :-)
Comment #10
Primsi CreditAttribution: Primsi at MD Systems GmbH for MD Systems GmbH commentedAdded an option for the sensu output, but left out the custom output options from before, because as @BryanDeNijs already mentioned, the --format option seems to do a good job.
I added a new option called --sensu-output. I was thinking about providing a new output format for sensu, but it doesn't make much sense for non monitoring output I guess.
I also left the --output option there for now, allowing just "sensu". Not sure if we want that or not.
Regarding the --verbose, I added some logic for that, but couldn't really test properly. The output there seems to be mostly empty.
Comment #11
BerdirThe problem with --format vs --output is that their output isn't the same, --output=json prints more with different keys and also supports --expand=sensor to add the sensor information as well. I added some hardcoded checks on format not table now, I think with default fields and so on, you could get cleaner results but trying to make it easy to switch from drush 8 to 9.
Verbose is weird, it only works if you combine it with force as the cached results don't have verbose information. Works ok then.
I also removed the truncating of the message for the default table output, looks fairly ok with multi-line messages I think and then you don't miss half the information.
And simplified a few option checks, all defined options are initalized, so we can do with fewer conditions, ?? and so on.
Comment #12
BerdirCommitted.