Katello / katello-packaging

[DEPRECATED] Packaging for Katello
7 stars 33 forks source link

Better katello-service list output #238

Open ericzolf opened 8 years ago

ericzolf commented 8 years ago

The current output of the 'list' command just tells if the unit exists and is enabled, it doesn't tell if the service is running or not (whereas the output of 'status' is unreadable).

I suggest the following slight change to the list_services function:

    regex = services_by_priority.map { |service| "^[^a-z_-]*#{service}.service" }.join('\|')
    puts `systemctl list-units --all \*.service | grep -e '#{regex}' -e '^ *UNIT'`

The output then looks as follows (with systemctl), which is much more informative while remaining readable:

# katello-service list
  UNIT                                   LOAD      ACTIVE   SUB     DESCRIPTION
  foreman-proxy.service                  loaded    inactive dead    Foreman Proxy
  foreman-tasks.service                  loaded    inactive dead    Foreman jobs daemon
  httpd.service                          loaded    active   running The Apache HTTP Server
  mongod.service                         loaded    active   running High-performance, schema-free document-oriented database
  postgresql.service                     loaded    active   running PostgreSQL database server
  pulp_celerybeat.service                loaded    active   running Pulp's Celerybeat
  pulp_resource_manager.service          loaded    active   running Pulp Resource Manager
  pulp_workers.service                   loaded    active   exited  Pulp Celery Workers
  qdrouterd.service                      loaded    active   running Qpid Dispatch router daemon
  qpidd.service                          loaded    active   running An AMQP message broker daemon.
  tomcat.service                         loaded    active   running Apache Tomcat Web Application Container
ehelms commented 8 years ago

@ericzolf would you like to open a PR with your proposed changes? We are happy to open a PR with the patch ourselves, however, this gives you an opportunity to author and own a change within the project!

fftux commented 7 years ago

Created PR.

https://github.com/Katello/katello-packaging/pull/384