Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions collector/pkg/detect/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package detect

import (
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
"strings"

"github.com/analogj/scrutiny/collector/pkg/common/shell"
Expand Down Expand Up @@ -62,6 +64,17 @@ func (d *Detect) SmartCtlInfo(device *models.Device) error {
args = append(args, fullDeviceName)

availableDeviceInfoJson, err := d.Shell.Command(d.Logger, d.Config.GetString("commands.metrics_smartctl_bin"), args, "", os.Environ())
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
exitCode := exitErr.ExitCode()
if exitCode&0xBF == 0 {
d.Logger.Warnf("Successfully retrieved device information for %s, but received exit code %d, which is a non-fatal exit code. Continuing.", device.DeviceName, exitCode)
} else {
d.Logger.Errorf("Could not retrieve device information for %s: %v", device.DeviceName, err)
return err
}
}

if err != nil {
d.Logger.Errorf("Could not retrieve device information for %s: %v", device.DeviceName, err)
return err
Expand Down