[release] v0.12.0-unstable4
This commit is contained in:
parent
6aa8a9e5fa
commit
8a547e1b9c
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.12.0-unstable3",
|
"version": "0.12.0-unstable4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -2,7 +2,9 @@ package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/cpu"
|
"github.com/shirou/gopsutil/cpu"
|
||||||
"github.com/shirou/gopsutil/mem"
|
"github.com/shirou/gopsutil/mem"
|
||||||
|
@ -122,15 +124,23 @@ func GetSystemMetrics() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, part := range parts {
|
for _, part := range parts {
|
||||||
u, err := disk.Usage(part.Mountpoint)
|
if strings.HasPrefix(part.Mountpoint, "/dev") || strings.HasPrefix(part.Mountpoint, "/mnt") {
|
||||||
if err != nil {
|
realMount := part.Mountpoint
|
||||||
utils.Error("Metrics - Error fetching Disk usage for " + part.Mountpoint + " : ", err)
|
|
||||||
} else {
|
if os.Getenv("HOSTANME") != "" {
|
||||||
PushSetMetric("system.disk." + part.Mountpoint, int(u.Used), DataDef{
|
realMount = "/mnt/host" + part.Mountpoint
|
||||||
Max: u.Total,
|
}
|
||||||
Period: time.Second * 120,
|
|
||||||
Label: "Disk " + part.Mountpoint,
|
u, err := disk.Usage(realMount)
|
||||||
})
|
if err != nil {
|
||||||
|
utils.Error("Metrics - Error fetching Disk usage for " + realMount + " : ", err)
|
||||||
|
} else {
|
||||||
|
PushSetMetric("system.disk." + part.Mountpoint, int(u.Used), DataDef{
|
||||||
|
Max: u.Total,
|
||||||
|
Period: time.Second * 120,
|
||||||
|
Label: "Disk " + part.Mountpoint,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue