Ignore:
Timestamp:
11/12/09 17:08:03 (14 years ago)
Author:
ramonb
Message:

job_monarch/overview.php,
job_monarch/index.php:

  • old code cleanup

job_monarch/index.php,
job_monarch/image.php,
job_monarch/jobstore.php

  • rewrote session handling

job_monarch/image.php:

job_monarch/templates/header.tpl:

  • add session to clusterimage
  • (temp?) disabled pie chart

job_monarch/libtoga.php:

  • wrote new SessionHandler? class to handle all sessions
  • DataSource? now uses interactive port so can retrieve only relevant XML
  • disable XML_OPTION_CASE_FOLDING to speed up xml parsing
  • use jobmond poll interval to only reload XML when useful
  • use strpos instead of strstr, should be faster xml parsing
  • dont parse XML in ClusterImage? anymore, instead supply DataGather? object


job_monarch/conf.php:

  • use interactive gmetad port now
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/job_monarch/index.php

    r592 r648  
    2323 */
    2424
    25 ini_set("memory_limit","200M");
     25//ini_set("memory_limit","200M");
     26ini_set("memory_limit","1G");
    2627set_time_limit(0);
    2728
     
    4445chdir( $my_dir );
    4546
    46 $httpvars = new HTTPVariables( $HTTP_GET_VARS, $_GET );
    47 $clustername = $httpvars->getClusterName();
    48 $view = $httpvars->getHttpVar( "view" );
     47$httpvars       = new HTTPVariables( $HTTP_GET_VARS, $_GET );
     48$clustername    = $httpvars->getClusterName();
     49$view           = $httpvars->getHttpVar( "view" );
     50
     51global $mySession, $myData, $myXML;
     52
     53//printf( "c %s\n", $clustername );
     54
     55$mySession      = new SessionHandler( $clustername );
     56$mySession->checkSession();
     57
     58$session        = &$mySession->getSession();
     59$myXML          = $session['data'];
     60
     61$myData         = new DataGatherer( $clustername );
     62$myData->parseXML( $myXML );
     63
     64$mySession->updatePollInterval( $myData->getPollInterval() );
     65$mySession->endSession();
    4966
    5067$filter = array();
     
    94111}
    95112
    96 function makeHeader( $page_call, $title, $longtitle )
    97 {
    98         global $tpl, $grid, $context, $initgrid;
    99         global $jobrange, $jobstart;
    100         global $page, $gridwalk, $clustername;
    101         global $parentgrid, $physical, $hostname;
    102         global $self, $filter, $cluster_url, $get_metric_string;
    103         global $metrics, $reports, $m, $default_metric;
    104         global $default_refresh, $filterorder, $view;
    105         global $JOB_ARCHIVE, $period_start, $period_stop, $h, $id;
    106         global $job_start, $job_stop, $range, $r, $metricname;
    107        
    108         if( isset($default_metric) and !isset($m) )
    109                 $metricname = $default_metric;
    110         else
    111                 if( isset( $m ) )
    112                         $metricname = $m;
    113                 else
    114                         $metricname = "load_one";
    115 
    116         $header = "header";
    117 
    118         # Maintain our path through the grid tree.
    119         $me = $self . "@" . $grid[$self]['AUTHORITY'];
    120 
    121         $gridstack = array();
    122         $gridstack[] = $me;
    123 
    124         if ($gridwalk=="fwd")
    125         {
    126                 # push our info on gridstack, format is "name@url>name2@url".
    127                 if (end($gridstack) != $me)
    128                 {
    129                         $gridstack[] = $me;
    130                 }
    131         }
    132         else if ($gridwalk=="back")
    133         {
    134                 # pop a single grid off stack.
    135                 if (end($gridstack) != $me)
    136                 {
    137                         array_pop($gridstack);
    138                 }
    139         }
    140 
    141         $gridstack_str = join(">", $gridstack);
    142         $gridstack_url = rawurlencode($gridstack_str);
    143 
    144         if ($initgrid or $gridwalk)
    145         {
    146                 # Use cookie so we dont have to pass gridstack around within this site.
    147                 # Cookie values are automatically urlencoded. Expires in a day.
    148                 setcookie("gs", $gridstack_str, time() + 86400);
    149         }
    150 
    151         # Invariant: back pointer is second-to-last element of gridstack. Grid stack never
    152         # has duplicate entries.
    153         list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]);
    154 
    155         # Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell
    156         # destination server that we're walking foward in the grid tree.
    157         if (strstr($clustername, "http://"))
    158         {
    159                 $tpl->assign("refresh", "0");
    160                 $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url");
    161                 echo "<h2>Redirecting, please wait...</h2>";
    162                 $tpl->printToScreen();
    163                 exit;
    164         }
    165         $tpl->gotoBlock( "_ROOT" );
    166 
    167         if( $view != "search" )
    168                 $tpl->assign( "refresh", $default_refresh );
    169 
    170         $tpl->assign( "date", date("r") );
    171         //printf("lg %s\n", $longtitle );
    172         //printf("title %s\n", $title );
    173         $tpl->assign( "longpage_title", $longtitle );
    174         $tpl->assign( "page_title", $title );
    175 
    176         # The page to go to when "Get Fresh Data" is pressed.
    177         $tpl->assign("page","./");
    178 
    179         # Templated Logo image
    180         $tpl->assign("images","./templates/$template_name/images");
    181 
    182         #
    183         # Used when making graphs via graph.php. Included in most URLs
    184         #
    185         $sort_url=rawurlencode($sort);
    186         $get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols";
    187 
    188         if ($jobrange and $jobstart)
    189                 $get_metric_string .= "&jr=$jobrange&js=$jobstart";
    190 
    191         # Set the Alternate view link.
    192         $cluster_url=rawurlencode($clustername);
    193         $node_url=rawurlencode($hostname);
    194 
    195         # Make some information available to templates.
    196         $tpl->assign("cluster_url", $cluster_url);
    197         # Build the node_menu
    198         $node_menu = "";
    199 
    200         if ($parentgrid)
    201         {
    202                 $node_menu .= "<B>$parentgrid $meta_designator</B> ";
    203                 $node_menu .= "<B>&gt;</B>\n";
    204         }
    205 
    206         # Show grid.
    207         $mygrid =  ($self == "unspecified") ? "" : $self;
    208         $node_menu .= "<B><A HREF=\"../..\">$mygrid $meta_designator</A></B> ";
    209         $node_menu .= "<B>&gt;</B>\n";
    210 
    211         if ($physical)
    212         {
    213                 $node_menu .= hiddenvar("p", $physical);
    214         }
    215 
    216         if ( $clustername )
    217         {
    218                 $url = rawurlencode($clustername);
    219                 $node_menu .= "<B><A HREF=\"../../?c=".rawurlencode($clustername)."\">$clustername</A></B> ";
    220                 $node_menu .= "<B>&gt;</B>\n";
    221                 $node_menu .= hiddenvar("c", $clustername);
    222         }
    223 
    224         if (!count($metrics))
    225         {
    226                 echo "<h4>Cannot find any metrics for selected cluster \"$clustername\", exiting.</h4>\n";
    227                 echo "Check ganglia XML tree (telnet $ganglia_ip $ganglia_port)\n";
    228                 exit;
    229         }
    230         reset($metrics);
    231         $firsthost = key($metrics);
    232 
    233         $mmfh   = array();
    234 
    235         $mmfh   = $metrics[$firsthost];
    236 
    237         $context_metrics        = array();
    238 
    239         //foreach ($mmfh as $mm => $mfoo)
    240         foreach( $mmfh as $mm => $bla )
    241         {
    242                 $context_metrics[] = $mm;
    243         }
    244 
    245         foreach ($reports as $mr => $mfoo)
    246                 $context_metrics[] = $mr;
    247 
    248         $node_menu .= "<B><A HREF=\"./?c=".rawurlencode($clustername)."\">Joblist</A></B> ";
    249 
    250         if( isset( $hostname ) && ( $view != 'host' ) )
    251         {
    252                 $node_menu .= "<B>&gt;</B>\n";
    253                 $href = "<A HREF=\"./?c=".rawurlencode($clustername)."&h=".$hostname."\">";
    254                 $node_menu .= "<B>$href";
    255                 $node_menu .= "host: $hostname</A></B> ";
    256         }
    257 
    258         if( count( $filter ) > 0 && $view != "search" )
    259         {
    260                 $my_ct = 1;
    261                 $filter_nr = count( $filter );
    262 
    263                 foreach( $filter as $filtername=>$filterval )
    264                 {
    265                         $node_menu .= "<B>&gt;</B>\n";
    266 
    267                         $href = "<A HREF=\"./?c=".rawurlencode($clustername);
    268                         $temp_ct = 0;
    269                         $n_filter = $filter;
    270                         $my_filterorder = "";
    271                         $my_filters = array_keys( $filter );
    272 
    273                         foreach( $n_filter as $n_filtername=>$n_filterval )
    274                         {
    275                                 if( $temp_ct < $my_ct )
    276                                 {
    277                                         $href .= "&". $n_filtername . "=" . $n_filterval;
    278 
    279                                         if( $my_filterorder == "" )
    280                                                 $my_filterorder = $my_filters[$temp_ct];
    281                                         else
    282                                                 $my_filterorder .= "," . $my_filters[$temp_ct];
    283                                 }
    284 
    285                                 $temp_ct++;
    286                         }
    287                         $href .= "&filterorder=$my_filterorder\">";
    288 
    289                         if( $my_ct < $filter_nr )
    290                                 $node_menu .= "<B>$href$filtername: $filterval</A></B> ";
    291                         else
    292                                 $node_menu .= "<B>$filtername: $filterval</B> ";
    293 
    294                         $my_ct++;
    295                 }
    296         }
    297 
    298         $tpl->gotoBlock( "_ROOT" );
    299         $tpl->assignGlobal("view", $view);
    300 
    301         if( array_key_exists( "id", $filter ) or isset($hostname) )
    302         {
    303                 $range = "job";
    304 
    305                 if( $page_call != "host_view" )
    306                 {
    307                         if (is_array($context_metrics) )
    308                         {
    309                                 $metric_menu = "<B>Metric</B>&nbsp;&nbsp;"
    310                                         ."<SELECT NAME=\"m\" OnChange=\"toga_form.submit();\">\n";
    311 
    312                                 sort($context_metrics);
    313                                 foreach( $context_metrics as $k )
    314                                 {
    315                                         $url = rawurlencode($k);
    316                                         $metric_menu .= "<OPTION VALUE=\"$url\" ";
    317                                         if ($k == $metricname )
    318                                                 $metric_menu .= "SELECTED";
    319                                         $metric_menu .= ">$k\n";
    320                                 }
    321                                 $metric_menu .= "</SELECT>\n";
    322                         }
    323 
    324                 }
    325 
    326                 $tpl->assign("metric_menu", $metric_menu );
    327 
    328                 if( $view == "search" or $view == "host" )
    329                 {
    330                         $tpl->newBlock("timeperiod");
    331                         if( is_numeric( $period_start ) )
    332                         {
    333                                 $period_start = epochToDatetime( $period_start );
    334                         }
    335                         if( is_numeric( $period_stop ) )
    336                         {
    337                                 $period_stop = epochToDatetime( $period_stop );
    338                         }
    339                         $tpl->assign("period_start", $period_start );
    340                         $tpl->assign("period_stop", $period_stop );
    341                         $tpl->assign("hostname", $hostname );
    342 
    343                         if( $view == "host" )
    344                         {
    345                                 $tpl->newBlock("hostview");
    346                                 $tpl->assign("job_start", $job_start );
    347                                 $tpl->assign("job_stop", $job_stop );
    348                         }
    349                 }
    350 
    351         }
    352 
    353         if( $view != "search" )
    354         {
    355                 $context_ranges[]="hour";
    356                 $context_ranges[]="day";
    357                 $context_ranges[]="week";
    358                 $context_ranges[]="month";
    359                 $context_ranges[]="year";
    360                 $context_ranges[]="job";
    361 
    362                 $range_menu = "<B>Last</B>&nbsp;&nbsp;" ."<SELECT NAME=\"r\" OnChange=\"toga_form.submit();\">\n";
    363                 foreach ($context_ranges as $v)
    364                 {
    365                         $url=rawurlencode($v);
    366                         $range_menu .= "<OPTION VALUE=\"$url\" ";
    367                         if ($v == $range)
    368                                 $range_menu .= "SELECTED";
    369                         $range_menu .= ">$v\n";
    370                 }
    371                 $range_menu .= "</SELECT>\n";
    372 
    373                 $tpl->assign("range_menu", $range_menu);
    374 
    375         }
    376 
    377         if( $view == "search" or $view == "host" )
    378         {
    379                 $node_menu .= "<B>&gt;</B>\n";
    380                 $node_menu .= "<B>Jobarchive</B> ";
    381                 $form_name = "archive_search_form";
    382                 $tpl->assignGlobal("form_name", $form_name );
    383         }
    384         else
    385         {
    386                 $form_name = "toga_form";
    387                 $tpl->assignGlobal("form_name", $form_name );
    388         }
    389 
    390         if( $JOB_ARCHIVE && $page_call == 'overview' )
    391         {
    392                 $tpl->newBlock( "search" );
    393                 $tpl->assignGlobal( "cluster_url", rawurlencode($clustername) );
    394                 $tpl->assignGlobal( "cluster", $clustername );
    395         }
    396         $tpl->gotoBlock( "_ROOT" );
    397         $tpl->assignGlobal( "cluster", $clustername );
    398         $tpl->assign("node_menu", $node_menu);
    399 
    400         # Make sure that no data is cached..
    401         header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    # Date in the past
    402         header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified
    403         header ("Cache-Control: no-cache, must-revalidate");  # HTTP/1.1
    404         header ("Pragma: no-cache");                          # HTTP/1.0
    405 }
    406113
    407114function makeFooter()
     
    456163        $hostname = $h;
    457164}
     165$ic                     = new ClusterImage( $myData, $clustername );
     166$ic->setBig();
     167$ic->setNoimage();
     168$ic->draw();
     169
     170//printf("%s\n", $ic->getImagemapArea() );
     171
    458172
    459173switch( $view )
     
    461175        case "overview":
    462176
    463                 includeOverview();
     177                //includeOverview();
    464178                break;
    465179
    466180        case "search":
    467181
    468                 includeSearchPage();
     182                //includeSearchPage();
    469183                break;
    470184
    471185        case "host":
    472186
    473                 includeHostPage();
     187                //includeHostPage();
    474188                break;
    475189
    476190        default:
    477191
    478                 includeOverview();
     192                //includeOverview();
    479193                break;
    480194}
     
    488202$tpl->assign("cluster", $clustername );
    489203
     204session_start();
     205$tpl->assign( "session_name", session_name() );
     206$tpl->assign( "session_id", session_id() );
     207
     208$rjqj_str .= "./graph.php?z=small&c=$clustername&g=job_report&r=$range&st=$cluster[LOCALTIME]";
     209
     210$tpl->assign( "rjqj_graph", $rjqj_str );
     211$tpl->assign( "uue_clustername", rawurlencode($clustername) );
     212
     213$tpl->assign( "node_area_map", $ic->getImagemapArea() );
     214
    490215switch( $view )
    491216{
    492217        case "overview":
    493218
    494                 include "./overview.php";
    495                 makeOverview();
     219                //include "./overview.php";
     220                //makeOverview();
    496221                break;
    497222
    498223        case "search":
    499224
    500                 include "./search.php";
    501                 makeSearchPage();
     225                //include "./search.php";
     226                //makeSearchPage();
    502227                break;
    503228
    504229        case "host":
    505230
    506                 include "./host_view.php";
    507                 makeHostView();
     231                //include "./host_view.php";
     232                //makeHostView();
    508233                break;
    509234
    510235        default:
    511236
    512                 makeOverview();
     237                //makeOverview();
    513238                break;
    514239}
Note: See TracChangeset for help on using the changeset viewer.