From 9538b81c2994918d1ac87189d226f7f54933ea15 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Fri, 22 Sep 2017 12:48:18 +1000 Subject: [PATCH 01/11] make the bootchart binary static Signed-off-by: Sven Dowideit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1cc2974..fa7b863 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,7 @@ bootchartd: bootchartd.in $(substitute_variables) $^ > $@ bootchart-collector: $(COLLECTOR) - $(CC) $(CFLAGS) $(LDFLAGS) -pthread -Icollector -o $@ $^ + $(CC) $(CFLAGS) $(LDFLAGS) -static -pthread -Icollector -o $@ $^ pybootchartgui/main.py: pybootchartgui/main.py.in $(substitute_variables) $^ > $@ From f559ff6c153be24772cfe69a28d58f3f0c83e4d5 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Fri, 22 Sep 2017 13:02:34 +1000 Subject: [PATCH 02/11] Make a LinuxKit Dockerfile for the collectord Signed-off-by: Sven Dowideit --- Dockerfile.init | 10 ++++++++++ Makefile | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 Dockerfile.init diff --git a/Dockerfile.init b/Dockerfile.init new file mode 100644 index 0000000..5753b6c --- /dev/null +++ b/Dockerfile.init @@ -0,0 +1,10 @@ + +# Build a LinuxKit rootfs for the bootchartd + +FROM scratch + + +ADD bootchartd /sbin/ +ADD bootchartd.conf /etc/ +ADD bootchart-collector /lib/bootchart/ + diff --git a/Makefile b/Makefile index fa7b863..8c52cd2 100644 --- a/Makefile +++ b/Makefile @@ -136,3 +136,6 @@ test: pybootchartgui/tests echo "Testing $$f...";\ $(PYTHON) "$$f";\ done + +docker-init: all + docker build -t svendowideit/bootchart:init -f Dockerfile.init . From dac8f0088f9c55726dccbdd4ea6cae9e0e26a29b Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 10 Oct 2017 14:39:54 +1000 Subject: [PATCH 03/11] Make a svendowideit/bootchart:pybootchartgui image for making the png Signed-off-by: Sven Dowideit --- Dockerfile.pybootchartgui | 11 +++++++++++ Makefile | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 Dockerfile.pybootchartgui diff --git a/Dockerfile.pybootchartgui b/Dockerfile.pybootchartgui new file mode 100644 index 0000000..60f273f --- /dev/null +++ b/Dockerfile.pybootchartgui @@ -0,0 +1,11 @@ +FROM alpine + +RUN apk add --no-cache python py2-cairo + +WORKDIR /bootchart/ + +ADD pybootchartgui /bootchart/pybootchartgui/ +ADD pybootchartgui.py /bootchart/ +ADD pybootchartgui.1 /bootchart/ + +ENTRYPOINT ["./pybootchartgui.py", "--output", "/var/log/", "--show-all", "--no-prune"] diff --git a/Makefile b/Makefile index 8c52cd2..e1fc3d9 100644 --- a/Makefile +++ b/Makefile @@ -139,3 +139,6 @@ test: pybootchartgui/tests docker-init: all docker build -t svendowideit/bootchart:init -f Dockerfile.init . + +docker-py: all + docker build -t svendowideit/bootchart:pybootchartgui -f Dockerfile.pybootchartgui . From f9920ddfb5e7e3cf2910c179be5e29a9440ec88e Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 10 Oct 2017 15:47:43 +1000 Subject: [PATCH 04/11] use svg Signed-off-by: Sven Dowideit --- Dockerfile.pybootchartgui | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.pybootchartgui b/Dockerfile.pybootchartgui index 60f273f..ff12903 100644 --- a/Dockerfile.pybootchartgui +++ b/Dockerfile.pybootchartgui @@ -8,4 +8,5 @@ ADD pybootchartgui /bootchart/pybootchartgui/ ADD pybootchartgui.py /bootchart/ ADD pybootchartgui.1 /bootchart/ -ENTRYPOINT ["./pybootchartgui.py", "--output", "/var/log/", "--show-all", "--no-prune"] +ENTRYPOINT ["./pybootchartgui.py", "--output", "/var/log/", "--show-all", "--format", "svg"] +#, "--no-prune"] From 13af8226df4328be81e76818f6a5ba1c5feaf403 Mon Sep 17 00:00:00 2001 From: AzureCrimson <31549911+AzureCrimson@users.noreply.github.com> Date: Sat, 28 Apr 2018 15:14:44 -0400 Subject: [PATCH 05/11] Make dmesg parsing non-UTF-tolerant When Python's bytes.decode() method encounters encounters a byte sequence that cannot be decoded, it will take an action dependent on its second argument: 'strict': raise UnicodeDecodeError exception (default) 'replace': insert U+FFFD 'ignore': skip to next character While most inputs appear to be sanitized, dmesg output is passed to _parse_dmesg() as is, and can contain data that escapes to invalid Unicode. When the parser attempts to decode this data it immediately raises an exception and dies, as seen in https://github.com/xrmx/bootchart/issues/77. To prevent this issue, I set the error handling method to 'replace', as 'ignore' can hide decoding errors from developers working with *really* broken dmesg logs. The parts of dmesg the parser looks at should be in a standard format anyway, so a U+FFFD (Replacement Character) or two after the timestamp shouldn't be too harmful. --- pybootchartgui/parsing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybootchartgui/parsing.py b/pybootchartgui/parsing.py index 993d7bf..2bf4a61 100644 --- a/pybootchartgui/parsing.py +++ b/pybootchartgui/parsing.py @@ -526,7 +526,7 @@ def _parse_dmesg(writer, file): processMap['k-boot'] = kernel base_ts = False max_ts = 0 - for line in file.read().decode('utf-8').split('\n'): + for line in file.read().decode('utf-8', 'replace').split('\n'): t = timestamp_re.match (line) if t is None: # print "duff timestamp " + line From 89bd2b5f806b6f9b16de5c9f975cb59468d99656 Mon Sep 17 00:00:00 2001 From: Cengiz Can <123910+cengizIO@users.noreply.github.com> Date: Thu, 18 Oct 2018 17:56:26 +0300 Subject: [PATCH 06/11] fix CROSS_COMPILE prefix in CC Hello, With gnu make (4.1), I wasn't able to override `CC` value with `CROSS_COMPILE`. To find out what's really going on, I've added this temporary build target to dump variables ``` print-% : ; @echo $* = $($*) ``` Whenever I pass `CONFIG_CROSS_COMPILE` via environment, it was getting assigned to `CROSS_COMPILE` but `make` was not changing the default value of `CC` due to `?=` operator: ``` $ CONFIG_CROSS_COMPILE=arm-linux-gnueabihf- make print-CROSS_COMPILE print-CC CROSS_COMPILE = arm-linux-gnueabihf- CC = cc ``` So I've replaced the `?=` operator with `=`. _(This will prevent `CC=compiler make` definitions from working properly but that can be resolved by `CC=compiler make -e`, if needed.)_ --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1cc2974..9bff4eb 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ PKG_NAME=bootchart2 PKG_TARBALL=$(PKG_NAME)-$(VER).tar.bz2 CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) +CC = $(CROSS_COMPILE)gcc -CC ?= $(CROSS_COMPILE)gcc CFLAGS ?= -g -Wall -O0 CPPFLAGS ?= From 9b01b4122d7ef3ac2757f553e9e9a1fbbed681a7 Mon Sep 17 00:00:00 2001 From: Georges Savoundararadj Date: Thu, 23 May 2019 17:18:26 -0700 Subject: [PATCH 07/11] collector: include missing header for makedev --- collector/collector.c | 1 + 1 file changed, 1 insertion(+) diff --git a/collector/collector.c b/collector/collector.c index 54d3c6a..5055181 100644 --- a/collector/collector.c +++ b/collector/collector.c @@ -39,6 +39,7 @@ #include #include #include +#include /* pid uniqifying code */ typedef struct { From 39cef4fe07ecc559e305717e46f466649c045b10 Mon Sep 17 00:00:00 2001 From: Pops Dylan Date: Fri, 3 Jan 2020 07:07:15 -0800 Subject: [PATCH 08/11] set EXIT_PROC="sshd" --- bootchartd.conf | 17 +---------------- bootchartd.in | 16 +--------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/bootchartd.conf b/bootchartd.conf index 7c45cb5..9599451 100644 --- a/bootchartd.conf +++ b/bootchartd.conf @@ -30,19 +30,4 @@ AUTO_RENDER_DIR="/var/log" CUSTOM_POST_CMD="" # The processes we have to wait for -EXIT_PROC="compiz \ - enlightenment \ - fluxbox \ - gnome-shell \ - gnome-terminal \ - icewm-session \ - kdm_greet \ - konsole \ - ldm \ - lightdm-gtk-greeter \ - metacity \ - mutter \ - openbox \ - sddm-helper \ - xfwm4 \ - xterm" +EXIT_PROC="sshd" diff --git a/bootchartd.in b/bootchartd.in index 7979ef9..d1709eb 100755 --- a/bootchartd.in +++ b/bootchartd.in @@ -43,21 +43,7 @@ AUTO_RENDER_DIR="/var/log" AUTO_RENDER_FORMAT="png" # The processes we have to wait for -EXIT_PROC="compiz \ - enlightenment \ - fluxbox \ - gnome-shell \ - gnome-terminal \ - icewm-session \ - kdm_greet \ - konsole \ - ldm \ - lightdm-gtk-greeter \ - metacity \ - mutter \ - openbox \ - xfwm4 \ - xterm" +EXIT_PROC="sshd" # Read configuration. CONFBASE="${PROGRAM_PREFIX}bootchartd${PROGRAM_SUFFIX}" From d44de61737baa7b45498de72df2106e723a07908 Mon Sep 17 00:00:00 2001 From: Pops Dylan Date: Fri, 3 Jan 2020 17:14:40 -0800 Subject: [PATCH 09/11] Compatibility with python 3.8+ --- pybootchartgui.py | 2 +- pybootchartgui/parsing.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pybootchartgui.py b/pybootchartgui.py index 947ce10..55f56ca 100755 --- a/pybootchartgui.py +++ b/pybootchartgui.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # This file is part of pybootchartgui. diff --git a/pybootchartgui/parsing.py b/pybootchartgui/parsing.py index 993d7bf..433eb8b 100644 --- a/pybootchartgui/parsing.py +++ b/pybootchartgui/parsing.py @@ -23,7 +23,7 @@ import re import sys import tarfile -from time import clock +from time import perf_counter from collections import defaultdict from functools import reduce @@ -658,7 +658,7 @@ def get_num_cpus(headers): def _do_parse(writer, state, name, file): writer.status("parsing '%s'" % name) - t1 = clock() + t1 = perf_counter() if name == "header": state.headers = _parse_headers(file) elif name == "proc_diskstats.log": @@ -680,7 +680,7 @@ def _do_parse(writer, state, name, file): state.ps_stats = _parse_proc_ps_log(writer, file) elif name == "kernel_pacct": # obsoleted by PROC_EVENTS state.parent_map = _parse_pacct(writer, file) - t2 = clock() + t2 = perf_counter() writer.info(" %s seconds" % str(t2-t1)) return state From 1a43ca5880246b9a7c6cf4845de10e5d63d093f9 Mon Sep 17 00:00:00 2001 From: Pops Dylan Date: Sat, 4 Jan 2020 10:24:20 -0800 Subject: [PATCH 10/11] remove interactive mode, for compatibility with python 3 --- pybootchartgui/main.py.in | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pybootchartgui/main.py.in b/pybootchartgui/main.py.in index e809198..164fcf3 100644 --- a/pybootchartgui/main.py.in +++ b/pybootchartgui/main.py.in @@ -30,8 +30,10 @@ def _mk_options_parser(): usage = "%prog [options] PATH, ..., PATH" version = "%prog v@VER@" parser = optparse.OptionParser(usage, version=version) - parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, - help="start in active mode") + # PostmarketOS: Remove interactive mode. gui.py would need changes for compatibility + # with the py3-gobject3 package. + # parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, + # help="start in active mode") parser.add_option("-f", "--format", dest="format", default="png", choices=["png", "svg", "pdf"], help="image format (png, svg, pdf); default format png") parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None, @@ -123,10 +125,12 @@ def main(argv=None): trace = parsing.Trace(writer, args, options) - if options.interactive: - from . import gui - gui.show(trace, options) - elif options.boottime: + # PostmarketOS: Remove interactive mode + # if options.interactive: + # from . import gui + # gui.show(trace, options) + #elif options.boottime: + if options.boottime: import math proc_tree = trace.proc_tree if proc_tree.idle: From 222c7d6c899320ec2f0bc40d1e21170083ea0a1a Mon Sep 17 00:00:00 2001 From: Alex Chernetz Date: Fri, 3 Jul 2020 14:56:58 -0700 Subject: [PATCH 11/11] fix whitespace --- pybootchartgui/main.py.in | 2 +- pybootchartgui/parsing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pybootchartgui/main.py.in b/pybootchartgui/main.py.in index 164fcf3..0e8f2b8 100644 --- a/pybootchartgui/main.py.in +++ b/pybootchartgui/main.py.in @@ -32,7 +32,7 @@ def _mk_options_parser(): parser = optparse.OptionParser(usage, version=version) # PostmarketOS: Remove interactive mode. gui.py would need changes for compatibility # with the py3-gobject3 package. - # parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, + # parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, # help="start in active mode") parser.add_option("-f", "--format", dest="format", default="png", choices=["png", "svg", "pdf"], help="image format (png, svg, pdf); default format png") diff --git a/pybootchartgui/parsing.py b/pybootchartgui/parsing.py index a55146f..4401ea0 100644 --- a/pybootchartgui/parsing.py +++ b/pybootchartgui/parsing.py @@ -23,7 +23,7 @@ import re import sys import tarfile -from time import perf_counter +from time import perf_counter from collections import defaultdict from functools import reduce