| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// Draw generic bits graph
 | 
					
						
							| 
									
										
										
										
											2011-09-21 11:59:59 +00:00
										 |  |  | /// args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, $percentile
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-11 11:20:02 +00:00
										 |  |  | $length = "10"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | if (!isset($percentile)) { $length += "2"; } | 
					
						
							| 
									
										
										
										
											2010-08-11 11:20:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | if (!isset($out_text)) { $out_text = "Out"; } | 
					
						
							|  |  |  | if (!isset($in_text)) { $in_text = "In"; } | 
					
						
							| 
									
										
										
										
											2010-08-11 11:20:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $unit_text = str_pad(truncate($unit_text,$length),$length); | 
					
						
							|  |  |  | $in_text   = str_pad(truncate($in_text,$length),$length); | 
					
						
							|  |  |  | $out_text   = str_pad(truncate($out_text,$length),$length); | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 11:59:59 +00:00
										 |  |  | $rrd_options .= " DEF:".$out."=".$rrd_filename.":".$ds_out.":AVERAGE"; | 
					
						
							|  |  |  | $rrd_options .= " DEF:".$in."=".$rrd_filename.":".$ds_in.":AVERAGE"; | 
					
						
							|  |  |  | $rrd_options .= " DEF:".$out."_max=".$rrd_filename.":".$ds_out.":MAX"; | 
					
						
							|  |  |  | $rrd_options .= " DEF:".$in."_max=".$rrd_filename.":".$ds_in.":MAX"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $rrd_options .= " CDEF:dout_max=out_max,-1,*"; | 
					
						
							|  |  |  | $rrd_options .= " CDEF:dout=out,-1,*"; | 
					
						
							|  |  |  | $rrd_options .= " CDEF:both=in,out,+"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | if ($print_total) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  |   $rrd_options .= " VDEF:totin=in,TOTAL"; | 
					
						
							|  |  |  |   $rrd_options .= " VDEF:totout=out,TOTAL"; | 
					
						
							|  |  |  |   $rrd_options .= " VDEF:tot=both,TOTAL"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | if ($percentile) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  |   $rrd_options .= " VDEF:percentile_in=in,".$percentile.",PERCENT"; | 
					
						
							|  |  |  |   $rrd_options .= " VDEF:percentile_out=out,".$percentile.",PERCENT"; | 
					
						
							|  |  |  |   $rrd_options .= " VDEF:dpercentile_out=dout,".$percentile.",PERCENT"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | if ($graph_max) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  |   $rrd_options .= " AREA:in_max#".$colour_area_in_max.":"; | 
					
						
							|  |  |  |   $rrd_options .= " AREA:dout_max#".$colour_area_out_max.":"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | $rrd_options .= " AREA:in#".$colour_area_in.":"; | 
					
						
							| 
									
										
										
										
											2010-08-11 11:20:02 +00:00
										 |  |  | $rrd_options .= " COMMENT:'".$unit_text."      Now       Ave      Max"; | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($percentile) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-28 23:34:13 +00:00
										 |  |  |   $rrd_options .= "      ".$percentile."th %"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-28 23:34:13 +00:00
										 |  |  | $rrd_options .= "\\n'"; | 
					
						
							| 
									
										
										
										
											2010-08-11 11:20:02 +00:00
										 |  |  | $rrd_options .= " LINE1.25:in#".$colour_line_in.":'".$in_text."'"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " GPRINT:in:LAST:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:in:AVERAGE:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:in_max:MAX:%6.2lf%s"; | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($percentile) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  |   $rrd_options .= " GPRINT:percentile_in:%6.2lf%s"; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-11 11:20:02 +00:00
										 |  |  | $rrd_options .= " COMMENT:'\\n'"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " AREA:dout#".$colour_area_out.":"; | 
					
						
							| 
									
										
										
										
											2010-08-11 11:20:02 +00:00
										 |  |  | $rrd_options .= " LINE1.25:dout#".$colour_line_out.":'".$out_text."'"; | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " GPRINT:out:LAST:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:out:AVERAGE:%6.2lf%s"; | 
					
						
							|  |  |  | $rrd_options .= " GPRINT:out_max:MAX:%6.2lf%s"; | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($percentile) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  |   $rrd_options .= " GPRINT:percentile_out:%6.2lf%s"; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  | $rrd_options .= " COMMENT:\\\\n"; | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($print_total) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-06-09 10:23:47 +00:00
										 |  |  |   $rrd_options .= " GPRINT:tot:'Total %6.2lf%s'"; | 
					
						
							| 
									
										
										
										
											2010-06-08 18:22:00 +00:00
										 |  |  |   $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
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-17 10:57:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if ($percentile) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-27 13:04:16 +00:00
										 |  |  |   $rrd_options .= " LINE1:percentile_in#aa0000"; | 
					
						
							|  |  |  |   $rrd_options .= " LINE1:dpercentile_out#aa0000"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 11:59:59 +00:00
										 |  |  | ?>
 |