[systemd-commits] 4 commits - fixme Makefile.am src/dbus-manager.c src/job.c src/manager.c src/manager.h src/systemctl.c src/util.h units/tmpwatch.service units/tmpwatch.timer
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Sep 20 19:26:33 PDT 2010
Makefile.am | 8 ++++++--
fixme | 2 --
src/dbus-manager.c | 22 ++++++++++++++++++++++
src/job.c | 2 ++
src/manager.c | 31 +++++++++++++++++++++++++++++++
src/manager.h | 5 +++++
src/systemctl.c | 8 ++++++++
src/util.h | 2 ++
units/tmpwatch.service | 21 +++++++++++++++++++++
units/tmpwatch.timer | 14 ++++++++++++++
10 files changed, 111 insertions(+), 4 deletions(-)
New commits:
commit 05d6a3b6cff405e43fd95a26e342b9233b21269b
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Sep 21 04:25:48 2010 +0200
manager: calculate progress value while booting
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index c08781d..53dbeac 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -221,6 +221,24 @@ static int bus_manager_append_n_jobs(Manager *m, DBusMessageIter *i, const char
return 0;
}
+static int bus_manager_append_progress(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ double d;
+
+ assert(m);
+ assert(i);
+ assert(property);
+
+ if (dual_timestamp_is_set(&m->finish_timestamp))
+ d = 1.0;
+ else
+ d = 1.0 - ((double) hashmap_size(m->jobs) / (double) m->n_installed_jobs);
+
+ if (!dbus_message_iter_append_basic(i, DBUS_TYPE_DOUBLE, &d))
+ return -ENOMEM;
+
+ return 0;
+}
+
static const char *message_get_sender_with_fallback(DBusMessage *m) {
const char *s;
@@ -248,6 +266,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", NULL },
{ "org.freedesktop.systemd1.Manager", "NJobs", bus_manager_append_n_jobs, "u", NULL },
{ "org.freedesktop.systemd1.Manager", "NInstalledJobs",bus_property_append_uint32, "u", &m->n_installed_jobs },
+ { "org.freedesktop.systemd1.Manager", "Progress", bus_manager_append_progress, "d", NULL },
{ "org.freedesktop.systemd1.Manager", "Environment", bus_property_append_strv, "as", m->environment },
{ "org.freedesktop.systemd1.Manager", "ConfirmSpawn", bus_property_append_bool, "b", &m->confirm_spawn },
{ "org.freedesktop.systemd1.Manager", "ShowStatus", bus_property_append_bool, "b", &m->show_status },
diff --git a/src/systemctl.c b/src/systemctl.c
index 525e2f0..2525967 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -2003,6 +2003,14 @@ static int print_property(const char *name, DBusMessageIter *iter) {
return 0;
}
+ case DBUS_TYPE_DOUBLE: {
+ double d;
+ dbus_message_iter_get_basic(iter, &d);
+
+ printf("%s=%g\n", name, d);
+ return 0;
+ }
+
case DBUS_TYPE_STRUCT: {
DBusMessageIter sub;
dbus_message_iter_recurse(iter, &sub);
commit b0c918b97f1abb160d8df2b94deb03efcb4fcf8f
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Sep 21 04:14:38 2010 +0200
manager: measure startup times
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index fb10bd4..c08781d 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -242,6 +242,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "org.freedesktop.systemd1.Manager", "Version", bus_property_append_string, "s", PACKAGE_STRING },
{ "org.freedesktop.systemd1.Manager", "RunningAs", bus_manager_append_running_as, "s", &m->running_as },
{ "org.freedesktop.systemd1.Manager", "StartupTimestamp", bus_property_append_uint64, "t", &m->startup_timestamp.realtime },
+ { "org.freedesktop.systemd1.Manager", "FinishTimestamp", bus_property_append_uint64, "t", &m->finish_timestamp.realtime },
{ "org.freedesktop.systemd1.Manager", "LogLevel", bus_manager_append_log_level, "s", NULL },
{ "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", NULL },
{ "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", NULL },
diff --git a/src/job.c b/src/job.c
index 7b20987..ac3bb9d 100644
--- a/src/job.c
+++ b/src/job.c
@@ -540,6 +540,8 @@ int job_finish_and_invalidate(Job *j, bool success) {
if (other->meta.job)
job_add_to_run_queue(other->meta.job);
+ manager_check_finished(u->meta.manager);
+
return 0;
}
diff --git a/src/manager.c b/src/manager.c
index 31dd44c..1be2bfd 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -2173,6 +2173,8 @@ int manager_loop(Manager *m) {
set_free_free(m->unit_path_cache);
m->unit_path_cache = NULL;
+ manager_check_finished(m);
+
/* There might still be some zombies hanging around from
* before we were exec()'ed. Leat's reap them */
if ((r = manager_dispatch_sigchld(m)) < 0)
@@ -2598,6 +2600,34 @@ bool manager_unit_pending_inactive(Manager *m, const char *name) {
return unit_pending_inactive(u);
}
+void manager_check_finished(Manager *m) {
+ char userspace[FORMAT_TIMESPAN_MAX], kernel[FORMAT_TIMESPAN_MAX], sum[FORMAT_TIMESPAN_MAX];
+
+ assert(m);
+
+ if (dual_timestamp_is_set(&m->finish_timestamp))
+ return;
+
+ if (hashmap_size(m->jobs) > 0)
+ return;
+
+ dual_timestamp_get(&m->finish_timestamp);
+
+ if (m->running_as == MANAGER_SYSTEM)
+ log_info("Startup finished in %s (kernel) + %s (userspace) = %s.",
+ format_timespan(kernel, sizeof(kernel),
+ m->startup_timestamp.monotonic),
+ format_timespan(userspace, sizeof(userspace),
+ m->finish_timestamp.monotonic - m->startup_timestamp.monotonic),
+ format_timespan(sum, sizeof(sum),
+ m->finish_timestamp.monotonic));
+ else
+ log_debug("Startup finished in %s.",
+ format_timespan(userspace, sizeof(userspace),
+ m->finish_timestamp.monotonic - m->startup_timestamp.monotonic));
+
+}
+
static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
[MANAGER_SYSTEM] = "system",
[MANAGER_SESSION] = "session"
diff --git a/src/manager.h b/src/manager.h
index a137eb7..c404443 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -139,6 +139,7 @@ struct Manager {
char **environment;
dual_timestamp startup_timestamp;
+ dual_timestamp finish_timestamp;
char *console;
@@ -263,6 +264,8 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success);
bool manager_unit_pending_inactive(Manager *m, const char *name);
+void manager_check_finished(Manager *m);
+
const char *manager_running_as_to_string(ManagerRunningAs i);
ManagerRunningAs manager_running_as_from_string(const char *s);
diff --git a/src/util.h b/src/util.h
index 7ea163f..ae00ff5 100644
--- a/src/util.h
+++ b/src/util.h
@@ -73,6 +73,8 @@ usec_t now(clockid_t clock);
dual_timestamp* dual_timestamp_get(dual_timestamp *ts);
+#define dual_timestamp_is_set(ts) ((ts)->realtime > 0)
+
usec_t timespec_load(const struct timespec *ts);
struct timespec *timespec_store(struct timespec *ts, usec_t u);
commit e409f87570a87009d023e1ba97263445241b84d3
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Sep 21 03:51:31 2010 +0200
manager: count how many jobs we executed
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index cffa547..fb10bd4 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -132,6 +132,7 @@
" <property name=\"LogTarget\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"NNames\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"NJobs\" type=\"u\" access=\"read\"/>\n" \
+ " <property name=\"NInstalledJobs\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Environment\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"ConfirmSpawn\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"ShowStatus\" type=\"b\" access=\"read\"/>\n" \
@@ -245,6 +246,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
{ "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", NULL },
{ "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", NULL },
{ "org.freedesktop.systemd1.Manager", "NJobs", bus_manager_append_n_jobs, "u", NULL },
+ { "org.freedesktop.systemd1.Manager", "NInstalledJobs",bus_property_append_uint32, "u", &m->n_installed_jobs },
{ "org.freedesktop.systemd1.Manager", "Environment", bus_property_append_strv, "as", m->environment },
{ "org.freedesktop.systemd1.Manager", "ConfirmSpawn", bus_property_append_bool, "b", &m->confirm_spawn },
{ "org.freedesktop.systemd1.Manager", "ShowStatus", bus_property_append_bool, "b", &m->show_status },
diff --git a/src/manager.c b/src/manager.c
index 27c8aa4..31dd44c 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -1182,6 +1182,7 @@ static int transaction_apply(Manager *m) {
j->unit->meta.job = j;
j->installed = true;
+ m->n_installed_jobs ++;
/* We're fully installed. Now let's free data we don't
* need anymore. */
diff --git a/src/manager.h b/src/manager.h
index 4455372..a137eb7 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -207,6 +207,8 @@ struct Manager {
bool swap_auto;
int n_deserializing;
+
+ unsigned n_installed_jobs;
};
int manager_new(ManagerRunningAs running_as, Manager **m);
commit f0a73e245c1646c6c62a3bd0a3db969dd2e55edc
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Sep 21 03:38:32 2010 +0200
units: add default tmpwatch units
diff --git a/Makefile.am b/Makefile.am
index 3ab79ba..b5b2a9d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -979,12 +979,16 @@ install-data-hook:
dev-mqueue.automount \
proc-sys-fs-binfmt_misc.automount \
sys-kernel-debug.automount \
- sys-kernel-security.automount && \
+ sys-kernel-security.automount \
+ tmpwatch.timer \
+ tmpwatch.service && \
$(LN_S) ../dev-hugepages.automount dev-hugepages.automount && \
$(LN_S) ../dev-mqueue.automount dev-mqueue.automount && \
$(LN_S) ../proc-sys-fs-binfmt_misc.automount proc-sys-fs-binfmt_misc.automount && \
$(LN_S) ../sys-kernel-debug.automount sys-kernel-debug.automount && \
- $(LN_S) ../sys-kernel-security.automount sys-kernel-security.automount )
+ $(LN_S) ../sys-kernel-security.automount sys-kernel-security.automount && \
+ $(LN_S) ../tmpwatch.timer && \
+ $(LN_S) ../tmpwatch.service )
( cd $(DESTDIR)$(dbussessionservicedir) && \
rm -f org.freedesktop.systemd1.service && \
$(LN_S) ../system-services/org.freedesktop.systemd1.service org.freedesktop.systemd1.service )
diff --git a/fixme b/fixme
index 4e29ae3..38c7dbd 100644
--- a/fixme
+++ b/fixme
@@ -99,8 +99,6 @@
* properly handle bind mounts in /etc/fstab
-* cleanup /tmp.
-
External:
* place /etc/inittab with explaining blurb.
diff --git a/units/tmpwatch.service b/units/tmpwatch.service
new file mode 100644
index 0000000..55f8f0a
--- /dev/null
+++ b/units/tmpwatch.service
@@ -0,0 +1,21 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Cleanup of Temporary Directories
+DefaultDependencies=no
+Wants=local-fs.target
+After=local-fs.target
+Before=poweroff.service reboot.service halt.service killall.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/tmpwatch -umc -x /tmp/.X11-unix -x /tmp/.ICE-unix 10d /tmp
+ExecStart=/usr/sbin/tmpwatch -umc 30d /var/tmp
+
+[Install]
+WantedBy=shutdown.target
diff --git a/units/tmpwatch.timer b/units/tmpwatch.timer
new file mode 100644
index 0000000..222e3d2
--- /dev/null
+++ b/units/tmpwatch.timer
@@ -0,0 +1,14 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Daily Cleanup of Temporary Directories
+DefaultDependency=no
+
+[Timer]
+OnBootSec=1d
+OnUnitActiveSec=1d
More information about the systemd-commits
mailing list