mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 23:19:06 +01:00
Add LustreCollector
This commit is contained in:
parent
642314c102
commit
e9a74a4c9c
62
collectors/lustreMetric.go
Normal file
62
collectors/lustreMetric.go
Normal file
@ -0,0 +1,62 @@
|
||||
package collectors
|
||||
|
||||
import (
|
||||
// "errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const LUSTREFILE = `/proc/fs/lustre/llite/lnec-XXXXXX/stats`
|
||||
|
||||
type LustreCollector struct {
|
||||
MetricCollector
|
||||
}
|
||||
|
||||
|
||||
func (m *LustreCollector) Init() {
|
||||
m.name = "LustreCollector"
|
||||
m.setup()
|
||||
}
|
||||
|
||||
func (m *LustreCollector) Read(interval time.Duration){
|
||||
buffer, err := ioutil.ReadFile(string(LUSTREFILE))
|
||||
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(string(buffer), "\n") {
|
||||
lf := strings.Fields(line)
|
||||
if len(lf) > 1 {
|
||||
switch lf[0] {
|
||||
case "read_bytes":
|
||||
m.node["read_bytes"], err = strconv.ParseInt(lf[6], 0, 64)
|
||||
m.node["read_requests"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
case "write_bytes":
|
||||
m.node["write_bytes"], err = strconv.ParseInt(lf[6], 0, 64)
|
||||
m.node["write_requests"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
case "open":
|
||||
m.node["open"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
case "close":
|
||||
m.node["close"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
case "setattr":
|
||||
m.node["setattr"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
case "getattr":
|
||||
m.node["getattr"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
case "statfs":
|
||||
m.node["statfs"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
case "inode_permission":
|
||||
m.node["inode_permission"], err = strconv.ParseInt(lf[1], 0, 64)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *LustreCollector) Close() {
|
||||
return
|
||||
}
|
@ -12,7 +12,8 @@
|
||||
"likwid",
|
||||
"loadavg",
|
||||
"netstat",
|
||||
"ibstat"
|
||||
"ibstat",
|
||||
"lustrestat"
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ var Collectors = map[string]collectors.MetricGetter{
|
||||
"memstat": &collectors.MemstatCollector{},
|
||||
"netstat": &collectors.NetstatCollector{},
|
||||
"ibstat": &collectors.InfinibandCollector{},
|
||||
"lustrestat": &collectors.LustreCollector{},
|
||||
}
|
||||
type GlobalConfig struct {
|
||||
Sink struct {
|
||||
|
Loading…
Reference in New Issue
Block a user