Changeset 409 for trunk


Ignore:
Timestamp:
07/06/07 14:16:44 (17 years ago)
Author:
bastiaans
Message:

web/addons/job_monarch/version.php:

  • SVN version

web/addons/job_monarch/libtoga.php:

  • need $start in my graph.php

jobmond/jobmond.py:

  • added number of running and queued jobs metric reporting

web/addons/job_monarch/graph.php:

  • added 'job_report' graph, shows running and queued jobs

web/addons/job_monarch/overview.php:

  • included IMG to job_report graph

web/addons/job_monarch/index.php:

  • added range menu
  • fixed metric_menu selection now properly instantly refreshes graphs

web/addons/job_monarch/templates/overview.tpl:

  • added job_report graph
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/jobmond/jobmond.py

    r388 r409  
    327327                return incompatible
    328328
    329         def multicastGmetric( self, metricname, metricval, valtype='string' ):
     329        def multicastGmetric( self, metricname, metricval, valtype='string', units='' ):
    330330
    331331                """Call gmetric binary and multicast"""
     
    348348                        gm = Gmetric( GMETRIC_TARGET_HOST, GMETRIC_TARGET_PORT )
    349349
    350                         gm.send( str( metricname ), str( metricval ), str( self.dmax ) )
     350                        gm.send( str( metricname ), str( metricval ), str( self.dmax ), units )
    351351
    352352                else:
     
    359359
    360360                        cmd = cmd + ' -n' + str( metricname )+ ' -v"' + str( metricval )+ '" -t' + str( valtype ) + ' -d' + str( self.dmax )
     361
     362                        if len( units ) > 0:
     363
     364                                cmd = cmd + ' -u"' + units + '"'
    361365
    362366                        debug_msg( 10, printTime() + ' ' + cmd )
     
    776780                self.dp.multicastGmetric( 'MONARCH-HEARTBEAT', str( int( int( self.cur_time ) + int( self.timeoffset ) ) ) )
    777781
     782                running_jobs    = 0
     783                queued_jobs     = 0
     784
     785                for jobid, jobattrs in self.jobs.items():
     786
     787                        if jobattrs[ 'status' ] == 'Q':
     788
     789                                queued_jobs += 1
     790
     791                        elif jobattrs[ 'status' ] == 'R':
     792
     793                                running_jobs += 1
     794
     795                self.dp.multicastGmetric( 'MONARCH-RJ', str( running_jobs ), 'uint32', 'jobs' )
     796                self.dp.multicastGmetric( 'MONARCH-QJ', str( queued_jobs ), 'uint32', 'jobs' )
     797
    778798                # Now let's spread the knowledge
    779799                #
     
    922942                        return 'udp'
    923943
    924         def send( self, name, value, dmax ):
    925 
    926                 msg             = self.makexdr( name, value, self.type, self.unitstr, self.slopestr, self.tmax, dmax )
     944        def send( self, name, value, dmax, units = '' ):
     945
     946                if len( units ) == 0:
     947                        units           = self.unitrs
     948
     949                msg             = self.makexdr( name, value, self.type, units, self.slopestr, self.tmax, dmax )
    927950
    928951                return self.socket.sendto( msg, self.hostport )
  • trunk/web/addons/job_monarch/graph.php

    r231 r409  
    2323 */
    2424
    25 include_once "./libtoga.php";
     25global $metrics, $rrds, $range, $start, $r;
     26$range = $r;
     27
     28include "./libtoga.php";
    2629
    2730if ( !empty( $_GET ) ) {
    2831        extract( $_GET );
    2932}
     33
     34//printf( "st%s\n", $st);
     35$sourcetime = $st;
     36//printf( "st%s\n", $sourcetime);
     37
     38//printf( "%s\n", $rrds );
     39//printf( "r%s\n", $range);
     40//printf( "s %s\n", $start);
     41//printf( "e %s\n", $end);
    3042
    3143# Graph specific variables
     
    3951$load_color = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["l"] ));
    4052$vlabel = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["vl"] ));
    41 $sourcetime = escapeshellcmd($HTTP_GET_VARS["st"]);
     53//$sourcetime = escapeshellcmd($HTTP_GET_VARS["st"]);
    4254
    4355$cluster = $c;
     
    120132                        $def_nr++;
    121133                }
     134
     135        } else if ($graph == "job_report") {
     136                $style = "Jobs";
     137
     138                //$upper_limit = "--upper-limit 100 --rigid";
     139                $lower_limit = "--lower-limit 0 --rigid";
     140                $vertical_label = "--vertical-label Jobs";
     141
     142                $def_nr = 0;
     143
     144                foreach( $metrics as $bhost => $bmetric )
     145                {
     146                        foreach( $bmetric as $mname => $mval )
     147                        {
     148                                if( ( $mname == 'MONARCH-RJ' ) || ($mname == 'MONARCH-QJ') )
     149                                {
     150                                        $rjqj_host      = $bhost;
     151                                }
     152                        }
     153                }
     154
     155                $rrd_dir = "$rrds/$clustername/$rjqj_host/";
     156
     157                $rj_rrd = $rrd_dir . "MONARCH-RJ.rrd";
     158                $qj_rrd = $rrd_dir . "MONARCH-QJ.rrd";
     159
     160                $sorted_hosts   = array();
     161                $sorted_hosts[] = $rjqj_host;
     162
     163                //printf( "rjqjh %s\n", $rjqj_host);
     164
     165                //printf( "rrdd %s\n", $rrd_dir );
     166
     167                $rj_str = ":'Running Jobs'";
     168                $qj_str = ":'Queued Jobs'";
     169
     170                $series .= "DEF:'running_jobs'='${rj_rrd}':'sum':AVERAGE "
     171                        ."DEF:'queued_jobs'='${qj_rrd}':'sum':AVERAGE "
     172
     173               
     174                        ."LINE3:'running_jobs'#ff0000${rj_str} "
     175                        ."LINE3:'queued_jobs'#999999${qj_str} ";
    122176
    123177        } else if ($graph == "mem_report") {
     
    435489$lower_limit = "--lower-limit 0";
    436490
     491# Calculate time range.
     492if( isset($sourcetime) )
     493{
     494        //printf("yay");
     495
     496        $end = $sourcetime;
     497        # Get_context makes start negative.
     498        $start = $sourcetime + $start;
     499
     500        # Fix from Phil Radden, but step is not always 15 anymore.
     501        if ($range=="month")
     502                $end = floor($end / 672) * 672;
     503
     504        $command = RRDTOOL . " graph - --start $start --end $end ".
     505                "--width $width --height $height $lower_limit ".
     506                "--title '$title' $extras $background ".
     507                $series;
     508}
     509
    437510#
    438511# Generate the rrdtool graph command.
     
    442515#       "--title '$title' $vertical_label $extras $background $xgrid ".
    443516#       $series;
    444 $command = RRDTOOL . " graph - --start $period_start --end $period_stop ".
    445         "--width $width --height $height $lower_limit ".
    446         "--title '$title' $extras $background ".
    447         $series;
     517
     518else {
     519        $command = RRDTOOL . " graph - --start $period_start --end $period_stop ".
     520                "--width $width --height $height $lower_limit ".
     521                "--title '$title' $extras $background ".
     522                $series;
     523}
    448524
    449525$debug=0;
  • trunk/web/addons/job_monarch/index.php

    r406 r409  
    2626set_time_limit(0);
    2727
     28
     29$my_dir = getcwd();
     30
     31global $r, $range;
     32
     33include_once "./libtoga.php";
     34
    2835if ( !empty( $_GET ) ) {
    2936        extract( $_GET );
    3037}
    3138
    32 $my_dir = getcwd();
    33 
    34 include_once "./libtoga.php";
     39//printf( "r2%s\n", $range );
    3540
    3641global $GANGLIA_PATH;
     
    102107        global $default_refresh, $filterorder, $view;
    103108        global $JOB_ARCHIVE, $period_start, $period_stop, $h, $id;
    104         global $job_start, $job_stop;
     109        global $job_start, $job_stop, $range, $r;
    105110       
    106111        if( isset($default_metric) and !isset($m) )
     
    287292        $tpl->assignGlobal("view", $view);
    288293
     294
    289295        if( array_key_exists( "id", $filter ) or isset($hostname) ) {
     296
     297                $range = "job";
    290298
    291299                //print_r( $context_metrics );
     
    293301                if (is_array($context_metrics) ) {
    294302                        $metric_menu = "<B>Metric</B>&nbsp;&nbsp;"
    295                                 ."<SELECT NAME=\"m\" OnChange=\"".$form_name.".submit();\">\n";
     303                                ."<SELECT NAME=\"m\" OnChange=\"toga_form.submit();\">\n";
    296304
    297305                        sort($context_metrics);
     
    332340        //$ex_fn = $tpl->getVarValue( "_ROOT", "form_name" );
    333341
     342        $context_ranges[]="hour";
     343        $context_ranges[]="day";
     344        $context_ranges[]="week";
     345        $context_ranges[]="month";
     346        $context_ranges[]="year";
     347        $context_ranges[]="job";
     348
     349        $range_menu = "<B>Last</B>&nbsp;&nbsp;" ."<SELECT NAME=\"r\" OnChange=\"toga_form.submit();\">\n";
     350        foreach ($context_ranges as $v) {
     351                $url=rawurlencode($v);
     352                $range_menu .= "<OPTION VALUE=\"$url\" ";
     353                if ($v == $range)
     354                        $range_menu .= "SELECTED";
     355                $range_menu .= ">$v\n";
     356        }
     357        $range_menu .= "</SELECT>\n";
     358
     359        $tpl->assign("range_menu", $range_menu);
     360
    334361        if( $view == "search" or $view == "host" ) {
    335362
  • trunk/web/addons/job_monarch/libtoga.php

    r405 r409  
    9595include_once "./ganglia.php";
    9696include_once "./get_context.php";
    97 unset( $start );
     97//unset( $start );
    9898$context = 'cluster';
    9999include_once "./get_ganglia.php";
     
    117117//
    118118global $metrics, $hosts_up;
     119global $range, $start;
    119120
    120121global $DATETIME_FORMAT;
  • trunk/web/addons/job_monarch/overview.php

    r406 r409  
    2525global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url, $sh;
    2626global $hosts_up, $m, $start, $end, $filterorder, $COLUMN_REQUESTED_MEMORY, $COLUMN_QUEUED, $COLUMN_NODES, $hostname, $piefilter;
    27 global $longtitle, $title;
     27global $longtitle, $title, $range;
    2828
    2929$tpl->assign( "clustername", $clustername );
     
    502502{
    503503        global $jobs, $nodes, $heartbeat, $clustername, $tpl;
    504         global $sortorder, $sortby, $filter, $sh, $hc, $m;
     504        global $sortorder, $sortby, $filter, $sh, $hc, $m, $range;
    505505        global $cluster_url, $get_metric_string, $host_url, $metrics;
    506506        global $start, $end, $reports, $gnodes, $default_showhosts;
    507507        global $COLUMN_QUEUED, $COLUMN_REQUESTED_MEMORY, $COLUMN_NODES, $hostname;
     508        global $cluster;
    508509
    509510        $metricname             = $m;
     
    567568        $last_displayed_job     = null;
    568569
    569         foreach( $metrics as $bhost => $bmetric )
    570         {
    571                 foreach( $bmetric as $mname => $mval )
    572                 {
    573                         if( ( $mname == 'MONARCH-RJ' ) || ($mname == 'MONARCH-QJ') )
    574                         {
    575                                 $rjqj_host      = $bhost;
    576                         }
    577                 }
    578         }
    579         //$rjqj_str =  "<IMG SRC=\"../../graph.php?z=small&c=$cluster_url&h=$rjqj_host&m=MONARCH-QJ&r=job&jr=$jobrange&js=$jobstart\">";
    580         //printf( $rjqj_str, '' );
     570        $rjqj_str =  "<IMG SRC=\"./graph.php?z=small&c=$clustername&g=job_report&r=$range&st=$cluster[LOCALTIME]\">";
     571
     572        $tpl->gotoBlock( "_ROOT" );
     573
     574        $tpl->assign( "rjqj_graph", $rjqj_str );
    581575
    582576        foreach( $sorted_jobs as $jobid => $sortdec )
  • trunk/web/addons/job_monarch/templates/overview.tpl

    r346 r409  
    66
    77  <TD>
     8
    89
    910<TABLE ALIGN=CENTER class="overview" cellpadding="5">
     
    111112
    112113</TABLE>
     114
     115<BR>
     116{rjqj_graph}
    113117
    114118  <TD ALIGN="CENTER"><CENTER>
  • trunk/web/addons/job_monarch/version.php

    r333 r409  
    2222 */
    2323
    24 $monarchversion = "0.2+SVN";
     24$monarchversion = "0.2.1+SVN";
    2525?>
Note: See TracChangeset for help on using the changeset viewer.