diff --git a/go.mod b/go.mod index cff824f..d1b78a3 100755 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/prometheus/client_golang v1.19.1 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 - github.com/starttoaster/go-proxmox v0.0.2 + github.com/starttoaster/go-proxmox v0.0.3 ) require ( diff --git a/go.sum b/go.sum index 35c2939..7aa58c4 100755 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= -github.com/starttoaster/go-proxmox v0.0.2 h1:4BI2DlIfFTDxUE80DLhshfzDTe/IGXVeQW1HUSdvr+s= -github.com/starttoaster/go-proxmox v0.0.2/go.mod h1:eyvj8nnoKJfwSjXIisLkErTtE2ErEsUHExcjG2zf+mQ= +github.com/starttoaster/go-proxmox v0.0.3 h1:1Z1EYMuNFkACdeYdR7gDOyTwykI74pZl9wi/b5cDi1M= +github.com/starttoaster/go-proxmox v0.0.3/go.mod h1:eyvj8nnoKJfwSjXIisLkErTtE2ErEsUHExcjG2zf+mQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= diff --git a/internal/prometheus/lxc.go b/internal/prometheus/lxc.go index 8d2a0c6..254d394 100644 --- a/internal/prometheus/lxc.go +++ b/internal/prometheus/lxc.go @@ -23,10 +23,10 @@ func (c *Collector) collectLxcMetrics(ch chan<- prometheus.Metric, node proxmox. if strings.EqualFold(lxc.Status, "running") { status = 1.0 } - ch <- prometheus.MustNewConstMetric(c.guestUp, prometheus.GaugeValue, status, node.Node, lxc.Type, lxc.Name, lxc.VMID) + ch <- prometheus.MustNewConstMetric(c.guestUp, prometheus.GaugeValue, status, node.Node, lxc.Type, lxc.Name, string(lxc.VMID)) // Add to LXC aggregate metrics - res.cpusAllocated += lxc.Cpus + res.cpusAllocated += lxc.CPUs res.memAllocated += lxc.MaxMem } return &res diff --git a/internal/prometheus/node.go b/internal/prometheus/node.go index e8bcdf1..e3b0e52 100644 --- a/internal/prometheus/node.go +++ b/internal/prometheus/node.go @@ -87,10 +87,10 @@ func (c *Collector) collectNode(ch chan<- prometheus.Metric, clusterResources *p if err != nil { logger.Logger.Error("failed making request to get node status", "node", node.Node, "error", err.Error()) } else { - resp.clusterCPUs = nodeStatus.Data.CPUInfo.Cpus + resp.clusterCPUs = nodeStatus.Data.CPUInfo.CPUs resp.clusterMem = nodeStatus.Data.Memory.Total c.collectNodeVersionMetric(ch, node, nodeStatus.Data) - ch <- prometheus.MustNewConstMetric(c.nodeCPUsTotal, prometheus.GaugeValue, float64(nodeStatus.Data.CPUInfo.Cpus), node.Node) + ch <- prometheus.MustNewConstMetric(c.nodeCPUsTotal, prometheus.GaugeValue, float64(nodeStatus.Data.CPUInfo.CPUs), node.Node) ch <- prometheus.MustNewConstMetric(c.nodeMemTotal, prometheus.GaugeValue, float64(nodeStatus.Data.Memory.Total), node.Node) } diff --git a/internal/prometheus/virtualmachine.go b/internal/prometheus/virtualmachine.go index 2ac0a3b..910315c 100644 --- a/internal/prometheus/virtualmachine.go +++ b/internal/prometheus/virtualmachine.go @@ -2,7 +2,6 @@ package prometheus import ( "github.com/starttoaster/proxmox-exporter/internal/logger" - "strconv" "strings" "github.com/prometheus/client_golang/prometheus" @@ -49,10 +48,10 @@ func (c *Collector) collectVirtualMachineMetrics(ch chan<- prometheus.Metric, cl if strings.EqualFold(vm.Status, "running") { status = 1.0 } - ch <- prometheus.MustNewConstMetric(c.guestUp, prometheus.GaugeValue, status, node.Node, "qemu", vm.Name, strconv.Itoa(vm.VMID)) + ch <- prometheus.MustNewConstMetric(c.guestUp, prometheus.GaugeValue, status, node.Node, "qemu", vm.Name, string(vm.VMID)) // Add to VM aggregate metrics - res.cpusAllocated += vm.Cpus + res.cpusAllocated += vm.CPUs res.memAllocated += vm.MaxMem } return &res