Title: GraphDrawsWrongTotalMemory on Ubuntu 24.04.1 KVM Server
Introduction
This article discusses an issue where the graph drawn by a monitoring tool (e.g., Munin) on a Ubuntu 24.04.1 KVM server shows an incorrect total memory. This issue can cause confusion and inaccurate resource utilization analysis.
Context
When running a KVM-based server on Ubuntu 24.04.1 with 8GB RAM, the cat /proc/meminfo command shows the following:
MemTotal: 8082704 kB
However, the graph drawn by Munin shows a different total memory value.
Solution
The issue arises due to the way Munin calculates the total memory. To fix this, you can modify the Munin plugin configuration file for memory.
- Locate the Munin plugin configuration file for memory:
sudo nano /etc/munin/plugins/mem_total.pl
- Modify the plugin configuration file to use the
/proc/meminfocommand:
#%Module
#%Description: Memory total
#%Author: Munin Maintainers <[email protected]>
#%Contact: Munin Maintainers <[email protected]>
#%Version: 2.1.0
#%Depends:
#%EndDepend
#%Include: /etc/munin/plugins/common.pm
use strict;
use munin::plugin;
my $meminfo = `cat /proc/meminfo | grep MemTotal`;
my ($mem_total) = $meminfo =~ /^MemTotal:\s+(\d+) kB$/m;
my $plugin = new munin::plugin(
name => "Total memory",
version => "2.1.0",
charts => [
{ label => "Total memory", draw => WEBP,
details => "Memory total" }
],
help => "Memory total",
min => 0,
max => $mem_total,
instance => 1,
short_help => "Total memory in kB",
);
$plugin->add_graph_info(graph => {
vlabel_type => "number",
vlabel_unit => "kB",
});
$plugin->set_info(short_description => "Total memory in kB");
$plugin->set_info(long_description => "This graph shows the total memory available on the system.");
$plugin->set_info(warning => "90%", warning_colour => "orange");
$plugin->set_info(critical => "100%", critical_colour => "red");
$plugin->set_info(discard_unit => 1);
$plugin->set_info(units => "kB");
$plugin->set_info(extend => "up");
$plugin->set_info(ignore_errors => 1);
$plugin->run();
-
Save and close the file.
-
Restart the Munin-node service:
sudo systemctl restart munin-node
After making these changes, the Munin graph should now display the correct total memory.
Summary
In this article, we discussed an issue where the graph drawn by Munin on a Ubuntu 24.04.1 KVM server shows an incorrect total memory. To fix this issue, we modified the Munin plugin configuration file for memory to use the /proc/meminfo command.