Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve ${graph_period} in field labels #1565

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
12 changes: 7 additions & 5 deletions lib/Munin/Master/Graph.pm
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,15 @@ sub handle_request
my $longest_fieldname = 0;
my %row;

while (my ($_rrdname, @rest) = $sth->fetchrow_array()) {
while (my ($_rrdname, $label, @rest) = $sth->fetchrow_array()) {
# The label is the fieldname if not present.
$label ||= $_rrdname;
$label =~ s/\$\{graph_period\}/$graph_period/g;
unshift @rest, $label;

$row{$_rrdname} = \@rest;

my $l = length($_rrdname);
my $l = length($label);
$longest_fieldname = $l if $l > $longest_fieldname;
$graph_has_negative = 1 if $rest[9];
}
Expand Down Expand Up @@ -401,9 +406,6 @@ sub handle_request
$_printf = $graph_printf unless defined $_printf;
$_printf .= "%s" if $graph_scale;

# The label is the fieldname if not present
$_label = $_rrdname unless $_label;

DEBUG "rrdname: $_rrdname: negative: ".($_negative // "undef")." has_negative: ".($_has_negative // "undef");

# rrdtool fails on unescaped colons found in its input data
Expand Down
7 changes: 7 additions & 0 deletions lib/Munin/Master/HTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,11 @@ sub _get_params_services {
sub _get_params_fields {
my ($dbh, $service_id) = @_;

my $sth_sa = $dbh->prepare_cached("SELECT value FROM service_attr WHERE id = ? and name = ?");

$sth_sa->execute($service_id, 'graph_period');
my ($graph_period) = $sth_sa->fetchrow_array();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@steveschnepp : any clue to why this prepare/execute returns a empty value?

Compare https://github.com/munin-monitoring/munin/blob/master/lib/Munin/Master/Graph.pm#L227 and the ds query further down.


my $sth_ds = $dbh->prepare_cached("
SELECT ds.name, ds.warning, ds.critical,
a_g.value, a_l.value, a_t.value, a_w.value, a_c.value, a_i.value
Expand All @@ -838,6 +843,8 @@ sub _get_params_fields {
$sth_ds->fetchrow_array) {
next if $_ds_graph && $_ds_graph eq 'no';

$_ds_label =~ s/\$\{graph_period\}/$graph_period/g;

# GAUGE by default
$_ds_type = 'GAUGE' unless defined $_ds_type;

Expand Down