diff --git a/pitr/agent/internal/handler/diskspace.go b/pitr/agent/internal/handler/diskspace.go index 401d523c..b9807f9a 100644 --- a/pitr/agent/internal/handler/diskspace.go +++ b/pitr/agent/internal/handler/diskspace.go @@ -40,6 +40,10 @@ func DiskSpace(ctx *fiber.Ctx) error { return fmt.Errorf("invalid parameter, err wrap: %w", err) } + if err := os.MkdirAll(in.DiskPath, 0755); err != nil { + return fmt.Errorf("mkdir [%s] failure, err wrap: %w", in.DiskPath, err) + } + // show disk space cmd := fmt.Sprintf("df -h %s", in.DiskPath) output, err := cmds.Exec(os.Getenv("SHELL"), cmd) diff --git a/pitr/agent/pkg/cmds/cmd.go b/pitr/agent/pkg/cmds/cmd.go index 77a98f53..e39a3475 100644 --- a/pitr/agent/pkg/cmds/cmd.go +++ b/pitr/agent/pkg/cmds/cmd.go @@ -142,7 +142,7 @@ func Exec(name string, args ...string) (string, error) { if err = cmd.Wait(); err != nil { if ee, ok := err.(*exec.ExitError); ok { - return "", fmt.Errorf("exec failure[ee=%s,stdout=%s], wrap:%w", ee, string(reader), cons.CmdOperateFailed) + return "", fmt.Errorf("exec failure[ee=%s,stdout=%s,stderr=%s], wrap:%w", ee, string(reader), string(ereader), cons.CmdOperateFailed) } return "", fmt.Errorf("%s err: %s", cmd.String(), string(ereader)) }