<?php

$g = 0;  # Graph number
$colors[0] = "#00ff00";
$colors[1] = "#0000ff";
$colors[2] = "#ff0000";
$colors[3] = "#00a0c1";
$colors[4] = "#ff00ff";
$colors[5] = "#ffab00";
$colors[6] = "#000000";
$colors[7] = "#ffff00";
$colors[8] = "#00ffff";
$colors[9] = "#a000c1";

# First, assign colors
$ic = 0;
foreach ($NAME as $key=>$val) {
   $elem[$key] = $val;
   $COLOR[$key] = $colors[$ic++%(count($colors))];
}

if (count($elem) > 0) {
   $g++;
   $ds_name[$g] = "Cisco QoS Queue Depths";
   $opt[$g] = "--vertical-label 'depth' --alt-autoscale-max --title \"Cisco QoS Queue Depths\" ";
   
   $def[$g] = "";
   foreach ($elem as $key=>$val) {
      $def[$g] .= "DEF:$NAME[$key]=$RRDFILE[$key]:$DS[$key]:AVERAGE ";
   }
#   foreach ($elem as $key=>$val) {
#      $def[$g] .= "CDEF:$NAME[$key]" . "f=$NAME[$key],1.8,*,32,+ ";
#   }
   foreach ($elem as $key=>$val) {
      $def[$g] .= "LINE:$NAME[$key]" . "$COLOR[$key]:\"$NAME[$key]\" ";
      $def[$g] .= "GPRINT:$NAME[$key]" . ":LAST:\"Cur\: %6.2lf $UNIT[$key] \" " ;
      $def[$g] .= "GPRINT:$NAME[$key]" . ":AVERAGE:\"Avg\: %6.2lf $UNIT[$key] \" " ;
      $def[$g] .= "GPRINT:$NAME[$key]" . ":MAX:\"Max\: %6.2lf $UNIT[$key] \\n\" " ;
   }
}

?>
