Ignore:
Timestamp:
02/17/09 15:57:35 (15 years ago)
Author:
ramonb
Message:

job_monarch/jobstore.php,
job_monarch/graph.php,
job_monarch/js/monarch.js:

  • changed node graph to use own graph.php, since Ganglia's graph.php is broken for jobs
  • correctly set/mark jobstart
  • correctly select time period for job ranges
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web2/addons/job_monarch/graph.php

    r532 r604  
    5757$hostname = $h;
    5858
    59 # Assumes we have a $start variable (set in get_context.php).
    60 if ($size == "small") {
    61         $height = 40;
    62         $width = 130;
    63 } else if ($size == "medium") {
    64         $height = 75;
    65         $width = 300;
    66 } else {
    67         $height = 100;
    68         $width = 400;
    69 }
     59//# Assumes we have a $start variable (set in get_context.php).
     60//if ($size == "small") {
     61//      $height = 40;
     62//      $width = 130;
     63//} else if ($size == "medium") {
     64//      $height = 75;
     65//      $width = 300;
     66//} else {
     67//      $height = 100;
     68//      $width = 400;
     69//}
     70
     71if( in_array( $size, array_keys( $graph_sizes ) ) )
     72{
     73        $height = $graph_sizes[ $size ][ 'height' ];
     74        $width  = $graph_sizes[ $size ][ 'width' ];
     75}
     76else
     77{
     78        $height = $graph_sizes[ 'default' ][ 'height' ];
     79        $width  = $graph_sizes[ 'default' ][ 'width' ];
     80}
     81
    7082
    7183if($command) {
     
    7587//printf( "cluster = %s hostname = %s metric = %s\n", $cluster, $hostname, $metricname );
    7688
    77 $trd = new TarchRrdGraph( $cluster, $hostname );
     89if( $archive )
     90{
     91        $trd = new TarchRrdGraph( $cluster, $hostname );
     92}
    7893//$rrd_files = $trd->getRrdFiles( $metricname, $start, $stop );
    7994
     
    8297$graph = $metricname;
    8398
    84 if (isset($graph)) {
     99if( isset($graph) )
     100{
    85101        $series = '';
    86         if( isset( $period_start ) && isset( $period_stop ) )
     102
     103        if( ( $archive ) && ( isset( $period_start ) && isset( $period_stop ) ) )
    87104        {
    88105                $rrd_dirs = $trd->getRrdDirs( $period_start, $period_stop );
     106        }
     107        else
     108        {
     109                $rrd_dirs = array( "$rrds/$clustername/$hostname" );
    89110        }
    90111
     
    365386                foreach( $rrd_dirs as $rrd_dir ) {
    366387
    367                         if( $def_nr == 0 ) {
    368                                 $title_str = ":'${subtitle}'";
    369                         } else {
     388                        if( $def_nr == 0 )
     389                        {
     390                                if( $archive )
     391                                {
     392                                        $title_str = ":'${subtitle}'";
     393                                }
     394                                else
     395                                {
     396                                        $title_str = ":'${subtitle} (now $value)'";
     397                                }
     398                        }
     399                        else
     400                        {
    370401                                $title_str = "";
    371402                        }
     
    387418}
    388419
    389 //$title = "$hostname $style $metricname";
    390420$title = "$hostname";
    391421
    392 //# Set the graph title.
    393 //if($context == "meta") {
    394 //      $title = "$self $meta_designator $style last $range";
    395 //} else if ($context == "grid") {
    396 //      $title = "$grid $meta_designator $style last $range";
    397 //} else if ($context == "cluster") {
    398 //      $title = "$clustername $style last $range";
    399 //} else {
    400 //      if ($size == "small") {
    401 //              # Value for this graph define a background color.
    402 //              if (!$load_color) $load_color = "ffffff";
    403 //                      $background = "--color BACK#'$load_color'";
    404 
    405 //              $title = $hostname;
    406 //      } else {
    407 //              if ($style)
    408 //                      $title = "$hostname $style last $range";
    409 //              else
    410 //                      $title = $metricname;
    411 //      }
    412 //}
     422if( !$load_color )
     423{
     424        $load_color = "ffffff";
     425}
     426
     427$background = "--color BACK#'$load_color'";
    413428
    414429function determineXGrid( $p_start, $p_stop ) {
     
    494509
    495510# Calculate time range.
    496 if( isset($sourcetime) )
    497 {
     511//if( isset($sourcetime) )
     512//{
    498513        //printf("yay");
    499514
    500         $end = $sourcetime;
    501         # Get_context makes start negative.
    502         $start = $sourcetime + $start;
    503 
    504         # Fix from Phil Radden, but step is not always 15 anymore.
    505         if ($range=="month")
    506                 $end = floor($end / 672) * 672;
    507 
    508         $command = RRDTOOL . " graph - --start $start --end $end ".
    509                 "--width $width --height $height $lower_limit ".
    510                 "--title '$title' $extras $background ".
    511                 $series;
    512 }
     515//      $end = $sourcetime;
     516//      # Get_context makes start negative.
     517//      $start = $sourcetime + $start;
     518
     519//      # Fix from Phil Radden, but step is not always 15 anymore.
     520//      if ($range=="month")
     521//              $end = floor($end / 672) * 672;
     522
     523//      $command = RRDTOOL . " graph - --start $start --end $end ".
     524//              "--width $width --height $height $lower_limit ".
     525//              "--title '$title' $extras $background ".
     526//              $series;
     527//}
    513528
    514529#
     
    520535#       $series;
    521536
    522 else {
     537//else {
    523538        $command = RRDTOOL . " graph - --start $period_start --end $period_stop ".
    524539                "--width $width --height $height $lower_limit ".
    525540                "--title '$title' $extras $background ".
    526541                $series;
    527 }
     542//}
    528543
    529544$debug=0;
    530545
    531546# Did we generate a command?   Run it.
    532 if($command) {
     547if( $command )
     548{
    533549        /*Make sure the image is not cached*/
    534550        header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");   // Date in the past
Note: See TracChangeset for help on using the changeset viewer.