Working: router2.cgi-style shaded "business hours"

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Developers, Moderators

Post Reply
beaugunderson
Posts: 1
Joined: Wed Jan 28, 2009 1:12 pm

Working: router2.cgi-style shaded "business hours"

Post by beaugunderson »

I figured this out by looking at the router2.cgi source and figured I would share since there are countless requests in the forums for this functionality.

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";	
	}
Hope someone finds this useful!

Keep in mind, if you do it this way it will add the business hours overlay to EVERY SINGLE GRAPH.
Attachments
ss.jpg
ss.jpg (67.17 KiB) Viewed 5100 times
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests