Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions LibreNMS/Data/Metrics/MetricEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
readonly class MetricEntry
{
/**
* @param string $metric metric name
* @param string $metric metric name
* @param array<string, float|int> $fields
* @param array<string, string|int> $tags
* @param array<string, string|int> $tags
*/
public function __construct(
public string $metric,
public array $fields,
public array $tags,
) {}
) {
}
}
5 changes: 3 additions & 2 deletions LibreNMS/Data/Metrics/MetricWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class MetricWriter
public function __construct(
private readonly MetricCollector $collector,
private readonly WriteInterface $writer,
) {}
) {
}

public function writeMetrics(): void
{
Expand All @@ -20,7 +21,7 @@ public function writeMetrics(): void

public function writeMetric(string $metric, array $meta = []): void
{
foreach($this->collector->forMetric($metric) as $entry) {
foreach ($this->collector->forMetric($metric) as $entry) {
$meta['rrd_name'] = $metric . '-' . implode('-', $entry->tags);

$this->writer->write($metric, $entry->fields, $entry->tags, $meta);
Expand Down
1 change: 0 additions & 1 deletion LibreNMS/Interfaces/Polling/VmPortPolling.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace LibreNMS\Interfaces\Polling;

use App\Models\VmPort;
Expand Down
9 changes: 4 additions & 5 deletions LibreNMS/OS/Proxmox.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,27 @@ public function pollVminfo(Collection $vms, MetricCollector $metrics): Collectio
// ]);
$metrics->record($vm, 'vm.diskio', $this->aggregateDiskStats($status));


// Disk usage
// prefer guest agent (accurate per-filesystem data),
// fall back to hypervisor-level values if agent is absent/unavailable.
$fsInfo = $api->getVmFsInfo($vm->vmwVmVMID);

if (!empty($fsInfo)) {
if (! empty($fsInfo)) {
// Aggregate across all real filesystems, skipping pseudo-mounts
$skipTypes = ['tmpfs', 'devtmpfs', 'squashfs', 'overlay', 'proc', 'sysfs', 'cgroup', 'cgroup2'];
$diskUsed = 0;
$diskUsed = 0;
$diskTotal = 0;

foreach ($fsInfo as $fs) {
if (in_array($fs['type'] ?? '', $skipTypes, true)) {
continue;
}
$diskUsed += $fs['used-bytes'] ?? 0;
$diskUsed += $fs['used-bytes'] ?? 0;
$diskTotal += $fs['total-bytes'] ?? 0;
}

$metrics->record($vm, 'vm.disk', [
'used' => $diskUsed,
'used' => $diskUsed,
'total' => $diskTotal,
]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/ApiClients/ProxmoxApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public function __construct(
private string $hostname,
private int $timeout = 10,
){
) {
$this->base_uri = "https://$this->hostname:8006/api2/json";
$this->tokenName = LibrenmsConfig::get('proxmox.token_id');
$this->tokenSecret = LibrenmsConfig::get('proxmox.secret');
Expand Down
3 changes: 1 addition & 2 deletions includes/html/graphs/vminfo/diskio_bits.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$rrd_filename = Rrd::name($device['hostname'], ["vm.diskio", ...$vminfo->tags()]);
$rrd_filename = Rrd::name($device['hostname'], ['vm.diskio', ...$vminfo->tags()]);

if (! Rrd::checkRrdExists($rrd_filename)) {
throw new \LibreNMS\Exceptions\RrdGraphException('No Data');
Expand All @@ -15,5 +15,4 @@
$colour_area_out = '00FF00';
$colour_line_out = '009900';


require 'includes/html/graphs/generic_duplex.inc.php';
1 change: 0 additions & 1 deletion includes/html/graphs/vminfo/diskio_ops.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
$colour_area_out = '00FF00';
$colour_line_out = '009900';


$ds_in = 'read_ops';
$ds_out = 'write_ops';
$unit_text = 'Ops/sec';
Expand Down
1 change: 0 additions & 1 deletion includes/html/graphs/vminfo/net.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
$ds_in = 'in';
$ds_out = 'out';


$unit_text = 'Bits/sec';
$multiplier = 8;

Expand Down
Loading