From 0fe78be906fd7d84c93ea452b88b7e387265b7cb Mon Sep 17 00:00:00 2001 From: lufia Date: Thu, 21 Jul 2022 17:37:59 +0900 Subject: [PATCH 1/4] [check-disk] shows device names in error messages --- check-disk/lib/check-disk.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/check-disk/lib/check-disk.go b/check-disk/lib/check-disk.go index 981b1636..bcaeb80a 100644 --- a/check-disk/lib/check-disk.go +++ b/check-disk/lib/check-disk.go @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { From 50f77713c77d73d85db640ee352d734d8a9a042a Mon Sep 17 00:00:00 2001 From: lufia Date: Thu, 21 Jul 2022 17:40:12 +0900 Subject: [PATCH 2/4] [check-disk] ignores fuse.portal partitions --- check-disk/lib/check-disk.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check-disk/lib/check-disk.go b/check-disk/lib/check-disk.go index bcaeb80a..cacd51f8 100644 --- a/check-disk/lib/check-disk.go +++ b/check-disk/lib/check-disk.go @@ -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 { @@ -265,6 +265,7 @@ func listPartitions() ([]gpud.PartitionStat, error) { "debugfs", "devpts", "fusectl", + "fuse.portal", "mqueue", "rpc_pipefs", "sysfs", From 1417255cb4cb2c682658653ed877e96bd2cbc261 Mon Sep 17 00:00:00 2001 From: lufia Date: Thu, 21 Jul 2022 17:41:35 +0900 Subject: [PATCH 3/4] [check-disk] update README.md --- check-disk/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/check-disk/README.md b/check-disk/README.md index 8d1d17ba..600559c9 100644 --- a/check-disk/README.md +++ b/check-disk/README.md @@ -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 ``` 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). From e809f2975416c2240fcd329ec77dffd19aa532d1 Mon Sep 17 00:00:00 2001 From: lufia Date: Thu, 21 Jul 2022 18:55:06 +0900 Subject: [PATCH 4/4] [check-disk] add -X tracefs option in test.sh --- check-disk/test.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/check-disk/test.sh b/check-disk/test.sh index 2f67787a..58b73d1c 100755 --- a/check-disk/test.sh +++ b/check-disk/test.sh @@ -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