Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignores fuse.portal partitions #626

Merged
merged 4 commits into from Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions check-disk/README.md
Expand Up @@ -13,9 +13,7 @@ check-disk --warning=10 --critical=5 --path=/
First, build this program.

```
go get github.com/mackerelio/go-check-plugins
cd $(go env GOPATH)/src/github.com/mackerelio/go-check-plugins/check-disk
go install
go install github.com/mackerelio/go-check-plugins/check-disk@latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

```

Or you can use this program by installing the official Mackerel package. See [Using the official check plugin pack for check monitoring - Mackerel Docs](https://mackerel.io/docs/entry/howto/mackerel-check-plugins).
Expand Down
13 changes: 7 additions & 6 deletions check-disk/lib/check-disk.go
Expand Up @@ -159,7 +159,7 @@ func run(args []string) *checkers.Checker {
for _, partition := range partitions {
disk, err := gpud.Usage(partition.Mountpoint)
if err != nil {
return checkers.Unknown(fmt.Sprintf("Failed to fetch disk usage: %s", err))
return checkers.Unknown(fmt.Sprintf("%s[type=%s]: Failed to fetch disk usage: %s", partition.Mountpoint, partition.Fstype, err))
}

if disk.Total != 0 {
Expand Down Expand Up @@ -188,7 +188,7 @@ func run(args []string) *checkers.Checker {
for _, disk := range disks {
checkSt, err = checkInodes(checkSt, *opts.InodeCritical, disk, checkers.CRITICAL)
if err != nil {
return checkers.Unknown(fmt.Sprintf("Failed to check disk status: %s", err))
return checkers.Unknown(fmt.Sprintf("%s: Failed to check disk status: %s", disk.Path, err))
}

if checkSt == checkers.CRITICAL {
Expand All @@ -201,7 +201,7 @@ func run(args []string) *checkers.Checker {
for _, disk := range disks {
checkSt, err = checkDisk(checkSt, *opts.Critical, u.Size, disk, checkers.CRITICAL)
if err != nil {
return checkers.Unknown(fmt.Sprintf("Failed to check disk status: %s", err))
return checkers.Unknown(fmt.Sprintf("%s: Failed to check disk status: %s", disk.Path, err))
}

if checkSt == checkers.CRITICAL {
Expand All @@ -214,7 +214,7 @@ func run(args []string) *checkers.Checker {
for _, disk := range disks {
checkSt, err = checkInodes(checkSt, *opts.InodeWarning, disk, checkers.WARNING)
if err != nil {
return checkers.Unknown(fmt.Sprintf("Failed to check disk status: %s", err))
return checkers.Unknown(fmt.Sprintf("%s: Failed to check disk status: %s", disk.Path, err))
}

if checkSt == checkers.WARNING {
Expand All @@ -227,7 +227,7 @@ func run(args []string) *checkers.Checker {
for _, disk := range disks {
checkSt, err = checkDisk(checkSt, *opts.Warning, u.Size, disk, checkers.WARNING)
if err != nil {
return checkers.Unknown(fmt.Sprintf("Failed to check disk status: %s", err))
return checkers.Unknown(fmt.Sprintf("%s: Failed to check disk status: %s", disk.Path, err))
}

if checkSt == checkers.WARNING {
Expand All @@ -250,7 +250,7 @@ func run(args []string) *checkers.Checker {
}

// ref: mountlist.c in gnulib
// https://github.com/coreutils/gnulib/blob/a742bdb3/lib/mountlist.c#L168
// https://github.com/coreutils/gnulib/blob/df336dc/lib/mountlist.c#L164
func listPartitions() ([]gpud.PartitionStat, error) {
allPartitions, err := gpud.Partitions(true)
if err != nil {
Expand All @@ -265,6 +265,7 @@ func listPartitions() ([]gpud.PartitionStat, error) {
"debugfs",
"devpts",
"fusectl",
"fuse.portal",
"mqueue",
"rpc_pipefs",
"sysfs",
Expand Down
5 changes: 4 additions & 1 deletion check-disk/test.sh
Expand Up @@ -10,4 +10,7 @@ then
exit 2
fi

exec $plugin
# GitHub-hosted Linux runner mounts tracefs on /sys/kernel/debug/tracing.
# That fstype don't appear in ME_DUMMY macro on coreutils.
# Thus, for now, we ignore it only in test.sh.
exec $plugin -X tracefs