How to display a graph only for business hours with CACTI?

I have noticed that I can only display an uninterrupted period with CACTI. I am wondering whether is possible or not to make a custom graph which displaying only the business hours during a period (a week, a month, etc.).

For example, I would like to be able to display a graph with an average inbound traffic between 8am and 6pm for 5 business days a week (monday to friday) of the last month.

I've tried to configure a script for RRDtool, but I don't know the right syntax. After severals tests, I saw that it is possible to superimpose differents graphs together. I was thinking to calculate the average of all thoses graphs, but I'm don't know how to do it.

I would like to configure something like the following:

--startday 20120604+8h
--endday 20120604+18h
monday:          --start startday --end endday
tuesday:         --start startday+24h --end endday+24h
wednesday:       --start startday+48h --end endday+48h
thursday:        --start startday+72h --end endday+72h
friday:          --start startday+96h --end endday+96h

DEF:monday=router.rrd:gi0/1:traffic_mon:AVERAGE
DEF:tuesday=router.rrd:gi0/1:traffic_tue:AVERAGE
DEF:wednesday=router.rrd:gi0/1:traffic_wed:AVERAGE
DEF:thursday=router.rrd:gi0/1:traffic_thu:AVERAGE
DEF:friday=router.rrd:gi0/1:traffic_fri:AVERAGE

DEF:traffic_mon:traffic_tue:traffic_wed:traffic_thu:traffic_fri:AVERAGE

I would apreciate any help.

Thank you.


Most likely, Cacti itself isn't going to be able to generate this kind of graph for you. You're going to need to generate your RRD graph manually using rrdgraph. The full solution is quite complicated, but the basic gist is that you create a CDEF with an RPN equation that nulls out the data during non-business hours.

A very basic example that removes the hours 2012-01-31 18:00:00 UTC to 2012-02-01 08:00:00 UTC would be:

DEF:ds0=/path/to/data.rrd:ds0:AVERAGE
CDEF:officehours=TIME,1328032800,GT,0,1,IF,TIME,1328083200,LT,0,1,IF,MAX,1,UNKN,IF
CDEF:dslimit=ds0,officehours,*
AREA:dslimit#00cc00:"Value "

The CDEF for officehours basically checks to see if the time of the sample is between 6pm and 8am. If it is, the value is UNKN. If it isn't, the value is 1. Multiply that by the value and you're left with actual values during office hours and unknowns during non-office hours. A graph would show a hole during non-office hours, and averages, maxes, and mins output via GPRINT or PRINT would not factor in the non-office hour values.

You'll have to setup a CDEF for each non-office hour period you want to filter out. Time is in seconds since the epoch, so if you were graphing, say, January 1st to February 1st, you'd have on the order of 20 distinct periods you need to filter out. RRD has very good language hooks, so you could write a simple Perl or Python script to generate these graphs on the fly for you.

Read over the rrdgraph, rrdgraph_rpn, and rrdgraph_examples man pages for more details and examples.