Changeset 604


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
Location:
trunk/web2/addons/job_monarch
Files:
3 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
  • trunk/web2/addons/job_monarch/jobstore.php

    r603 r604  
    489489                $load_color     = load_color($load);
    490490
     491                $reported       = (int) $jobs[$jid]['reported'];
     492
     493                $time           = time();
    491494
    492495                // RB: something broken here with JR / JS
    493496                //
    494                 //$job_runtime  = intval( $jobs[$jid]['reported'] ) - intval( $jobs[$jid]['start_timestamp'] );
    495                 $job_runtime    = date( 'u' ) - intval( $jobs[$jid]['start_timestamp'] );
    496                 $job_window     = intval( $job_runtime ) * 1.2;
     497                $job_runtime    = $time - intval( $jobs[$jid]['start_timestamp'] );
     498                //$job_runtime  = date( 'u' ) - intval( $jobs[$jid]['start_timestamp'] );
     499                //$job_window   = intval( $job_runtime ) * 1.2;
    497500
    498501                $jobrange       = -$job_window;
    499                 $jobstart       = $jobs[$jid]['start_timestamp'];
     502                $jobstart       = (int) $jobs[$jid]['start_timestamp'];
     503                $period_start   = (int) ($time - (($time - $jobstart) * 1.1 ));
    500504
    501505                $nr['jid']      = $jid;
     
    515519                // maybe later to popup?
    516520                //
    517                 //$host_link      = "\"../../?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&js=$jobstart\"";
     521                //$host_link      = "\"../../?c=$cluster_url&h=$host_url&r=job&jr=$jobrange&job_start=$jobstart\"";
    518522
    519523                if ( $val["TYPE"] == "timestamp" || $always_timestamp[$metricname] )
     
    527531                else
    528532                {
     533                        $end            = time();
    529534                        $graphargs      = ($reports[$metricname]) ? "g=$metricname&" : "m=$metricname&";
    530                         $graphargs      .= "c=$cluster_url&h=$host_url&l=$load_color&v=".$val['VAL']."&r=job&jr=$jobrange&js=$jobstart";
     535                        $graphargs      .= "c=$cluster_url&h=$host_url&l=$load_color&v=".$val['VAL']."&r=job&period_start=$period_start&period_stop=$end&job_start=$jobstart";
    531536
    532537                        if( $max > 0 )
  • trunk/web2/addons/job_monarch/js/monarch.js

    r602 r604  
    829829        proxy:          JobProxy,
    830830        autoLoad:       false,
     831        // RB: anto cache store timestamp, dan autoload
    831832        baseParams:     { task: "GETMETRICS" },
    832833        reader:
     
    923924                                new Ext.XTemplate(
    924925                                        '<tpl for=".">',
    925                                         '<div class="rrd-float"><a href="../../graph.php?z=large&{ga}" border="0" rel="lightbox[{jid}.{[globalWindowCount]}]"><img src="../../graph.php?z=small&{ga}" border="0"></a></div>',
     926                                        '<div class="rrd-float"><a href="./graph.php?z=large&{ga}" border="0" rel="lightbox[{jid}.{[globalWindowCount]}]"><img src="./graph.php?z=small&{ga}" border="0"></a></div>',
    926927                                        '</tpl>'
    927928                                )
     
    967968                                        xtype:          'combo',
    968969                                        width:          190,
     970                                        myview:         view,
    969971                                        listeners:
    970972                                        {
     
    976978                                                        // doe iets
    977979
     980                                                        //this.myview.getStore().baseParams.metricname  = metric;
     981                                                        //this.myview.refresh();
    978982                                                        // RB: misschien zo metric opgeven aan datastore?
    979983                                                        //items[0].items[0].getStore().baseParams.metric = metric;
Note: See TracChangeset for help on using the changeset viewer.