Change default GpfsCollector command to mmpmon (#53)

* Set default cmd to 'mmpmon'

* Reuse looked up path

* Cast const to string
This commit is contained in:
Thomas Gruber 2022-03-05 14:42:04 +01:00 committed by GitHub
parent 8c668fcc6f
commit 21864e0ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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`