Cacti does not fully support RRDtool options (yet, probably).
I tried implementing that..
(for Cacti 0.8.7g, but not tested completely. At your own risk.)
1) Add new field to rra table
% mysql -uUSER -pPASS cacti -e 'ALTER TABLE rra ADD x_grid VARCHAR(80) NULL;'
Result in database:
2) Modify source
include/global_form.php:
Code: Select all
--- include/global_form.php.org Thu Mar 31 15:47:00 2011
+++ include/global_form.php Mon May 16 16:26:00 2011
@@ -923,6 +923,13 @@
"value" => "|arg1:timespan|",
"max_length" => "12",
),
+ "x_grid" => array(
+ "method" => "textbox",
+ "friendly_name" => "X-Grid Definitions",
+ "description" => "Custom definitions of 'x-grid' option for this RRA.",
+ "value" => "|arg1:x_grid|",
+ "max_length" => "80",
+ ),
"id" => array(
"method" => "hidden_zero",
"value" => "|arg1:id|"
lib/rrd.php:
Code: Select all
--- lib/rrd.php.org Thu Mar 31 15:47:00 2011
+++ lib/rrd.php Mon May 16 16:30:22 2011
@@ -590,7 +590,7 @@
}
}
}else{
- $rra = db_fetch_row("select timespan,rows,steps from rra where id=$rra_id");
+ $rra = db_fetch_row("select timespan,rows,steps,x_grid from rra where id=$rra_id");
}
$seconds_between_graph_updates = ($ds_step * $rra["steps"]);
@@ -861,6 +861,11 @@
$graph_opts .= rrdtool_set_font("unit");
}
+ /* x-grid definitions */
+ if (!empty($rra["x_grid"])) {
+ $graph_opts .= "--x-grid " . $rra["x_grid"] . RRD_NL;
+ }
+
$i = 0; $j = 0;
$last_graph_cf = array();
if (sizeof($graph_items) > 0) {
rra.php:
Code: Select all
--- rra.php.org Sat Jul 10 07:33:46 2010
+++ rra.php Mon May 16 16:25:44 2011
@@ -66,6 +66,7 @@
$save["steps"] = form_input_validate($_POST["steps"], "steps", "^[0-9]*$", false, 3);
$save["rows"] = form_input_validate($_POST["rows"], "rows", "^[0-9]*$", false, 3);
$save["timespan"] = form_input_validate($_POST["timespan"], "timespan", "^[0-9]*$", false, 3);
+ $save["x_grid"] = form_input_validate($_POST["x_grid"], "x_grid", "", true, 3);
if (!is_error_message()) {
$rra_id = sql_save($save, "rra");
@@ -168,7 +169,8 @@
"name" => array("Name", "ASC"),
"steps" => array("Steps", "ASC"),
"rows" => array("Rows", "ASC"),
- "timespan" => array("Timespan", "ASC"));
+ "timespan" => array("Timespan", "ASC"),
+ "x_grid" => array("X-Grid Definitions", "ASC"));
html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"], 4);
@@ -177,7 +179,8 @@
name,
rows,
steps,
- timespan
+ timespan,
+ x_grid
FROM rra
ORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction']);
@@ -198,6 +201,9 @@
<td>
<?php print $rra["timespan"];?>
</td>
+ <td>
+ <?php print $rra["x_grid"];?>
+ </td>
<td align="right">
<a href="<?php print htmlspecialchars("rra.php?action=remove&id=" . $rra["id"]);?>"><img src="images/delete_icon.gif" style="height:10px;width:10px;" border="0" alt="Delete"></a>
</td>
Result:
3) Define x-grid as you like
(For example, I edited Daily RRA)
* I use "%p" (AM/PM) instead of "%P" (am/pm), because my rrdtool was linked with old C library when compiled.
Result:
NOTICE: This string should be sanitized (but this time I didn't)
4) View graphs
When I clicked "Graph Source/Properties" icon:
/usr/local/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title='Localhost - Disk Space - /var' \
--rigid \
--base=1024 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label='bytes' \
--slope-mode \
--font TITLE:10: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
--x-grid MINUTE:30:HOUR:2:HOUR:2:0:"%I%p" \
DEF:a="/var/www/cacti/rra/localhost_hdd_free_48.rrd":hdd_used:AVERAGE \
DEF:b="/var/www/cacti/rra/localhost_hdd_free_48.rrd":hdd_free:AVERAGE \
CDEF:cdefa=a,1024,* \
CDEF:cdefe=b,1024,* \
...
// Sorry my English