From 4271e7eaebf811395e4ef2d018d86570580312ea Mon Sep 17 00:00:00 2001 From: linxin Date: Fri, 5 May 2023 10:47:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9rpm=E6=89=93=E5=8C=85?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96sysctl=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 60-coredump.conf | 23 +++++++++++++++++++++++ coredump.go | 2 +- script/coredump.spec | 7 +++++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 60-coredump.conf diff --git a/60-coredump.conf b/60-coredump.conf new file mode 100644 index 0000000..96abce4 --- /dev/null +++ b/60-coredump.conf @@ -0,0 +1,23 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +# See sysctl.d(5) for the description of the files in this directory, +# and systemd-coredump(8) and core(5) for the explanation of the +# setting below. + +kernel.core_pattern=|/opt/tsg/coredump/bin/coredump-handler -P %P -E %E -t %t -p %p -g %g -s %s -u %u -C /opt/tsg/coredump/etc/config.json + +# Allow that 16 coredumps are dispatched in parallel by the kernel. We want to +# be able to collect process metadata from /proc/%P/ while processing +# coredumps, and thus need to make sure the crashed processes are not reaped +# until we finished collecting what we need. The kernel default for this sysctl +# is "0" which means the kernel doesn't wait for userspace processes to finish +# processing before reaping the crashed processes — by setting this higher the +# kernel will delay reaping until we are done, but only for the specified +# number of crashes in parallel. The value of 16 is chosen to match +# systemd-coredump.socket's MaxConnections= value. +kernel.core_pipe_limit=16 diff --git a/coredump.go b/coredump.go index fbbcac5..ac6edaa 100644 --- a/coredump.go +++ b/coredump.go @@ -1,7 +1,7 @@ package main import ( - "coredump-handler/types" + "coredump-tools/types" "fmt" "net" "os/exec" diff --git a/script/coredump.spec b/script/coredump.spec index 8031532..294944e 100644 --- a/script/coredump.spec +++ b/script/coredump.spec @@ -21,7 +21,7 @@ This package contains the binary executable for coredump-handler and coredump-to cd ./coredump-handler go build -o coredump-handler . cd .. -cd ./coredump-ctl +cd ./coredump-tool go build -o coredump-tool . cd .. %install @@ -30,11 +30,13 @@ mkdir -p %{buildroot}/opt/tsg/coredump/bin mkdir -p %{buildroot}/opt/tsg/coredump/etc mkdir -p %{buildroot}/etc/profile.d mkdir -p %{buildroot}/usr/lib/tmpfiles.d +mkdir -p %{buildroot}/usr/lib/sysctl.d cp ./coredump-handler/coredump-handler %{buildroot}/opt/tsg/coredump/bin cp ./config/config.json %{buildroot}/opt/tsg/coredump/etc -cp ./coredump-ctl/coredump-tool %{buildroot}/opt/tsg/coredump/bin +cp ./coredump-tool/coredump-tool %{buildroot}/opt/tsg/coredump/bin cp ./script/coredump-tools.sh %{buildroot}/etc/profile.d cp ./coredump.conf %{buildroot}/usr/lib/tmpfiles.d +cp ./60-coredump.conf %{buildroot}/usr/lib/sysctl.d %files %defattr (-,root,root) /opt/tsg/coredump/etc/config.json @@ -42,3 +44,4 @@ cp ./coredump.conf %{buildroot}/usr/lib/tmpfiles.d /opt/tsg/coredump/bin/coredump-tool /etc/profile.d/coredump-tools.sh /usr/lib/tmpfiles.d/coredump.conf +/usr/lib/sysctl.d/60-coredump.conf