Hi people!
I'm just evaluating cricket and cacti.
One feature i found nice with cricket are "zero rules", ie. VRULEs, which mark the begin of the day, week, month or year.
I'm not an SQL guy, so I'll leave the patching of an user configurable color value and if those zero-rules should be drawn to others.
Here is the code fragment, it's all patched against cacti-0.6.8a and goes into include/rrd_functions.ohp at/after line 895
Regards,
Richard
/*##############################################################*/
// An additional line-warp shouldn't hurt.
// if ($i < $rows) {
$graph_items .= "\\\n";
// }
}
/* +-------------------------------------------------------------------+
| ZERO RULES |
+-------------------------------------------------------------------+ */
/* These statements were actually taken out from CRICKET, written by
Jeff Allen. Since I don't know the first thing about SQL (well, at
least some bits'n'pieces I do know ), I'll let other people do
an implementation with nice check-boxes on the web-gui, boolean rows
and so on...
Here a kind of auto-detection must suffice.
Included here by Richard Scheffenegger in 2003 */
if ( true ) { // put some SQL-DB stuff in here (checkbox or existence of a valid vrule-color)
$vruleColor = "FF8080";
$timeToZeroTime = 0;
$deltaZeroTime = 0;
$now = time();
$ts = localtime($now, 1);
$timeToZeroTime += $ts[tm_sec];
$timeToZeroTime += $ts[tm_min] * 60;
$timeToZeroTime += $ts[tm_hour] * 60 * 60;
$deltaZeroTime = 60 * 60 * 24;
if ($timespan < -2678400) { // Do we span more than a month (4 weeks, actually)?
$timeToZeroTime += $ts[tm_yday] * 60 * 60 * 24;
# yikes... what about leap year? Ick.
$deltaZeroTime *= 365;
} else
if ($timespan < -604800) { // Do we span more than a week?
$timeToZeroTime += ($ts[tm_mday] -1) * 60 * 60 * 24;
$deltaZeroTime *= 30;
} else
if ($timespan < -86400) { // Do we span more than a day?
$timeToZeroTime += ($ts[tm_wday] - 1) * 60 * 60 * 24;
$deltaZeroTime *= 7;
}
$zeroTime = $now - $timeToZeroTime;
# loop and add a vrule for every zero point from
# now back to ($now - $range). This loop has
# the nice property that it will skip even the first VRULE,
# if that wouldn't fit on the graph.
while ($zeroTime > ($now + $timespan)) {
$graph_items .= "VRULE:$zeroTime#$vruleColor: \\\n";
$zeroTime -= $deltaZeroTime;
}
}
/*##############################################################*/
Zero Rules
Moderators: Developers, Moderators
Who is online
Users browsing this forum: No registered users and 1 guest