Skip to content

Instantly share code, notes, and snippets.

@vyder
Created May 30, 2017 08:24
Show Gist options
  • Save vyder/fb237fe0c66b80c1db4844efab5b28a1 to your computer and use it in GitHub Desktop.
Save vyder/fb237fe0c66b80c1db4844efab5b28a1 to your computer and use it in GitHub Desktop.
Ubuntu: List upstart services + status

This is a ruby script to pretty print the output of initctl list.

#!/usr/bin/env ruby
require 'colorize'
require 'terminal-table'
data = %x(initctl list)
STATUS = {
up: "✓".green,
down: "✗".red
}
services = []
data.split("\n").each do |line|
line = line.split(" ")
is_up = line[1].match /running/
services << [line[0], (is_up ? STATUS[:up] : STATUS[:down])]
end
puts Terminal::Table.new({
title: "Services Status Report",
headings: ["Name", "Status"],
rows: services
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment