[check-disk] refactor
@@ -65,7 +65,10 @@ func checkDisk(current checkers.Status, threshold string, units float64, disk *g
}
func checkInodes(current checkers.Status, threshold string, disk *gpud.UsageStat, status checkers.Status) (checkers.Status, error) {
- if strings.HasSuffix(threshold, "%") {
+ if !strings.HasSuffix(threshold, "%") {
+ return checkers.UNKNOWN, errors.New("-W, -K value should be N%")
+ }
+
thresholdPct, err := strconv.ParseFloat(strings.TrimRight(threshold, "%"), 64)
if err != nil {
return checkers.UNKNOWN, err
@@ -82,9 +85,6 @@ func checkInodes(current checkers.Status, threshold string, disk *gpud.UsageStat
}
return current, nil
- } else {
- return checkers.UNKNOWN, errors.New("-W, -K value should be N%")
- }
}
func genMessage(disk *gpud.UsageStat, u unit) string {
