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/Dockerfile.pybootchartgui b/Dockerfile.pybootchartgui new file mode 100644 index 0000000..ff12903 --- /dev/null +++ b/Dockerfile.pybootchartgui @@ -0,0 +1,12 @@ +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", "--format", "svg"] +#, "--no-prune"] diff --git a/Makefile b/Makefile index 1cc2974..53dbe1a 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 ?= @@ -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) $^ > $@ @@ -136,3 +136,9 @@ test: pybootchartgui/tests echo "Testing $$f...";\ $(PYTHON) "$$f";\ done + +docker-init: all + docker build -t svendowideit/bootchart:init -f Dockerfile.init . + +docker-py: all + docker build -t svendowideit/bootchart:pybootchartgui -f Dockerfile.pybootchartgui . 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}" 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 { 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/main.py.in b/pybootchartgui/main.py.in index e809198..0e8f2b8 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: diff --git a/pybootchartgui/parsing.py b/pybootchartgui/parsing.py index 993d7bf..4401ea0 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 @@ -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 @@ -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