Skip to content

Commit 9c41f35

Browse files
author
Todd Campbell
committed
Add error checking
Signed-off-by: Todd Campbell <[email protected]>
1 parent ce68896 commit 9c41f35

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
99

10+
## [0.1.1] - 2020-12-29
11+
12+
### Change
13+
- Added appropriate error checking
14+
1015
## [0.1.0] - 2020-12-14
1116

1217
### Added

main.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import (
99
"github.com/shirou/gopsutil/disk"
1010
)
1111

12-
// TODO
13-
// 1. Magic factor for larger file systems
14-
// 2. Metrics output (--metrics, --metrics-only)
15-
// 3. inodes?
16-
1712
// Config represents the check plugin config.
1813
type Config struct {
1914
sensu.PluginConfig
@@ -116,11 +111,17 @@ func executeCheck(event *types.Event) (int, error) {
116111
warnings int
117112
)
118113

119-
parts, _ := disk.Partitions(true)
114+
parts, err := disk.Partitions(true)
115+
if err != nil {
116+
return sensu.CheckStateCritical, fmt.Errorf("Failed to get partions, error: %v", err)
117+
}
120118

121119
for _, p := range parts {
122120
device := p.Mountpoint
123-
s, _ := disk.Usage(device)
121+
s, err := disk.Usage(device)
122+
if err != nil {
123+
return sensu.CheckStateCritical, fmt.Errorf("Failed to get disk usage for %s, error: %v", device, err)
124+
}
124125

125126
// Ignore empty file systems
126127
if s.Total == 0 {

0 commit comments

Comments
 (0)