From 6fc08fc789cfccacc7741ba8feab849bc4f3c414 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Thu, 3 May 2012 13:42:45 -0700 Subject: [PATCH] systemd-analyze: add a --user option to support user instances --- src/analyze/systemd-analyze | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/analyze/systemd-analyze b/src/analyze/systemd-analyze index a49fbb7..ad7bd9a 100755 --- a/src/analyze/systemd-analyze +++ b/src/analyze/systemd-analyze @@ -69,9 +69,9 @@ def draw_text(context, x, y, text, size = 12, r = 0, g = 0, b = 0, vcenter = 0.5 context.restore() def help(): - sys.stdout.write("""systemd-analyze time -systemd-analyze blame -systemd-analyze plot + sys.stdout.write("""systemd-analyze [--user] time +systemd-analyze [--user] blame +systemd-analyze [--user] plot Process systemd profiling information @@ -80,8 +80,14 @@ Process systemd profiling information bus = dbus.SystemBus() +command_index = 1 -if len(sys.argv) <= 1 or sys.argv[1] == 'time': +if len(sys.argv) > 1 and sys.argv[1] == '--user': + bus = dbus.SessionBus() + command_index = 2 + + +if len(sys.argv) <= command_index or sys.argv[command_index] == 'time': initrd_time, start_time, finish_time = acquire_start_time() @@ -98,7 +104,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == 'time': finish_time/1000) -elif sys.argv[1] == 'blame': +elif sys.argv[command_index] == 'blame': data = acquire_time_data() s = sorted(data, key = lambda i: i[2] - i[1], reverse = True) @@ -113,7 +119,7 @@ elif sys.argv[1] == 'blame': sys.stdout.write("%6lums %s\n" % ((aet - ixt) / 1000, name)) -elif sys.argv[1] == 'plot': +elif sys.argv[command_index] == 'plot': import cairo, os initrd_time, start_time, finish_time = acquire_start_time() @@ -269,8 +275,8 @@ elif sys.argv[1] == 'plot': finish_time/1000), hcenter = 0, vcenter = -1) surface.finish() -elif sys.argv[1] in ("help", "--help", "-h"): +elif sys.argv[command_index] in ("help", "--help", "-h"): help() else: - sys.stderr.write("Unknown verb '%s'.\n" % sys.argv[1]) + sys.stderr.write("Unknown verb '%s'.\n" % sys.argv[command_index]) sys.exit(1) -- 2.7.4