| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-25 12:24:34 +00:00
										 |  |  | // Draw generic bits graph
 | 
					
						
							|  |  |  | // args: ds_in, ds_out, rrd_filename, bg, legend, from, to, width, height, inverse, percentile
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | require 'includes/graphs/common.inc.php'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | $unit_text = str_pad(truncate($unit_text, 18, ''), 18); | 
					
						
							|  |  |  | $line_text = str_pad(truncate($line_text, 12, ''), 12); | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($multiplier) { | 
					
						
							|  |  |  |     if (empty($multiplier_action)) { | 
					
						
							|  |  |  |         $multiplier_action = '*'; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     $rrd_options .= ' DEF:'.$ds.'_o='.$rrd_filename.':'.$ds.':AVERAGE'; | 
					
						
							|  |  |  |     $rrd_options .= ' CDEF:'.$ds.'='.$ds."_o,$multiplier,$multiplier_action"; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | else { | 
					
						
							|  |  |  |     $rrd_options .= ' DEF:'.$ds.'='.$rrd_filename.':'.$ds.':AVERAGE'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($print_total) { | 
					
						
							| 
									
										
										
										
											2015-11-15 11:48:39 +10:00
										 |  |  |     $rrd_options .= ' VDEF:'.$ds.'_total='.$ds.',TOTAL'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($percentile) { | 
					
						
							|  |  |  |     $rrd_options .= ' VDEF:'.$ds.'_percentile='.$ds.','.$percentile.',PERCENT'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($_GET['previous'] == 'yes') { | 
					
						
							|  |  |  |     if ($multiplier) { | 
					
						
							|  |  |  |         if (empty($multiplier_action)) { | 
					
						
							|  |  |  |             $multiplier_action = '*'; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |         $rrd_options .= ' DEF:'.$ds.'_oX='.$rrd_filename.':'.$ds.':AVERAGE:start='.$prev_from.':end='.$from; | 
					
						
							|  |  |  |         $rrd_options .= ' SHIFT:'.$ds."_oX:$period"; | 
					
						
							|  |  |  |         $rrd_options .= ' CDEF:'.$ds.'X='.$ds."_oX,$multiplier,*"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |         $rrd_options .= ' DEF:'.$ds.'X='.$rrd_filename.':'.$ds.':AVERAGE:start='.$prev_from.':end='.$from; | 
					
						
							|  |  |  |         $rrd_options .= ' SHIFT:'.$ds."X:$period"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ($print_total) { | 
					
						
							| 
									
										
										
										
											2015-11-15 11:48:39 +10:00
										 |  |  |         $rrd_options .= ' VDEF:'.$ds.'_totalX='.$ds.',TOTAL'; | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     if ($percentile) { | 
					
						
							|  |  |  |         $rrd_options .= ' VDEF:'.$ds.'_percentileX='.$ds.','.$percentile.',PERCENT'; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // if ($graph_max)
 | 
					
						
							|  |  |  |     // {
 | 
					
						
							|  |  |  |     // $rrd_options .= " AREA:".$ds."_max#".$colour_area_max.":";
 | 
					
						
							|  |  |  |     // }
 | 
					
						
							|  |  |  | }//end if
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $rrd_options .= ' AREA:'.$ds.'#'.$colour_area.':'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $rrd_options .= " COMMENT:'".$unit_text.'Now       Ave      Max'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($percentile) { | 
					
						
							|  |  |  |     $rrd_options .= '      '.$percentile.'th %'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $rrd_options .= "\\n'"; | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | $rrd_options .= ' LINE1.25:'.$ds.'#'.$colour_line.":'".$line_text."'"; | 
					
						
							|  |  |  | $rrd_options .= ' GPRINT:'.$ds.':LAST:%6.2lf%s'; | 
					
						
							|  |  |  | $rrd_options .= ' GPRINT:'.$ds.':AVERAGE:%6.2lf%s'; | 
					
						
							|  |  |  | $rrd_options .= ' GPRINT:'.$ds.':MAX:%6.2lf%s'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ($percentile) { | 
					
						
							|  |  |  |     $rrd_options .= ' GPRINT:'.$ds.'_percentile:%6.2lf%s'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-15 11:48:39 +10:00
										 |  |  | $rrd_options .= "\\n"; | 
					
						
							|  |  |  | $rrd_options .= " COMMENT:\\n"; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($print_total) { | 
					
						
							| 
									
										
										
										
											2015-11-15 11:48:39 +10:00
										 |  |  |     $rrd_options .= ' GPRINT:'.$ds.'_total:Total" %6.2lf%s"\\l'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($percentile) { | 
					
						
							|  |  |  |     $rrd_options .= ' LINE1:'.$ds.'_percentile#aa0000'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  | if ($_GET['previous'] == 'yes') { | 
					
						
							| 
									
										
										
										
											2015-11-15 11:48:39 +10:00
										 |  |  |     $rrd_options .= ' LINE1.25:'.$ds."X#666666:'Prev \\n'"; | 
					
						
							| 
									
										
										
										
											2015-07-10 13:36:21 +02:00
										 |  |  |     $rrd_options .= ' AREA:'.$ds.'X#99999966:'; | 
					
						
							| 
									
										
										
										
											2012-05-02 14:55:30 +00:00
										 |  |  | } |