From 21864e0ac4a790e4f9ab1a3af9e9ad01a661e751 Mon Sep 17 00:00:00 2001 From: Thomas Gruber Date: Sat, 5 Mar 2022 14:42:04 +0100 Subject: [PATCH] Change default GpfsCollector command to `mmpmon` (#53) * Set default cmd to 'mmpmon' * Reuse looked up path * Cast const to string --- collectors/gpfsMetric.go | 11 +++++++---- collectors/gpfsMetric.md | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/collectors/gpfsMetric.go b/collectors/gpfsMetric.go index adbc7fb..453704c 100644 --- a/collectors/gpfsMetric.go +++ b/collectors/gpfsMetric.go @@ -17,6 +17,8 @@ import ( lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric" ) +const DEFAULT_GPFS_CMD = `mmpmon` + type GpfsCollector struct { metricCollector tags map[string]string @@ -38,7 +40,7 @@ func (m *GpfsCollector) Init(config json.RawMessage) error { m.setup() // Set default mmpmon binary - m.config.Mmpmon = "/usr/lpp/mmfs/bin/mmpmon" + m.config.Mmpmon = string(DEFAULT_GPFS_CMD) // Read JSON configuration if len(config) > 0 { @@ -64,17 +66,18 @@ func (m *GpfsCollector) Init(config json.RawMessage) error { // GPFS / IBM Spectrum Scale file system statistics can only be queried by user root user, err := user.Current() if err != nil { - return fmt.Errorf("Failed to get current user: %v", err) + return fmt.Errorf("failed to get current user: %v", err) } if user.Uid != "0" { return fmt.Errorf("GPFS file system statistics can only be queried by user root") } // Check if mmpmon is in executable search path - _, err = exec.LookPath(m.config.Mmpmon) + p, err := exec.LookPath(m.config.Mmpmon) if err != nil { - return fmt.Errorf("Failed to find mmpmon binary '%s': %v", m.config.Mmpmon, err) + return fmt.Errorf("failed to find mmpmon binary '%s': %v", m.config.Mmpmon, err) } + m.config.Mmpmon = p m.init = true return nil diff --git a/collectors/gpfsMetric.md b/collectors/gpfsMetric.md index 4a6a058..4f2c897 100644 --- a/collectors/gpfsMetric.md +++ b/collectors/gpfsMetric.md @@ -16,7 +16,7 @@ The reported filesystems can be filtered with the `exclude_filesystem` option in the configuration. The path to the `mmpmon` command can be configured with the `mmpmon_path` option -in the configuration. +in the configuration. If nothing is set, the collector searches in `$PATH` for `mmpmon`. Metrics: * `bytes_read`