Skip to content

Commit

Permalink
Merge pull request #1 from natrontech/update-exporter
Browse files Browse the repository at this point in the history
feat: add load metrics
  • Loading branch information
janfuhrer authored Aug 23, 2023
2 parents de87464 + 6eb8ac0 commit d529fdd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Metrics are retrieved using the [Proxmox Backup Server API](https://pbs.proxmox.
| pbs_host_disk_used | The used disk of the local root disk in bytes. | |
| pbs_host_uptime | The uptime of the host. | |
| pbs_host_io_wait | The io wait of the host. | |
| pbs_host_load1 | The load for 1 minute of the host. | |
| pbs_host_load5 | The load for 5 minutes of the host. | |
| pbs_host_load15 | The load 15 minutes of the host. | |

## Flags / Environment Variables

Expand Down
32 changes: 30 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ var (
"The io wait of the host.",
nil, nil,
)
host_load1 = prometheus.NewDesc(
prometheus.BuildFQName(promNamespace, "", "host_load1"),
"The load for 1 minute of the host.",
nil, nil,
)
host_load5 = prometheus.NewDesc(
prometheus.BuildFQName(promNamespace, "", "host_load5"),
"The load for 5 minutes of the host.",
nil, nil,
)
host_load15 = prometheus.NewDesc(
prometheus.BuildFQName(promNamespace, "", "host_load15"),
"The load for 15 minutes of the host.",
nil, nil,
)
)

type DatastoreResponse struct {
Expand Down Expand Up @@ -192,8 +207,9 @@ type HostResponse struct {
Total int64 `json:"total"`
Used int64 `json:"used"`
} `json:"root"`
Uptime int64 `json:"uptime"`
Wait float64 `json:"wait"`
Load []float64 `json:"loadavg"`
Uptime int64 `json:"uptime"`
Wait float64 `json:"wait"`
} `json:"data"`
}

Expand Down Expand Up @@ -228,6 +244,9 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
ch <- host_disk_used
ch <- host_uptime
ch <- host_io_wait
ch <- host_load1
ch <- host_load5
ch <- host_load15
}

func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
Expand Down Expand Up @@ -393,6 +412,15 @@ func (e *Exporter) getNodeMetrics(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(
host_io_wait, prometheus.GaugeValue, float64(response.Data.Wait),
)
ch <- prometheus.MustNewConstMetric(
host_load1, prometheus.GaugeValue, float64(response.Data.Load[0]),
)
ch <- prometheus.MustNewConstMetric(
host_load5, prometheus.GaugeValue, float64(response.Data.Load[1]),
)
ch <- prometheus.MustNewConstMetric(
host_load15, prometheus.GaugeValue, float64(response.Data.Load[2]),
)

return nil
}
Expand Down

0 comments on commit d529fdd

Please sign in to comment.