This is what I would call a "very naive" attempt, hopefully someone can take this and clean it up a little bit and work on getting it into the 0.9 branch.
It requires you to feed it an RRD that actually exists and specify a DS for that RRD that actually exists--though neither is actually used; it's just a dummy for the CDEF that calculates the workday.
In the calculation below the "-8" refers to the timezone, the "6" to our starting hour of 6am, and the "18" to our closing hour of 6pm.
I inserted this code at line 1189 of lib/rrd.php, right before "/* either print out the source or pass the source onto rrdtool to get us a nice PNG */"
Code: Select all
if (strpos("hoursarea", $graph_defs) === FALSE) {
$graph_defs .= "DEF:dummy=\"C\:/Cacti/rra/rrd_that_really_exists.rrd\":ds_that_really_exists:AVERAGE \\\n";
$graph_defs .= "CDEF:hours=dummy,POP,TIME,3600,/,-8,+,DUP,24,/,7,%,DUP,4,LT,EXC,2,GE,+,2,LT,EXC,24,%,DUP,6,GE,EXC,18,LT,+,2,EQ,1,0,IF,0,IF \\\n";
$graph_defs .= "CDEF:hoursarea=hours,INF,0,IF \\\n";
$graph_defs .= "AREA:hoursarea#F9FD5FFF:\"\" \\\n";
}
Keep in mind, if you do it this way it will add the business hours overlay to EVERY SINGLE GRAPH.