From ae6d96a0ff23eb8b49288037634a8bff79e95771 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 12 May 2023 18:00:25 +0200 Subject: [PATCH] Get CPU in % from InfluxDB --- staticDevices.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/staticDevices.go b/staticDevices.go index ff12d6a..e77a350 100644 --- a/staticDevices.go +++ b/staticDevices.go @@ -16,14 +16,15 @@ func processGateways() []node { log.Println("Processing Static Device: ", d.Devices[i].Name) currentDevice := d.Devices[i] - //Calulate Memory + //Collect data + //Calulate Memory (%) mem := getInfluxDataPoint("mem", currentDevice.FQDN, conf.General.ProxmoxInfluxPort) maxmem := getInfluxDataPoint("maxmem", currentDevice.FQDN, conf.General.ProxmoxInfluxPort) memory := mem / maxmem * 100 rx := getInfluxDataPoint("netin", currentDevice.FQDN, conf.General.ProxmoxInfluxPort) tx := getInfluxDataPoint("netout", currentDevice.FQDN, conf.General.ProxmoxInfluxPort) - // Get CPU - cpu := getInfluxDataPoint("cpu", currentDevice.FQDN, conf.General.ProxmoxInfluxPort) + // Get CPU (%) + cpu := getInfluxDataPoint("cpu", currentDevice.FQDN, conf.General.ProxmoxInfluxPort) * 100 //Uptime (seconds) uptime := getInfluxDataPoint("uptime", currentDevice.FQDN, conf.General.ProxmoxInfluxPort) t := time.Duration(uptime * float64(time.Second)) @@ -54,6 +55,7 @@ func processGateways() []node { log.Fatalln("Error: ", err) } sendInfluxBatchDataPoint(point, conf.General.FreifunkInfluxPort) + //Build Nodes nodes = append(nodes, node{ Firstseen: up.Format(iso8601),