// Inspect gathers information for a crashed process identfied by pid, recording the signal that caused the crash. // // Returns an error if either gathering system info or process-specific info fails. func (self CrashInspector) Inspect(pid int, signal os.Signal) (*CrashReport, error) { si := SystemInspector{debian.NewSystem()} sr, err := si.Inspect() if err != nil { return nil, errors.New(fmt.Sprintf("Failed to gather system information [%s]\n", err)) } pi := ProcessInspector{debian.NewSystem()} pr, err := pi.Inspect(pid) if err != nil { return nil, errors.New(fmt.Sprintf("Failed to gather process information [%s]\n", err)) } return &CrashReport{signal, &sr, pr}, nil }
func actionSystem(context *cli.Context) { si := csi.SystemInspector{debian.NewSystem()} sysInfo, _ := si.Inspect() if b, err := json.MarshalIndent(sysInfo, "", " "); err != nil { fmt.Fprintf(context.App.Writer, "Failed to query system information") } else { fmt.Fprintf(context.App.Writer, "%s\n", b) } }
func actionProcess(context *cli.Context) { pid := os.Getpid() if p := context.String(processFlagPid.Name); len(p) > 0 { pid, _ = strconv.Atoi(p) } pi := csi.ProcessInspector{debian.NewSystem()} processInfo, _ := pi.Inspect(pid) if b, err := yaml.Marshal(processInfo); err != nil { fmt.Fprintf(context.App.Writer, "Failed to query process information") } else { fmt.Fprintf(context.App.Writer, "%s\n", b) } }