X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbootchart%2Fbootchart.c;h=5683025b1970df3f16da846326f70c2713c68fb8;hb=9a6f36c08f1ff93ff861e6371e081122a564c900;hp=692cbb983f405e01e96f6c1e2d25495d5c9a02a9;hpb=5d459d6b07206963a022e9a95ea9d8c18dc0eab8;p=elogind.git diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c index 692cbb983..5683025b1 100644 --- a/src/bootchart/bootchart.c +++ b/src/bootchart/bootchart.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include "systemd/sd-journal.h" #include "util.h" #include "fileio.h" @@ -310,6 +310,7 @@ int main(int argc, char *argv[]) { time_t t = 0; int r; struct rlimit rlim; + bool has_procfs = false; parse_conf(); @@ -349,6 +350,16 @@ int main(int argc, char *argv[]) { log_uptime(); + if (graph_start < 0.0) { + fprintf(stderr, + "Failed to setup graph start time.\n\nThe system uptime " + "probably includes time that the system was suspended. " + "Use --rel to bypass this issue.\n"); + exit (EXIT_FAILURE); + } + + has_procfs = access("/proc/vmstat", F_OK) == 0; + LIST_HEAD_INIT(head); /* main program loop */ @@ -385,11 +396,11 @@ int main(int argc, char *argv[]) { parse_env_file("/usr/lib/os-release", NEWLINE, "PRETTY_NAME", &build, NULL); } - /* wait for /proc to become available, discarding samples */ - if (graph_start <= 0.0) - log_uptime(); - else + if (has_procfs) log_sample(samples, &sampledata); + else + /* wait for /proc to become available, discarding samples */ + has_procfs = access("/proc/vmstat", F_OK) == 0; sample_stop = gettime_ns();