This is a ruby script to pretty print the output of initctl list.
Created
May 30, 2017 08:24
-
-
Save vyder/fb237fe0c66b80c1db4844efab5b28a1 to your computer and use it in GitHub Desktop.
Ubuntu: List upstart services + status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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