Add LustreCollector

This commit is contained in:
Thomas Roehl 2021-03-25 16:52:28 +01:00
parent 642314c102
commit e9a74a4c9c
3 changed files with 65 additions and 1 deletions

View 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
}

View File

@ -12,7 +12,8 @@
"likwid", "likwid",
"loadavg", "loadavg",
"netstat", "netstat",
"ibstat" "ibstat",
"lustrestat"
] ]
} }

View File

@ -18,6 +18,7 @@ var Collectors = map[string]collectors.MetricGetter{
"memstat": &collectors.MemstatCollector{}, "memstat": &collectors.MemstatCollector{},
"netstat": &collectors.NetstatCollector{}, "netstat": &collectors.NetstatCollector{},
"ibstat": &collectors.InfinibandCollector{}, "ibstat": &collectors.InfinibandCollector{},
"lustrestat": &collectors.LustreCollector{},
} }
type GlobalConfig struct { type GlobalConfig struct {
Sink struct { Sink struct {