Cacti: Write value of GPRINT text bold/bigger
Posted: Tue May 21, 2013 5:29 pm
[PROBLEM]
I'm using Cacti to generate RRDTool graphs from SNMP values.
RRDTool is very powerful, and Cacti does a good job at providing a comfortable GUI for configuring these graphs.
Unfortunately, this means that some features RRDTool is able to handle, can't be used/configured using Cacti.
I wanted to have the currently measured value displayed within the graph.
In Cacti's "Graph Template" you can use the field "Text Format" for this, with the following settings:
For "Text Format" just enter the string to be used as label for the current (=LAST) value.
Unfortunately, there's no way of using RRDTool's advanced text formatting options (as listed in RRDTool's documentation)
Some common ones listed in the docs are:
[SOLUTION]
Unfortunately, in the current version of Cacti, this requires a patch to "lib/rrd.php"
All I've done was to wrap (=hardcoded! yikes) the html tags "<big>" around the variable called $graph_item["gprint_text"]. Now all values displayed using the "GPRINT+Text Format" fields in Cacti will be formatted like this.
I know it's an ugly hack and I apologize for it.
However, in my case it saved the day
I'm using Cacti to generate RRDTool graphs from SNMP values.
RRDTool is very powerful, and Cacti does a good job at providing a comfortable GUI for configuring these graphs.
Unfortunately, this means that some features RRDTool is able to handle, can't be used/configured using Cacti.
I wanted to have the currently measured value displayed within the graph.
In Cacti's "Graph Template" you can use the field "Text Format" for this, with the following settings:
Code: Select all
Data Source: None
Color: None
Graph Item Type: GPRINT
Consolidation Function: LAST
CDEF Function: None
GPRINT Type: Normal
Unfortunately, there's no way of using RRDTool's advanced text formatting options (as listed in RRDTool's documentation)
Some common ones listed in the docs are:
And that's exactly what I wanted to use.b Bold
big Makes font relatively larger, equivalent to <span size="larger">
i Italic
s Strikethrough
sub Subscript
sup Superscript
small Makes font relatively smaller, equivalent to <span size="smaller">
tt Monospace font
u Underline
[SOLUTION]
Unfortunately, in the current version of Cacti, this requires a patch to "lib/rrd.php"
Code: Select all
867d866
< "--pango-markup" . RRD_NL .
1364c1363
< $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":" . $data_source_name . ":" . $consolidation_functions{$graph_item["consolidation_function_id"]} . ":\"$text_padding" . $graph_variables["text_format"][$graph_item_id] ."<big>". $graph_item["gprint_text"] ."</big>". $hardreturn[$graph_item_id] . "\" ";
---
> $txt_graph_items .= $graph_item_types{$graph_item["graph_type_id"]} . ":" . $data_source_name . ":" . $consolidation_functions{$graph_item["consolidation_function_id"]} . ":\"$text_padding" . $graph_variables["text_format"][$graph_item_id] . $graph_item["gprint_text"] . $hardreturn[$graph_item_id] . "\" ";
I know it's an ugly hack and I apologize for it.
However, in my case it saved the day