7

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.

kronn
  • 182
  • 17
Blast Raider
  • 171
  • 1
  • 3

3 Answers3

3

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.

hrunting
  • 943
  • 4
  • 7
-1

The CACTI poller runs out of cron.

*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1

If you only want to poll within working hours, its possible to configure that in cron, but rrdtool will display the gaps on the graph where polling wasnt conducted.

Sirch
  • 5,697
  • 4
  • 19
  • 36
  • Can I just retrieved the average traffic ? I don't mind if the graphs won't display well. – Blast Raider Jun 11 '12 at 12:48
  • Not for cacti, if you have the rrd data, contrary to what womble says, yes rrdtool does work like that, you have a great ammount of control over what you can see, have a look at http://oss.oetiker.ch/rrdtool/doc/rrdgraph_examples.en.html – Sirch Jun 11 '12 at 13:09
  • Thank you for the rrdgraph examples. I would like viewing 5 days from 8am to 6pm together and caclulate the overall average. – Blast Raider Jun 12 '12 at 08:50
  • I have edited the question – Blast Raider Jun 12 '12 at 09:18
  • You cant superimpose different time periods over each other. In rrdtool graphs, time is linear, from a start point until an end point. Any graphs you wish displayed will be along this continual line. What you can do is pull out sections, and averages for that section. What you are asking to do now... no, rrdtool doesnt work like that. – Sirch Jun 12 '12 at 17:24
-2

No, rrdtool doesn't work like that.

womble
  • 95,029
  • 29
  • 173
  • 228