mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 04:27:25 +01:00
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:
parent
8c668fcc6f
commit
21864e0ac4
@ -17,6 +17,8 @@ import (
|
|||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const DEFAULT_GPFS_CMD = `mmpmon`
|
||||||
|
|
||||||
type GpfsCollector struct {
|
type GpfsCollector struct {
|
||||||
metricCollector
|
metricCollector
|
||||||
tags map[string]string
|
tags map[string]string
|
||||||
@ -38,7 +40,7 @@ func (m *GpfsCollector) Init(config json.RawMessage) error {
|
|||||||
m.setup()
|
m.setup()
|
||||||
|
|
||||||
// Set default mmpmon binary
|
// Set default mmpmon binary
|
||||||
m.config.Mmpmon = "/usr/lpp/mmfs/bin/mmpmon"
|
m.config.Mmpmon = string(DEFAULT_GPFS_CMD)
|
||||||
|
|
||||||
// Read JSON configuration
|
// Read JSON configuration
|
||||||
if len(config) > 0 {
|
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
|
// GPFS / IBM Spectrum Scale file system statistics can only be queried by user root
|
||||||
user, err := user.Current()
|
user, err := user.Current()
|
||||||
if err != nil {
|
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" {
|
if user.Uid != "0" {
|
||||||
return fmt.Errorf("GPFS file system statistics can only be queried by user root")
|
return fmt.Errorf("GPFS file system statistics can only be queried by user root")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if mmpmon is in executable search path
|
// Check if mmpmon is in executable search path
|
||||||
_, err = exec.LookPath(m.config.Mmpmon)
|
p, err := exec.LookPath(m.config.Mmpmon)
|
||||||
if err != nil {
|
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
|
m.init = true
|
||||||
return nil
|
return nil
|
||||||
|
@ -16,7 +16,7 @@ The reported filesystems can be filtered with the `exclude_filesystem` option
|
|||||||
in the configuration.
|
in the configuration.
|
||||||
|
|
||||||
The path to the `mmpmon` command can be configured with the `mmpmon_path` option
|
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:
|
Metrics:
|
||||||
* `bytes_read`
|
* `bytes_read`
|
||||||
|
Loading…
Reference in New Issue
Block a user