Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions resources/lib/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ def execute()

# Paint service list
if $parser.data[:show_runtime] && $parser.data[:show_memory]
printf("=========================================== Services =====================================================\n")
printf("%-33s %-33s %-15s %-10s %-33s\n", "Service", "Status(#{node_name})", "Runtime", "Memory", "Cgroup")
printf("----------------------------------------------------------------------------------------------------------\n")
printf("====================================================== Services ===========================================================================\n")
printf("%-33s %-33s %-23s %-25s %-33s\n", "Service", "Status(#{node_name})", "Runtime", "Cgroup", "Memory")
printf("-------------------------------------------------------------------------------------------------------------------------------------------\n")
elsif $parser.data[:show_runtime]
printf("================================= Services =========================================\n")
printf("%-33s %-33s %-10s %-33s\n", "Service", "Status(#{node_name})", "Runtime", "Cgroup")
Expand Down Expand Up @@ -283,23 +283,23 @@ def execute()

if $parser.data[:show_runtime] && $parser.data[:show_memory]
if runtime.match?(/^\d+\s*s/)
printf("%-33s #{green}%-33s#{reset} #{blink}%-15s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{green}%-33s#{reset} #{blink}%-23s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
else
printf("%-33s #{green}%-33s#{reset} %-15s %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{green}%-33s#{reset} %-23s %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
end
elsif $parser.data[:show_runtime]
if runtime.match?(/^\d+\s*s/)
printf("%-33s #{green}%-33s#{reset} #{blink}%-15s#{reset} %-25s\n",
printf("%-33s #{green}%-33s#{reset} #{blink}%-23s#{reset} %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
else
printf("%-33s #{green}%-33s#{reset} %-15s %-25s\n",
printf("%-33s #{green}%-33s#{reset} %-23s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
end
elsif $parser.data[:show_memory]
printf("%-33s #{green}%-33s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, memory_used, cgroup)
printf("%-33s #{green}%-33s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, cgroup, memory_used)
else
printf("%-33s #{green}%-33s#{reset} %-25s\n",
"#{systemd_service}:", ret, cgroup)
Expand All @@ -311,14 +311,14 @@ def execute()
memory_used = "0B"

if $parser.data[:show_runtime] && $parser.data[:show_memory]
printf("%-33s #{red}%-33s#{reset} %-15s %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{red}%-33s#{reset} %-23s %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
elsif $parser.data[:show_runtime]
printf("%-33s #{red}%-33s#{reset} %-15s %-25s\n",
printf("%-33s #{red}%-33s#{reset} %-23s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
elsif $parser.data[:show_memory]
printf("%-33s #{red}%-33s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, memory_used, cgroup)
printf("%-33s #{red}%-33s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, cgroup, memory_used)
else
printf("%-33s #{red}%-33s#{reset} %-25s\n",
"#{systemd_service}:", ret, cgroup)
Expand All @@ -336,23 +336,23 @@ def execute()

if $parser.data[:show_runtime] && $parser.data[:show_memory]
if runtime.match?(/^\d+\s*s/)
printf("%-33s #{green}%-33s#{reset} #{blink}%-15s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{green}%-33s#{reset} #{blink}%-23s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
else
printf("%-33s #{green}%-33s#{reset} %-15s %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{green}%-33s#{reset} %-23s %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
end
elsif $parser.data[:show_runtime]
if runtime.match?(/^\d+\s*s/)
printf("%-33s #{green}%-33s#{reset} #{blink}%-15s#{reset} %-25s\n",
printf("%-33s #{green}%-33s#{reset} #{blink}%-23s#{reset} %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
else
printf("%-33s #{green}%-33s#{reset} %-15s %-25s\n",
printf("%-33s #{green}%-33s#{reset} %-23s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
end
elsif $parser.data[:show_memory]
printf("%-33s #{green}%-33s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, memory_used, cgroup)
printf("%-33s #{green}%-33s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, cgroup, memory_used)
else
printf("%-33s #{green}%-33s#{reset} %-25s\n",
"#{systemd_service}:", ret, cgroup)
Expand All @@ -365,14 +365,14 @@ def execute()
memory_used = "0B"

if $parser.data[:show_runtime] && $parser.data[:show_memory]
printf("%-33s #{yellow}%-33s#{reset} %-15s %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{yellow}%-33s#{reset} %-23s %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
elsif $parser.data[:show_runtime]
printf("%-33s #{yellow}%-33s#{reset} %-15s %-25s\n",
printf("%-33s #{yellow}%-33s#{reset} %-23s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
elsif $parser.data[:show_memory]
printf("%-33s #{yellow}%-33s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, memory_used, cgroup)
printf("%-33s #{yellow}%-33s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, cgroup, memory_used)
else
printf("%-33s #{yellow}%-33s#{reset} %-25s\n",
"#{systemd_service}:", ret, cgroup)
Expand All @@ -386,14 +386,14 @@ def execute()
memory_used = "0B"

if $parser.data[:show_runtime] && $parser.data[:show_memory]
printf("%-33s #{blue}%-33s#{reset} %-15s %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{blue}%-33s#{reset} %-23s %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
elsif $parser.data[:show_runtime]
printf("%-33s #{blue}%-33s#{reset} %-15s %-25s\n",
printf("%-33s #{blue}%-33s#{reset} %-23s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
elsif $parser.data[:show_memory]
printf("%-33s #{blue}%-33s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, memory_used, cgroup)
printf("%-33s #{blue}%-33s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, cgroup, memory_used)
else
printf("%-33s #{blue}%-33s#{reset} %-25s\n",
"#{systemd_service}:", ret, cgroup)
Expand All @@ -406,14 +406,14 @@ def execute()
memory_used = "0B"

if $parser.data[:show_runtime] && $parser.data[:show_memory]
printf("%-33s #{red}%-33s#{reset} %-15s %-10s %-25s\n",
"#{systemd_service}:", ret, runtime, memory_used, cgroup)
printf("%-33s #{red}%-33s#{reset} %-23s %-25s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup, memory_used)
elsif $parser.data[:show_runtime]
printf("%-33s #{red}%-33s#{reset} %-15s %-25s\n",
printf("%-33s #{red}%-33s#{reset} %-23s %-25s\n",
"#{systemd_service}:", ret, runtime, cgroup)
elsif $parser.data[:show_memory]
printf("%-33s #{red}%-33s#{reset} %-10s %-25s\n",
"#{systemd_service}:", ret, memory_used, cgroup)
printf("%-33s #{red}%-33s#{reset} %-25s %-25s\n",
"#{systemd_service}:", ret, cgroup, memory_used)
else
printf("%-33s #{red}%-33s#{reset} %-25s\n",
"#{systemd_service}:", ret, cgroup)
Expand All @@ -422,7 +422,7 @@ def execute()
end

if $parser.data[:show_runtime] && $parser.data[:show_memory]
printf("----------------------------------------------------------------------------------------------------------\n")
printf("-------------------------------------------------------------------------------------------------------------------------------------------\n")
elsif $parser.data[:show_runtime] || $parser.data[:show_memory]
printf("------------------------------------------------------------------------------------\n")
else
Expand All @@ -443,15 +443,15 @@ def execute()
end

if $parser.data[:show_memory] && $parser.data[:show_runtime]
printf("%-33s %-10s %49s\n","Total:", services.count, total_memory_formatted)
printf("%-33s %-10s %-23s %-25s %s\n","Total:", services.count, "", "", total_memory_formatted)
elsif $parser.data[:show_memory]
printf("%-33s %-10s %28s\n","Total:", services.count, total_memory_formatted)
else
printf("%-33s %-10s\n","Total:", services.count)
end

if $parser.data[:show_runtime] && $parser.data[:show_memory]
printf("----------------------------------------------------------------------------------------------------------\n")
printf("-------------------------------------------------------------------------------------------------------------------------------------------\n")
elsif $parser.data[:show_runtime] || $parser.data[:show_memory]
printf("------------------------------------------------------------------------------------\n")
else
Expand Down