[systemd-devel] [PATCH] systemd-analyze: Show critical chains for listed units
Gabriel de Perthuis
g2p.code at gmail.com
Tue Jun 11 13:29:32 PDT 2013
---
src/analyze/systemd-analyze.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
Nb: it might be even better to show the critical chain of a fictive
unit that would depend on everything in argv, but that's more
complicated to implement.
diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c
index fe1abdc..ffdcd14 100644
--- a/src/analyze/systemd-analyze.c
+++ b/src/analyze/systemd-analyze.c
@@ -824,11 +824,11 @@ static int list_dependencies_one(DBusConnection *bus, const char *name, unsigned
}
return 0;
}
-static int list_dependencies(DBusConnection *bus) {
+static int list_dependencies(DBusConnection *bus, const char *name) {
_cleanup_strv_free_ char **units = NULL;
char ts[FORMAT_TIMESPAN_MAX];
struct unit_times *times;
int r;
const char
@@ -839,11 +839,11 @@ static int list_dependencies(DBusConnection *bus) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
struct boot_times *boot;
assert(bus);
- path = unit_dbus_path_from_name(SPECIAL_DEFAULT_TARGET);
+ path = unit_dbus_path_from_name(name);
if (path == NULL)
return -EINVAL;
r = bus_method_call_with_reply (
bus,
@@ -888,14 +888,14 @@ static int list_dependencies(DBusConnection *bus) {
printf("%s @%s\n", id, format_timespan(ts, sizeof(ts), times->aet - boot->userspace_time, USEC_PER_MSEC));
else
printf("%s\n", id);
}
- return list_dependencies_one(bus, SPECIAL_DEFAULT_TARGET, 0, &units, 0);
+ return list_dependencies_one(bus, name, 0, &units, 0);
}
-static int analyze_critical_chain(DBusConnection *bus) {
+static int analyze_critical_chain(DBusConnection *bus, char *names[]) {
struct unit_times *times;
int n, r;
unsigned int i;
Hashmap *h;
@@ -915,11 +915,17 @@ static int analyze_critical_chain(DBusConnection *bus) {
unit_times_hashmap = h;
puts("The time after the unit is active or started is printed after the \"@\" character.\n"
"The time the unit takes to start is printed after the \"+\" character.\n");
- list_dependencies(bus);
+ if (!strv_isempty(names)) {
+ char **name;
+ STRV_FOREACH(name, names)
+ list_dependencies(bus, *name);
+ } else {
+ list_dependencies(bus, SPECIAL_DEFAULT_TARGET);
+ }
hashmap_free(h);
free_unit_times(times, (unsigned) n);
return 0;
}
@@ -1299,11 +1305,11 @@ int main(int argc, char *argv[]) {
if (!argv[optind] || streq(argv[optind], "time"))
r = analyze_time(bus);
else if (streq(argv[optind], "blame"))
r = analyze_blame(bus);
else if (streq(argv[optind], "critical-chain"))
- r = analyze_critical_chain(bus);
+ r = analyze_critical_chain(bus, argv+optind+1);
else if (streq(argv[optind], "plot"))
r = analyze_plot(bus);
else if (streq(argv[optind], "dot"))
r = dot(bus, argv+optind+1);
else
--
1.8.3.222.g430da9e
More information about the systemd-devel
mailing list