2023-04-10 18:30:40 +08:00
|
|
|
package main
|
|
|
|
|
|
2023-05-22 18:52:59 +08:00
|
|
|
//#cgo CXXFLAGS: -std=c++11
|
|
|
|
|
// #cgo CFLAGS: -I .
|
|
|
|
|
// #cgo LDFLAGS: /opt/tsg/coredump/bin/coredump_handler_wrapper.so
|
|
|
|
|
//#include "coredump_handler_wrapper.h"
|
|
|
|
|
import "C"
|
|
|
|
|
|
2023-04-10 18:30:40 +08:00
|
|
|
import (
|
2023-04-11 11:27:04 +08:00
|
|
|
"archive/zip"
|
2023-04-10 18:30:40 +08:00
|
|
|
"context"
|
2023-05-04 18:29:05 +08:00
|
|
|
"coredump-tools/config"
|
|
|
|
|
"coredump-tools/types"
|
2023-04-14 15:31:59 +08:00
|
|
|
"encoding/json"
|
2023-04-10 18:30:40 +08:00
|
|
|
"errors"
|
2023-04-14 15:31:59 +08:00
|
|
|
"flag"
|
2023-04-10 18:30:40 +08:00
|
|
|
"fmt"
|
|
|
|
|
"io"
|
2023-05-10 19:36:15 +08:00
|
|
|
"math"
|
2023-04-10 18:30:40 +08:00
|
|
|
"os"
|
|
|
|
|
"regexp"
|
|
|
|
|
"strconv"
|
2023-04-14 15:31:59 +08:00
|
|
|
"strings"
|
2023-04-10 18:30:40 +08:00
|
|
|
|
|
|
|
|
"github.com/containerd/containerd"
|
|
|
|
|
"github.com/containerd/containerd/namespaces"
|
2023-04-12 16:13:21 +08:00
|
|
|
"github.com/coreos/go-systemd/v22/journal"
|
2023-05-10 19:36:15 +08:00
|
|
|
"github.com/shirou/gopsutil/disk"
|
2023-04-10 18:30:40 +08:00
|
|
|
)
|
|
|
|
|
|
2023-04-14 15:31:59 +08:00
|
|
|
var coredump_config types.Coredump_config
|
2023-04-11 11:27:04 +08:00
|
|
|
|
2023-04-14 15:31:59 +08:00
|
|
|
func argsJudge() error {
|
2023-05-10 19:36:15 +08:00
|
|
|
|
|
|
|
|
if coredump_config.Initial_ns_pid == "" ||
|
|
|
|
|
coredump_config.Process_ns_pid == "" ||
|
|
|
|
|
coredump_config.Corepipe_config_path == "" ||
|
|
|
|
|
coredump_config.Timestamp == 0 ||
|
|
|
|
|
coredump_config.Process_exe_path == "" ||
|
|
|
|
|
coredump_config.GID == "" ||
|
|
|
|
|
coredump_config.Hostname == "" ||
|
|
|
|
|
coredump_config.UID == "" ||
|
|
|
|
|
coredump_config.Signal == -1 {
|
|
|
|
|
err := fmt.Sprintf("Failed to initialize command line parameters. -P=%s -p=%s -E=%s -configpath=%s -t=%d -g=%s -h=%s -s=%d -u=%s",
|
|
|
|
|
coredump_config.Initial_ns_pid,
|
|
|
|
|
coredump_config.Process_ns_pid,
|
|
|
|
|
coredump_config.Process_exe_path,
|
|
|
|
|
coredump_config.Corepipe_config_path,
|
|
|
|
|
coredump_config.Timestamp,
|
|
|
|
|
coredump_config.GID,
|
|
|
|
|
coredump_config.Hostname,
|
|
|
|
|
coredump_config.Signal,
|
|
|
|
|
coredump_config.UID)
|
2023-04-14 15:31:59 +08:00
|
|
|
return errors.New(err)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-05-10 19:36:15 +08:00
|
|
|
|
2023-05-15 09:59:41 +08:00
|
|
|
// judge disk's space is sufficient or not
|
2023-04-14 15:31:59 +08:00
|
|
|
func isDiskSufficient(pipe_config types.Pipeconfig) (bool, error) {
|
2023-05-10 19:36:15 +08:00
|
|
|
percent, err := strconv.ParseInt(pipe_config.Total_file_mem_limit[:len(pipe_config.Total_file_mem_limit)-1], 10, 32)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
2023-05-10 19:36:15 +08:00
|
|
|
wd := pipe_config.Storage
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
2023-05-10 19:36:15 +08:00
|
|
|
diskinfo, err := disk.Usage(wd)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
data, err := json.MarshalIndent(diskinfo, "", " ")
|
|
|
|
|
if err != nil {
|
|
|
|
|
info := fmt.Sprintf("diskinfo:%s", string(data))
|
|
|
|
|
journal.Print(journal.PriInfo, info)
|
|
|
|
|
}
|
|
|
|
|
usage := int64(math.Floor(diskinfo.UsedPercent + 0.5))
|
|
|
|
|
info := fmt.Sprintf("usage:%d,limited:%d", usage, percent)
|
|
|
|
|
journal.Print(journal.PriInfo, info)
|
2023-04-11 11:27:04 +08:00
|
|
|
if usage >= percent {
|
2023-04-10 18:30:40 +08:00
|
|
|
return false, nil
|
|
|
|
|
}
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
2023-05-10 19:36:15 +08:00
|
|
|
|
2023-05-15 09:59:41 +08:00
|
|
|
// create dir to storage coredump file and coredump info
|
2023-04-14 15:31:59 +08:00
|
|
|
func createCoreDumpDir(pipe_config *types.Pipeconfig, args types.Coredump_config) error {
|
2023-05-10 19:36:15 +08:00
|
|
|
pipe_config.Storage = fmt.Sprintf("%s/coredump_%s_%s_%d", pipe_config.Storage, args.Initial_ns_pid, args.Process_ns_pid, args.Timestamp)
|
2023-04-27 17:20:57 +08:00
|
|
|
dirName := pipe_config.Storage
|
2023-04-10 18:30:40 +08:00
|
|
|
if _, err := os.Stat(dirName); os.IsNotExist(err) {
|
|
|
|
|
if err := os.MkdirAll(dirName, os.ModePerm); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return errors.New("directory already exists")
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
|
|
|
|
|
// chmod to storage dir
|
2023-04-11 16:47:19 +08:00
|
|
|
func changeDirectory(dir string) error {
|
2023-04-10 18:30:40 +08:00
|
|
|
if err := os.Chdir(dir); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
|
|
|
|
|
// get container id by search /proc dir
|
2023-04-10 18:30:40 +08:00
|
|
|
func getContainerId(pid string) (string, error) {
|
|
|
|
|
cgroup_path := fmt.Sprintf("/proc/%s/cgroup", pid)
|
2023-04-23 18:24:42 +08:00
|
|
|
content, err := os.ReadFile(cgroup_path)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
re := regexp.MustCompile(`([a-f\d]{64})`)
|
|
|
|
|
match := re.FindStringSubmatch(string(content))
|
|
|
|
|
if len(match) < 2 {
|
|
|
|
|
return "", errors.New("failed to extract container ID from cgroup file")
|
|
|
|
|
}
|
|
|
|
|
containerID := match[1]
|
|
|
|
|
return containerID, nil
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
|
|
|
|
|
// get image name by container id
|
2023-05-04 18:29:05 +08:00
|
|
|
func getImageName(container_id string, sock_path string) (string, error) {
|
2023-05-15 09:59:41 +08:00
|
|
|
// connect to containerd daemon
|
2023-04-10 18:30:40 +08:00
|
|
|
client, err := containerd.New(sock_path)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
defer client.Close()
|
2023-05-15 09:59:41 +08:00
|
|
|
// according to container id to get container info
|
2023-04-10 18:30:40 +08:00
|
|
|
ctx := namespaces.WithNamespace(context.Background(), "k8s.io")
|
|
|
|
|
container, err := client.LoadContainer(ctx, container_id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
imageRef, err := container.Image(ctx)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
return imageRef.Name(), nil
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
|
|
|
|
|
// write coredump info to file
|
2023-04-14 15:31:59 +08:00
|
|
|
func writeCoreConfig(config types.Coredump_config) error {
|
2023-05-10 19:36:15 +08:00
|
|
|
filename := fmt.Sprintf("%s_%s_%d.info", config.Initial_ns_pid, config.Process_ns_pid, config.Timestamp)
|
2023-04-14 16:50:48 +08:00
|
|
|
file, err := os.Create(filename)
|
2023-04-14 15:31:59 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
encoder := json.NewEncoder(file)
|
|
|
|
|
err = encoder.Encode(&config)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
|
|
|
|
|
// write coredump to file
|
2023-04-14 16:50:48 +08:00
|
|
|
func writeCoreDumpToFile(config types.Coredump_config) error {
|
2023-05-10 19:36:15 +08:00
|
|
|
filename := fmt.Sprintf("%s_%s_%d.coredump", config.Initial_ns_pid, config.Process_ns_pid, config.Timestamp)
|
2023-04-14 16:50:48 +08:00
|
|
|
file, err := os.Create(filename)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
defer file.Close()
|
2023-05-19 18:12:17 +08:00
|
|
|
buf := make([]byte, 1024*1024)
|
|
|
|
|
for {
|
2023-05-22 18:52:59 +08:00
|
|
|
n, err := os.Stdin.Read(buf)
|
|
|
|
|
if err != nil && err != io.EOF {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if n == 0 {
|
2023-05-19 18:12:17 +08:00
|
|
|
break
|
|
|
|
|
}
|
2023-05-22 18:52:59 +08:00
|
|
|
_, err = file.Write(buf[:n])
|
2023-05-19 18:12:17 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-10 18:30:40 +08:00
|
|
|
return nil
|
|
|
|
|
}
|
2023-05-22 18:52:59 +08:00
|
|
|
func HandleCrash(pid int, procfsDir string, mdFilename string) bool {
|
|
|
|
|
journal.Print(journal.PriInfo, "start convert to minidump")
|
|
|
|
|
return bool(C.HandleCrash(C.pid_t(pid), C.CString(procfsDir), C.CString(mdFilename)))
|
|
|
|
|
}
|
2023-05-09 17:36:04 +08:00
|
|
|
func writeMiniDumpToFile(config types.Coredump_config) error {
|
2023-05-17 18:26:24 +08:00
|
|
|
filename := fmt.Sprintf("%s/%s_%s_%d.minidump", config.Storage, config.Initial_ns_pid, config.Process_ns_pid, config.Timestamp)
|
2023-05-22 18:52:59 +08:00
|
|
|
pid, err := strconv.Atoi(config.Initial_ns_pid)
|
2023-05-09 17:36:04 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2023-05-22 18:52:59 +08:00
|
|
|
flag := HandleCrash(pid, "/proc/"+config.Initial_ns_pid, filename)
|
|
|
|
|
if !flag {
|
|
|
|
|
return errors.New("can not convert to minidump")
|
|
|
|
|
}
|
|
|
|
|
journal.Print(journal.PriInfo, "end convert to minidump")
|
|
|
|
|
// cmd := exec.Command("/opt/tsg/coredump/bin/core_handler", config.Initial_ns_pid, filename)
|
|
|
|
|
// cmd.Stdin = os.Stdin
|
|
|
|
|
// output, err := cmd.Output()
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// return err
|
|
|
|
|
// }
|
|
|
|
|
// fmt.Println(string(output))
|
2023-05-09 17:36:04 +08:00
|
|
|
return nil
|
|
|
|
|
}
|
2023-04-14 16:50:48 +08:00
|
|
|
func compress(config types.Coredump_config) error {
|
2023-04-11 11:27:04 +08:00
|
|
|
// Create a new zip archive.
|
2023-05-10 19:36:15 +08:00
|
|
|
filename := fmt.Sprintf("%s_%s_%d.coredump", config.Initial_ns_pid, config.Process_ns_pid, config.Timestamp)
|
2023-04-14 16:50:48 +08:00
|
|
|
zipfile, err := os.Create(filename + ".zip")
|
2023-04-11 11:27:04 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
defer zipfile.Close()
|
|
|
|
|
|
|
|
|
|
// Create a new zip writer.
|
|
|
|
|
zipwriter := zip.NewWriter(zipfile)
|
|
|
|
|
defer zipwriter.Close()
|
|
|
|
|
|
|
|
|
|
// Create a zip file header.
|
|
|
|
|
header := &zip.FileHeader{
|
2023-04-14 16:50:48 +08:00
|
|
|
Name: filename,
|
2023-04-11 11:27:04 +08:00
|
|
|
Method: zip.Deflate,
|
|
|
|
|
}
|
2023-05-19 18:12:17 +08:00
|
|
|
|
2023-04-11 11:27:04 +08:00
|
|
|
// Write the header to the zip file.
|
|
|
|
|
writer, err := zipwriter.CreateHeader(header)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2023-05-19 18:12:17 +08:00
|
|
|
|
|
|
|
|
// Set the block size to 1 megabyte.
|
|
|
|
|
const blockSize = 1024 * 1024
|
|
|
|
|
|
|
|
|
|
// Read and write the input in blocks.
|
|
|
|
|
buf := make([]byte, blockSize)
|
|
|
|
|
for {
|
|
|
|
|
n, err := os.Stdin.Read(buf)
|
|
|
|
|
if err != nil && err != io.EOF {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
if n == 0 {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
_, err = writer.Write(buf[:n])
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-11 11:27:04 +08:00
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-04-10 18:30:40 +08:00
|
|
|
func main() {
|
2023-04-23 18:24:42 +08:00
|
|
|
info := fmt.Sprintf("start handle coredump")
|
|
|
|
|
journal.Print(journal.PriInfo, info)
|
2023-04-14 15:31:59 +08:00
|
|
|
flag.StringVar(&coredump_config.Initial_ns_pid, "P", "", "initial ns pid")
|
|
|
|
|
flag.StringVar(&coredump_config.Process_ns_pid, "p", "", "process ns pid")
|
|
|
|
|
flag.StringVar(&coredump_config.Process_exe_path, "E", "", "pathname of executable process")
|
2023-04-28 17:21:02 +08:00
|
|
|
flag.StringVar(&coredump_config.Corepipe_config_path, "C", "", "configfile's path")
|
2023-05-17 18:26:24 +08:00
|
|
|
flag.Int64Var(&coredump_config.Timestamp, "t", 0, "the time of `coredump")
|
2023-04-18 15:27:42 +08:00
|
|
|
flag.StringVar(&coredump_config.GID, "g", "", "Numeric real GID of dumped process.")
|
|
|
|
|
flag.IntVar(&coredump_config.Signal, "s", -1, "Number of signal causing dump")
|
|
|
|
|
flag.StringVar(&coredump_config.UID, "u", "", "Numeric real UID of dumped process.")
|
2023-04-14 15:31:59 +08:00
|
|
|
flag.Parse()
|
2023-04-23 18:24:42 +08:00
|
|
|
var err error
|
|
|
|
|
coredump_config.Hostname, err = os.Hostname()
|
|
|
|
|
if err != nil {
|
|
|
|
|
journal.Print(journal.PriErr, err.Error())
|
|
|
|
|
}
|
2023-04-28 17:21:02 +08:00
|
|
|
info = fmt.Sprintf("initialize command line parameters. -P=%s -p=%s -E=%s -C=%s -t=%d -g=%s -h=%s -s=%d -u=%s", coredump_config.Initial_ns_pid, coredump_config.Process_ns_pid, coredump_config.Process_exe_path, coredump_config.Corepipe_config_path, coredump_config.Timestamp, coredump_config.GID, coredump_config.Hostname, coredump_config.Signal, coredump_config.UID)
|
2023-04-14 19:18:47 +08:00
|
|
|
journal.Print(journal.PriInfo, info)
|
2023-04-14 15:31:59 +08:00
|
|
|
coredump_config.Process_exe_path = strings.Replace(coredump_config.Process_exe_path, "!", "/", -1)
|
2023-05-15 09:59:41 +08:00
|
|
|
//Judge agrs is correct or not.
|
2023-04-23 18:24:42 +08:00
|
|
|
err = argsJudge()
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
2023-04-12 16:13:21 +08:00
|
|
|
journal.Print(journal.PriErr, err.Error())
|
2023-04-10 18:30:40 +08:00
|
|
|
return
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
//read config file and judge config info is correct or not.
|
2023-04-14 15:31:59 +08:00
|
|
|
pipe_config, err := config.PipeInit(coredump_config.Corepipe_config_path)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
2023-04-12 16:13:21 +08:00
|
|
|
journal.Print(journal.PriErr, err.Error())
|
2023-04-10 18:30:40 +08:00
|
|
|
return
|
|
|
|
|
}
|
2023-04-28 17:21:02 +08:00
|
|
|
if pipe_config.Storage_type == 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
//create source dir
|
2023-05-10 19:36:15 +08:00
|
|
|
if _, err := os.Stat(pipe_config.Storage); os.IsNotExist(err) {
|
|
|
|
|
if err := os.MkdirAll(pipe_config.Storage, os.ModePerm); err != nil {
|
|
|
|
|
journal.Print(journal.PriErr, err.Error())
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
//judge disk usage
|
2023-04-12 17:52:13 +08:00
|
|
|
flag, err := isDiskSufficient(pipe_config)
|
2023-05-09 17:36:04 +08:00
|
|
|
if err != nil {
|
2023-04-12 16:13:21 +08:00
|
|
|
journal.Print(journal.PriErr, err.Error())
|
2023-04-10 18:30:40 +08:00
|
|
|
return
|
|
|
|
|
}
|
2023-05-09 17:36:04 +08:00
|
|
|
if !flag {
|
|
|
|
|
journal.Print(journal.PriErr, "Disk space exceeds limit")
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
//create dir to storage coredump
|
2023-04-14 15:31:59 +08:00
|
|
|
err = createCoreDumpDir(&pipe_config, coredump_config)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
2023-04-12 16:13:21 +08:00
|
|
|
journal.Print(journal.PriErr, err.Error())
|
2023-04-10 18:30:40 +08:00
|
|
|
return
|
|
|
|
|
}
|
2023-04-27 17:20:57 +08:00
|
|
|
coredump_config.Storage = pipe_config.Storage
|
2023-05-15 09:59:41 +08:00
|
|
|
//chmod to coredump dir
|
2023-04-27 17:20:57 +08:00
|
|
|
err = changeDirectory(pipe_config.Storage)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
2023-04-12 16:13:21 +08:00
|
|
|
journal.Print(journal.PriErr, err.Error())
|
2023-04-10 18:30:40 +08:00
|
|
|
return
|
|
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
//find coredump process's container id
|
2023-04-14 15:31:59 +08:00
|
|
|
container_id, err := getContainerId(coredump_config.Initial_ns_pid)
|
2023-05-15 09:59:41 +08:00
|
|
|
//find image name
|
2023-04-10 18:30:40 +08:00
|
|
|
if err == nil && len(container_id) != 0 {
|
2023-05-12 17:58:39 +08:00
|
|
|
coredump_config.Container_id = container_id
|
2023-05-04 18:29:05 +08:00
|
|
|
coredump_config.Image_name, err = getImageName(container_id, pipe_config.Containered_sock_path)
|
2023-04-10 18:30:40 +08:00
|
|
|
if err != nil {
|
2023-04-12 16:13:21 +08:00
|
|
|
journal.Print(journal.PriInfo, err.Error())
|
2023-04-10 18:30:40 +08:00
|
|
|
}
|
|
|
|
|
}
|
2023-05-12 17:58:39 +08:00
|
|
|
if coredump_config.Container_id == "" {
|
|
|
|
|
coredump_config.Container_id = "NULL"
|
|
|
|
|
}
|
2023-05-04 18:29:05 +08:00
|
|
|
if coredump_config.Image_name == "" {
|
|
|
|
|
coredump_config.Image_name = "NULL"
|
2023-04-27 17:20:57 +08:00
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
//write coredump file
|
2023-05-17 18:26:24 +08:00
|
|
|
if !pipe_config.Compress {
|
|
|
|
|
if pipe_config.Storage_type == 1 {
|
|
|
|
|
err = writeCoreDumpToFile(coredump_config)
|
|
|
|
|
if err != nil {
|
|
|
|
|
journal.Print(journal.PriErr, err.Error())
|
|
|
|
|
}
|
|
|
|
|
coredump_config.Storage = fmt.Sprintf("%s/%s_%s_%d.coredump", pipe_config.Storage, coredump_config.Initial_ns_pid, coredump_config.Process_ns_pid, coredump_config.Timestamp)
|
|
|
|
|
} else if pipe_config.Storage_type == 2 {
|
|
|
|
|
err = writeMiniDumpToFile(coredump_config)
|
|
|
|
|
if err != nil {
|
|
|
|
|
journal.Print(journal.PriErr, err.Error())
|
|
|
|
|
}
|
|
|
|
|
coredump_config.Storage = fmt.Sprintf("%s/%s_%s_%d.minidump", pipe_config.Storage, coredump_config.Initial_ns_pid, coredump_config.Process_ns_pid, coredump_config.Timestamp)
|
2023-04-11 11:27:04 +08:00
|
|
|
}
|
2023-05-10 19:36:15 +08:00
|
|
|
} else {
|
2023-04-14 16:50:48 +08:00
|
|
|
err = compress(coredump_config)
|
2023-04-11 11:27:04 +08:00
|
|
|
if err != nil {
|
2023-04-12 16:13:21 +08:00
|
|
|
journal.Print(journal.PriErr, err.Error())
|
2023-04-11 11:27:04 +08:00
|
|
|
}
|
2023-05-10 19:36:15 +08:00
|
|
|
coredump_config.Storage = fmt.Sprintf("%s/%s_%s_%d.coredump.zip", pipe_config.Storage, coredump_config.Initial_ns_pid, coredump_config.Process_ns_pid, coredump_config.Timestamp)
|
2023-04-23 18:24:42 +08:00
|
|
|
}
|
2023-05-15 09:59:41 +08:00
|
|
|
//write coredump info
|
2023-04-23 18:24:42 +08:00
|
|
|
err = writeCoreConfig(coredump_config)
|
|
|
|
|
if err != nil {
|
|
|
|
|
journal.Print(journal.PriInfo, err.Error())
|
2023-04-10 18:30:40 +08:00
|
|
|
}
|
|
|
|
|
}
|