Index: trunk/web/addons/job_monarch/graph.php =================================================================== --- trunk/web/addons/job_monarch/graph.php (revision 408) +++ trunk/web/addons/job_monarch/graph.php (revision 409) @@ -23,9 +23,21 @@ */ -include_once "./libtoga.php"; +global $metrics, $rrds, $range, $start, $r; +$range = $r; + +include "./libtoga.php"; if ( !empty( $_GET ) ) { extract( $_GET ); } + +//printf( "st%s\n", $st); +$sourcetime = $st; +//printf( "st%s\n", $sourcetime); + +//printf( "%s\n", $rrds ); +//printf( "r%s\n", $range); +//printf( "s %s\n", $start); +//printf( "e %s\n", $end); # Graph specific variables @@ -39,5 +51,5 @@ $load_color = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["l"] )); $vlabel = escapeshellcmd( rawurldecode( $HTTP_GET_VARS["vl"] )); -$sourcetime = escapeshellcmd($HTTP_GET_VARS["st"]); +//$sourcetime = escapeshellcmd($HTTP_GET_VARS["st"]); $cluster = $c; @@ -120,4 +132,46 @@ $def_nr++; } + + } else if ($graph == "job_report") { + $style = "Jobs"; + + //$upper_limit = "--upper-limit 100 --rigid"; + $lower_limit = "--lower-limit 0 --rigid"; + $vertical_label = "--vertical-label Jobs"; + + $def_nr = 0; + + foreach( $metrics as $bhost => $bmetric ) + { + foreach( $bmetric as $mname => $mval ) + { + if( ( $mname == 'MONARCH-RJ' ) || ($mname == 'MONARCH-QJ') ) + { + $rjqj_host = $bhost; + } + } + } + + $rrd_dir = "$rrds/$clustername/$rjqj_host/"; + + $rj_rrd = $rrd_dir . "MONARCH-RJ.rrd"; + $qj_rrd = $rrd_dir . "MONARCH-QJ.rrd"; + + $sorted_hosts = array(); + $sorted_hosts[] = $rjqj_host; + + //printf( "rjqjh %s\n", $rjqj_host); + + //printf( "rrdd %s\n", $rrd_dir ); + + $rj_str = ":'Running Jobs'"; + $qj_str = ":'Queued Jobs'"; + + $series .= "DEF:'running_jobs'='${rj_rrd}':'sum':AVERAGE " + ."DEF:'queued_jobs'='${qj_rrd}':'sum':AVERAGE " + + + ."LINE3:'running_jobs'#ff0000${rj_str} " + ."LINE3:'queued_jobs'#999999${qj_str} "; } else if ($graph == "mem_report") { @@ -435,4 +489,23 @@ $lower_limit = "--lower-limit 0"; +# Calculate time range. +if( isset($sourcetime) ) +{ + //printf("yay"); + + $end = $sourcetime; + # Get_context makes start negative. + $start = $sourcetime + $start; + + # Fix from Phil Radden, but step is not always 15 anymore. + if ($range=="month") + $end = floor($end / 672) * 672; + + $command = RRDTOOL . " graph - --start $start --end $end ". + "--width $width --height $height $lower_limit ". + "--title '$title' $extras $background ". + $series; +} + # # Generate the rrdtool graph command. @@ -442,8 +515,11 @@ # "--title '$title' $vertical_label $extras $background $xgrid ". # $series; -$command = RRDTOOL . " graph - --start $period_start --end $period_stop ". - "--width $width --height $height $lower_limit ". - "--title '$title' $extras $background ". - $series; + +else { + $command = RRDTOOL . " graph - --start $period_start --end $period_stop ". + "--width $width --height $height $lower_limit ". + "--title '$title' $extras $background ". + $series; +} $debug=0; Index: trunk/web/addons/job_monarch/index.php =================================================================== --- trunk/web/addons/job_monarch/index.php (revision 408) +++ trunk/web/addons/job_monarch/index.php (revision 409) @@ -26,11 +26,16 @@ set_time_limit(0); + +$my_dir = getcwd(); + +global $r, $range; + +include_once "./libtoga.php"; + if ( !empty( $_GET ) ) { extract( $_GET ); } -$my_dir = getcwd(); - -include_once "./libtoga.php"; +//printf( "r2%s\n", $range ); global $GANGLIA_PATH; @@ -102,5 +107,5 @@ global $default_refresh, $filterorder, $view; global $JOB_ARCHIVE, $period_start, $period_stop, $h, $id; - global $job_start, $job_stop; + global $job_start, $job_stop, $range, $r; if( isset($default_metric) and !isset($m) ) @@ -287,5 +292,8 @@ $tpl->assignGlobal("view", $view); + if( array_key_exists( "id", $filter ) or isset($hostname) ) { + + $range = "job"; //print_r( $context_metrics ); @@ -293,5 +301,5 @@ if (is_array($context_metrics) ) { $metric_menu = "Metric " - ."\n"; + ."\n"; sort($context_metrics); @@ -332,4 +340,23 @@ //$ex_fn = $tpl->getVarValue( "_ROOT", "form_name" ); + $context_ranges[]="hour"; + $context_ranges[]="day"; + $context_ranges[]="week"; + $context_ranges[]="month"; + $context_ranges[]="year"; + $context_ranges[]="job"; + + $range_menu = "Last " ."\n"; + foreach ($context_ranges as $v) { + $url=rawurlencode($v); + $range_menu .= "assign("range_menu", $range_menu); + if( $view == "search" or $view == "host" ) { Index: trunk/web/addons/job_monarch/libtoga.php =================================================================== --- trunk/web/addons/job_monarch/libtoga.php (revision 408) +++ trunk/web/addons/job_monarch/libtoga.php (revision 409) @@ -95,5 +95,5 @@ include_once "./ganglia.php"; include_once "./get_context.php"; -unset( $start ); +//unset( $start ); $context = 'cluster'; include_once "./get_ganglia.php"; @@ -117,4 +117,5 @@ // global $metrics, $hosts_up; +global $range, $start; global $DATETIME_FORMAT; Index: trunk/web/addons/job_monarch/overview.php =================================================================== --- trunk/web/addons/job_monarch/overview.php (revision 408) +++ trunk/web/addons/job_monarch/overview.php (revision 409) @@ -25,5 +25,5 @@ global $GANGLIA_PATH, $clustername, $tpl, $filter, $cluster, $get_metric_string, $cluster_url, $sh; global $hosts_up, $m, $start, $end, $filterorder, $COLUMN_REQUESTED_MEMORY, $COLUMN_QUEUED, $COLUMN_NODES, $hostname, $piefilter; -global $longtitle, $title; +global $longtitle, $title, $range; $tpl->assign( "clustername", $clustername ); @@ -502,8 +502,9 @@ { global $jobs, $nodes, $heartbeat, $clustername, $tpl; - global $sortorder, $sortby, $filter, $sh, $hc, $m; + global $sortorder, $sortby, $filter, $sh, $hc, $m, $range; global $cluster_url, $get_metric_string, $host_url, $metrics; global $start, $end, $reports, $gnodes, $default_showhosts; global $COLUMN_QUEUED, $COLUMN_REQUESTED_MEMORY, $COLUMN_NODES, $hostname; + global $cluster; $metricname = $m; @@ -567,16 +568,9 @@ $last_displayed_job = null; - foreach( $metrics as $bhost => $bmetric ) - { - foreach( $bmetric as $mname => $mval ) - { - if( ( $mname == 'MONARCH-RJ' ) || ($mname == 'MONARCH-QJ') ) - { - $rjqj_host = $bhost; - } - } - } - //$rjqj_str = ""; - //printf( $rjqj_str, '' ); + $rjqj_str = ""; + + $tpl->gotoBlock( "_ROOT" ); + + $tpl->assign( "rjqj_graph", $rjqj_str ); foreach( $sorted_jobs as $jobid => $sortdec ) Index: trunk/web/addons/job_monarch/templates/overview.tpl =================================================================== --- trunk/web/addons/job_monarch/templates/overview.tpl (revision 408) +++ trunk/web/addons/job_monarch/templates/overview.tpl (revision 409) @@ -6,4 +6,5 @@ + @@ -111,4 +112,7 @@ + + +{rjqj_graph} Index: trunk/web/addons/job_monarch/version.php =================================================================== --- trunk/web/addons/job_monarch/version.php (revision 408) +++ trunk/web/addons/job_monarch/version.php (revision 409) @@ -22,4 +22,4 @@ */ -$monarchversion = "0.2+SVN"; +$monarchversion = "0.2.1+SVN"; ?>