Cherry pick plugin check-cmd.rb from upstream

Cherry pick plugin check-cmd.rb from upstream