diff --git a/lib/Munin/Master/Graph.pm b/lib/Munin/Master/Graph.pm index 25a8dadbb..ab4dd2086 100644 --- a/lib/Munin/Master/Graph.pm +++ b/lib/Munin/Master/Graph.pm @@ -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]; } @@ -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 diff --git a/lib/Munin/Master/HTML.pm b/lib/Munin/Master/HTML.pm index 5f409e9e6..f791f071e 100755 --- a/lib/Munin/Master/HTML.pm +++ b/lib/Munin/Master/HTML.pm @@ -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(); + 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 @@ -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;