| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// Draw generic bits graph
 | 
					
						
							| 
									
										
										
										
											2012-04-17 13:29:27 +00:00
										 |  |  | /// args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, previous
 | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-24 19:14:41 +00:00
										 |  |  | include("includes/graphs/common.inc.php"); | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | if ($rrd_filename) { $rrd_filename_out = $rrd_filename; $rrd_filename_in = $rrd_filename; } | 
					
						
							|  |  |  | if ($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | if ($multiplier) | 
					
						
							| 
									
										
										
										
											2010-07-31 19:12:40 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-21 11:59:59 +00:00
										 |  |  |   $rrd_options .= " DEF:p".$out."octets=".$rrd_filename_out.":".$ds_out.":AVERAGE"; | 
					
						
							|  |  |  |   $rrd_options .= " DEF:p".$in."octets=".$rrd_filename_in.":".$ds_in.":AVERAGE"; | 
					
						
							|  |  |  |   $rrd_options .= " DEF:p".$out."octets_max=".$rrd_filename_out.":".$ds_out.":MAX"; | 
					
						
							|  |  |  |   $rrd_options .= " DEF:p".$in."octets_max=".$rrd_filename_in.":".$ds_in.":MAX"; | 
					
						
							| 
									
										
										
										
											2010-07-31 19:12:40 +00:00
										 |  |  |   $rrd_options .= " CDEF:inoctets=pinoctets,$multiplier,*"; | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:outoctets=poutoctets,$multiplier,*"; | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:inoctets_max=pinoctets_max,$multiplier,*"; | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:outoctets_max=poutoctets_max,$multiplier,*"; | 
					
						
							|  |  |  | } else { | 
					
						
							| 
									
										
										
										
											2011-09-21 11:59:59 +00:00
										 |  |  |   $rrd_options .= " DEF:".$out."octets=".$rrd_filename_out.":".$ds_out.":AVERAGE"; | 
					
						
							|  |  |  |   $rrd_options .= " DEF:".$in."octets=".$rrd_filename_in.":".$ds_in.":AVERAGE"; | 
					
						
							|  |  |  |   $rrd_options .= " DEF:".$out."octets_max=".$rrd_filename_out.":".$ds_out.":MAX"; | 
					
						
							|  |  |  |   $rrd_options .= " DEF:".$in."octets_max=".$rrd_filename_in.":".$ds_in.":MAX"; | 
					
						
							| 
									
										
										
										
											2010-07-31 19:12:40 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-17 13:29:27 +00:00
										 |  |  | if($_GET['previous'] == "yes") | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if ($multiplier) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     $rrd_options .= " DEF:p".$out."octetsX=".$rrd_filename_out.":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; | 
					
						
							|  |  |  |     $rrd_options .= " DEF:p".$in."octetsX=".$rrd_filename_in.":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; | 
					
						
							|  |  |  |     $rrd_options .= " SHIFT:p".$out."octetsX:$period"; | 
					
						
							|  |  |  |     $rrd_options .= " SHIFT:p".$in."octetsX:$period"; | 
					
						
							|  |  |  |     $rrd_options .= " CDEF:inoctetsX=pinoctetsX,$multiplier,*"; | 
					
						
							|  |  |  |     $rrd_options .= " CDEF:outoctetsX=poutoctetsX,$multiplier,*"; | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     $rrd_options .= " DEF:".$out."octetsX=".$rrd_filename_out.":".$ds_out.":AVERAGE:start=".$prev_from.":end=".$from; | 
					
						
							|  |  |  |     $rrd_options .= " DEF:".$in."octetsX=".$rrd_filename_in.":".$ds_in.":AVERAGE:start=".$prev_from.":end=".$from; | 
					
						
							|  |  |  |     $rrd_options .= " SHIFT:".$out."octetsX:$period"; | 
					
						
							|  |  |  |     $rrd_options .= " SHIFT:".$in."octetsX:$period"; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:octetsX=inoctetsX,outoctetsX,+"; | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:doutoctetsX=outoctetsX,-1,*"; | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:outbitsX=outoctetsX,8,*"; | 
					
						
							|  |  |  |   #$rrd_options .= " CDEF:outbits_maxX=outoctets_maxX,8,*";
 | 
					
						
							|  |  |  |   #$rrd_options .= " CDEF:doutoctets_maxX=outoctets_maxX,-1,*";
 | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:doutbitsX=doutoctetsX,8,*"; | 
					
						
							|  |  |  |   #$rrd_options .= " CDEF:doutbits_maxX=doutoctets_maxX,8,*";
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   $rrd_options .= " CDEF:inbitsX=inoctetsX,8,*"; | 
					
						
							|  |  |  |   #$rrd_options .= " CDEF:inbits_maxX=inoctets_maxX,8,*";
 | 
					
						
							|  |  |  |   $rrd_options .= " VDEF:totinX=inoctetsX,TOTAL"; | 
					
						
							|  |  |  |   $rrd_options .= " VDEF:totoutX=outoctetsX,TOTAL"; | 
					
						
							|  |  |  |   $rrd_options .= " VDEF:totX=octetsX,TOTAL"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " CDEF:octets=inoctets,outoctets,+"; | 
					
						
							|  |  |  | $rrd_options .= " CDEF:doutoctets=outoctets,-1,*"; | 
					
						
							| 
									
										
										
										
											2010-07-31 19:12:40 +00:00
										 |  |  | $rrd_options .= " CDEF:outbits=outoctets,8,*"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " CDEF:outbits_max=outoctets_max,8,*"; | 
					
						
							|  |  |  | $rrd_options .= " CDEF:doutoctets_max=outoctets_max,-1,*"; | 
					
						
							|  |  |  | $rrd_options .= " CDEF:doutbits=doutoctets,8,*"; | 
					
						
							| 
									
										
										
										
											2010-07-31 19:12:40 +00:00
										 |  |  | $rrd_options .= " CDEF:doutbits_max=doutoctets_max,8,*"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $rrd_options .= " CDEF:inbits=inoctets,8,*"; | 
					
						
							|  |  |  | $rrd_options .= " CDEF:inbits_max=inoctets_max,8,*"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 19:16:23 +00:00
										 |  |  | if ($config['rrdgraph_real_95th']) { | 
					
						
							| 
									
										
										
										
											2011-09-20 14:37:54 +00:00
										 |  |  |         $rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*"; | 
					
						
							|  |  |  |         $rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT"; | 
					
						
							| 
									
										
										
										
											2011-07-19 19:16:23 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " VDEF:totin=inoctets,TOTAL"; | 
					
						
							|  |  |  | $rrd_options .= " VDEF:totout=outoctets,TOTAL"; | 
					
						
							|  |  |  | $rrd_options .= " VDEF:tot=octets,TOTAL"; | 
					
						
							| 
									
										
										
										
											2010-07-31 19:12:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " VDEF:95thin=inbits,95,PERCENT"; | 
					
						
							|  |  |  | $rrd_options .= " VDEF:95thout=outbits,95,PERCENT"; | 
					
						
							|  |  |  | $rrd_options .= " VDEF:d95thout=doutbits,5,PERCENT"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-20 10:35:13 +00:00
										 |  |  | if($format == "octets" || $format == "bytes") | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   $units = "Bps"; | 
					
						
							|  |  |  |   $format = "octets"; | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   $units = "bps"; | 
					
						
							|  |  |  |   $format = "bits"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-28 15:57:32 +00:00
										 |  |  | $rrd_options .= " COMMENT:'bps      Now       Ave      Max      95th %\\n'"; | 
					
						
							| 
									
										
										
										
											2011-10-26 10:14:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-20 10:35:13 +00:00
										 |  |  | $rrd_options .= " AREA:in".$format."_max#aDEB7B:"; | 
					
						
							|  |  |  | $rrd_options .= " AREA:in".$format."#91B13C:'In '"; | 
					
						
							|  |  |  | #$rrd_options .= " LINE1.25:in".$format."#006600:'In '";
 | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:in".$format.":LAST:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:in".$format.":AVERAGE:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:in".$format."_max:MAX:%6.2lf%s"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n"; | 
					
						
							| 
									
										
										
										
											2011-10-26 10:14:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-20 10:35:13 +00:00
										 |  |  | $rrd_options .= " AREA:dout".$format."_max#a3b9FF:"; | 
					
						
							|  |  |  | $rrd_options .= " AREA:dout".$format."#8080BD:'Out'"; | 
					
						
							|  |  |  | #$rrd_options .= " LINE1.25:dout".$format."#000099:Out";
 | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:out".$format.":LAST:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:out".$format.":AVERAGE:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:out".$format."_max:MAX:%6.2lf%s"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n"; | 
					
						
							| 
									
										
										
										
											2011-07-19 19:16:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($config['rrdgraph_real_95th']) { | 
					
						
							| 
									
										
										
										
											2011-09-20 14:37:54 +00:00
										 |  |  |         $rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\""; | 
					
						
							|  |  |  |         $rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\""; | 
					
						
							| 
									
										
										
										
											2011-07-19 19:16:23 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-08 18:22:00 +00:00
										 |  |  | $rrd_options .= " GPRINT:tot:'Total %6.2lf%s'"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:totin:'(In %6.2lf%s'"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:totout:'Out %6.2lf%s)\\\\l'"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " LINE1:95thin#aa0000"; | 
					
						
							|  |  |  | $rrd_options .= " LINE1:d95thout#aa0000"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-17 13:29:27 +00:00
										 |  |  | if($_GET['previous'] == "yes") | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-20 10:35:13 +00:00
										 |  |  |   $rrd_options .= " LINE1.25:in".$format."X#009900:'Prev In \\\\n'"; | 
					
						
							|  |  |  |   $rrd_options .= " LINE1.25:dout".$format."X#000099:'Prev Out'"; | 
					
						
							| 
									
										
										
										
											2012-04-17 13:29:27 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-13 13:06:20 +00:00
										 |  |  | ?>
 |