Changeset 648 for trunk


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
Location:
trunk/web/addons/job_monarch
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/job_monarch/clusterconf/gina-example.php

    r532 r648  
    11<?php
    22//
    3 $SORTBY_HOSTNAME = "v{x}-{y}.gina.sara.nl";
     3//$SORTBY_HOSTNAME = "v{x}-{y}.gina.sara.nl";
     4$SORTBY_HOSTNAME = "{x}-{y}.gina.sara.nl";
    45$SORT_ORDER = "asc";
    56
  • trunk/web/addons/job_monarch/conf.php

    r573 r648  
    7575// [syntax: <ip>:<port>]
    7676//
    77 $DATA_SOURCE = '127.0.0.1:8651';
     77$DATA_SOURCE = '127.0.0.1:8652';
    7878
    7979// Is there a jobarchive?
  • trunk/web/addons/job_monarch/image.php

    r646 r648  
    2323 */
    2424
    25 ini_set("memory_limit","200M");
     25ini_set("memory_limit","1G");
    2626set_time_limit(0);
    2727
     
    3333}
    3434
    35 function makeSession()
    36 {
    37         $ds             = new DataSource();
    38         $myxml_data     = &$ds->getData();
    39 
    40         unset( $_SESSION['data'] );
    41 
    42         $_SESSION['data']               = &$myxml_data;
    43         $_SESSION['gather_time']        = time();
    44 }
    45 
    46 global $session_active, $_SESSION, $myxml_data;
    47 
    48 function checkSessionPollInterval( $poll_interval )
    49 {
    50         global $session_active, $_SESSION;
    51 
    52         if( ! session_active )
    53         {
    54                 return 0;
    55         }
    56 
    57         if( isset( $_SESSION['poll_interval'] ) )
    58         {
    59                 if( $poll_interval <> $_SESSION['poll_interval'] )
    60                 {
    61                         $_SESSION['poll_interval']      = $poll_interval;
    62                 }
    63         }
    64         else
    65         {
    66                 $_SESSION['poll_interval']      = $poll_interval;
    67         }
    68 
    69         session_write_close();
    70 
    71         $session_active = false;
    72 }
    73 
    74 function checkSession()
    75 {
    76         global $session_active, $_SESSION;
    77 
    78         session_start();
    79 
    80         $session_active         = true;
    81 
    82         // I got nothing; create session
    83         //
    84         if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) )
    85         {
    86                 makeSession();
    87 
    88                 return 0;
    89         }
    90 
    91         if( isset( $_SESSION['poll_interval'] ) )
    92         {
    93                 $gather_time    = $_SESSION['gather_time'];
    94                 $poll_interval  = $_SESSION['poll_interval'];
    95 
    96                 $cur_time       = time();
    97 
    98                 // If poll_interval time elapsed since last update; recreate session
    99                 //
    100                 if( ($cur_time - $gather_time) >= $poll_interval )
    101                 {
    102                         makeSession();
    103 
    104                         return 0;
    105                 }
    106         }
    107 }
    108 
    109 checkSession();
    110 $myxml_data     = &$_SESSION['data'];
    111 session_write_close();
    112 
    11335$httpvars       = new HTTPVariables( $HTTP_GET_VARS, $_GET );
    11436$view           = $httpvars->getHttpVar( "view" );
     
    11638$query          = $httpvars->getHttpVar( "query" );
    11739$clustername    = $httpvars->getClusterName();
     40
     41global $mySession, $myData, $myXML;
     42
     43//printf( "c %s\n", $clustername );
     44
     45$mySession      = new SessionHandler( $clustername );
     46$mySession->checkSession();
     47
     48$session        = &$mySession->getSession();
     49$myXML          = $session['data'];
     50
     51$myData         = new DataGatherer( $clustername );
     52$myData->parseXML( $myXML );
     53
     54$mySession->updatePollInterval( $myData->getPollInterval() );
     55$mySession->endSession();
     56
     57//printf( "%s\n", strlen( $myXML ) );
    11858
    11959if( isset($jid) && ($jid!='')) $filter['jid']=$jid;
     
    12464if( isset($query) && ($query!='')) $filter['query']=$query;
    12565
    126 $data_gatherer  = new DataGatherer( $clustername );
    127 $data_gatherer->parseXML( &$myxml_data );
    128 
    12966function drawHostImage()
    13067{
    131         global $clustername, $hostname, $data_gatherer;
     68        global $clustername, $hostname, $myData;
    13269
    133         if( $data_gatherer->isJobmonRunning() )
     70        if( $myData->isJobmonRunning() )
    13471        {
    135                 $ic = new HostImage( $data_gatherer, $clustername, $hostname );
     72                $ic = new HostImage( $myData, $clustername, $hostname );
    13673        }
    13774        else
     
    14582function drawSmallClusterImage()
    14683{
    147         global $clustername, $data_gatherer, $myxml_data;
     84        global $clustername, $myData, $myXML;
    14885
    149         if( $data_gatherer->isJobmonRunning() )
     86        //printf( "%s\n", strlen( $myXML ) );
     87
     88        if( $myData->isJobmonRunning() )
    15089        {
    151                 $ic = new ClusterImage( $myxml_data, $clustername );
     90                //$ic = new ClusterImage( $myXML, $clustername );
     91                $ic = new ClusterImage( $myData, $clustername );
    15292                $ic->setSmall();
     93                //printf( "is running\n" );
    15394        }
    15495        else
    15596        {
    15697                $ic = new EmptyImage();
     98                //printf( "not running\n" );
    15799        }
    158100
     
    162104function drawBigClusterImage()
    163105{
    164         global $filter, $clustername, $myxml_data;
     106        global $filter, $clustername, $myXML, $myData;
    165107
    166         $ic = new ClusterImage( $myxml_data, $clustername );
     108        //$ic = new ClusterImage( $myXML, $clustername );
     109        $ic = new ClusterImage( $myData, $clustername );
    167110        $ic->setBig();
    168111
  • 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}
  • trunk/web/addons/job_monarch/jobstore.php

    r646 r648  
    11<?php
    22
    3 ini_set("memory_limit","200M");
     3ini_set("memory_limit","1G");
    44set_time_limit(0);
     5
     6//ini_set("xdebug.profiler_output_dir","/tmp");
     7//ini_set("xdebug.profiler_output_name","timestamp");
     8//ini_set("xdebug.profiler_enable","1");
    59
    610$c                      = $_POST['c'];
     
    5357$_GET['c']              = $c;
    5458
    55 global $c, $clustername, $cluster;
     59global $c, $clustername, $cluster, $mySession;
    5660
    5761include_once "./libtoga.php";
    5862
    59 function makeSession()
    60 {
    61         $ds             = new DataSource();
    62         $myxml_data     = &$ds->getData();
    63 
    64         unset( $_SESSION['data'] );
    65 
    66         $_SESSION['data']               = &$myxml_data;
    67         $_SESSION['gather_time']        = time();
    68 }
    69 
    70 global $session_active, $_SESSION;
    71 
    72 function checkSessionPollInterval( $poll_interval )
    73 {
    74         global $session_active, $_SESSION;
    75 
    76         if( ! session_active )
    77         {
    78                 return 0;
    79         }
    80 
    81         if( isset( $_SESSION['poll_interval'] ) )
    82         {
    83                 if( $poll_interval <> $_SESSION['poll_interval'] )
    84                 {
    85                         $_SESSION['poll_interval']      = $poll_interval;
    86                 }
    87         }
    88         else
    89         {
    90                 $_SESSION['poll_interval']      = $poll_interval;
    91         }       
    92 
    93         session_write_close();
    94 
    95         $session_active = false;
    96 }
    97 
    98 function checkSession()
    99 {
    100         global $session_active, $_SESSION;
    101 
    102         session_start();
    103 
    104         $session_active         = true;
    105 
    106         // I got nothing; create session
    107         //
    108         if( ! isset( $_SESSION['gather_time'] ) || ! isset( $_SESSION['data'] ) )
    109         {
    110                 makeSession();
    111 
    112                 return 0;       
    113         }
    114 
    115         if( isset( $_SESSION['poll_interval'] ) )
    116         {
    117                 $gather_time    = $_SESSION['gather_time'];
    118                 $poll_interval  = $_SESSION['poll_interval'];
    119 
    120                 $cur_time       = time();
    121 
    122                 // If poll_interval time elapsed since last update; recreate session
    123                 //
    124                 if( ($cur_time - $gather_time) >= $poll_interval )
    125                 {
    126                         makeSession();
    127 
    128                         return 0;       
    129                 }
    130         }
    131 }
    132 
    133 checkSession();
    134 
    135 global $jobs, $metrics;
    136 
    137 $data_gatherer  = new DataGatherer( $clustername );
    138 $data_gatherer->parseXML( &$_SESSION['data'] );
    139 
    140 $heartbeat      = &$data_gatherer->getHeartbeat();
    141 $jobs           = &$data_gatherer->getJobs();
    142 //$gnodes         = $data_gatherer->getNodes();
    143 $cpus           = &$data_gatherer->getCpus();
    144 $use_fqdn       = &$data_gatherer->getUsingFQDN();
     63
     64global $jobs, $metrics, $session;
     65
     66//printf( "c %s\n", $clustername );
     67
     68$mySession      = new SessionHandler( $clustername );
     69$mySession->checkSession();
     70
     71$session        = &$mySession->getSession();
     72$myXML          = $session['data'];
     73
     74//printf( "gt %s\n", $session['gather_time'] );
     75//printf( "pi %s\n", $session['poll_interval'] );
     76
     77$myData         = new DataGatherer( $clustername );
     78$myData->parseXML( $myXML );
     79
     80$mySession->updatePollInterval( $myData->getPollInterval() );
     81//printf( "pi %s\n", $myData->getPollInterval() );
     82//printf( "pi %s\n", $session['poll_interval'] );
     83$mySession->endSession();
     84
     85
     86$heartbeat      = &$myData->getHeartbeat();
     87$jobs           = &$myData->getJobs();
     88$cpus           = &$myData->getCpus();
     89$use_fqdn       = &$myData->getUsingFQDN();
     90
     91//print_r( $jobs );
     92
     93//print_r( $session );
    14594
    14695// The ext grid script will send  a task field which will specify what it wants to do
     
    518467{
    519468        global $jobs, $jobids, $clustername, $metrics, $jid, $p_metricname;
    520         global $always_timestamp, $always_constant;
     469        global $always_timestamp, $always_constant, $mySession;
    521470
    522471        $display_nodes  = array();
     
    566515                $poll_interval  = (int) $jobs[$jid]['poll_interval'];
    567516
    568                 checkSessionPollInterval( $poll_interval );
     517                //$mySession->updatePollInterval( $poll_interval );
    569518
    570519                $time           = time();
     
    636585        global $jobs, $hearbeat, $pstart, $pend;
    637586        global $sortfield, $sortorder, $query, $host;
    638         global $jid, $owner, $queue,  $status;
     587        global $jid, $owner, $queue,  $status, $mySession;
    639588
    640589        $job_count              = count( $jobs );
     
    686635                $poll_interval          = (int) $jobs[$jobid]['poll_interval'];
    687636
    688                 checkSessionPollInterval( $poll_interval );
     637                //$mySession->updatePollInterval( $poll_interval );
    689638
    690639                if( $jr['status'] == 'R' )
  • trunk/web/addons/job_monarch/libtoga.php

    r602 r648  
    137137}
    138138
     139class SessionHandler
     140{
     141        var $cluster, $poll_stored;
     142
     143        function SessionHandler( $cluster )
     144        {
     145                $this->cluster          = $cluster;
     146                $this->ds               = new DataSource( $this->cluster );
     147
     148                //ob_start();
     149                session_start();
     150        }
     151
     152        function refreshSession()
     153        {
     154                $ds                     = &$this->ds;
     155                $myxml_data             = $ds->getData();
     156
     157                $_SESSION['data']               = &$myxml_data;
     158                $_SESSION['gather_time']        = time();
     159        }
     160
     161        function hasSession()
     162        {
     163                return ( $this->have_session );
     164        }
     165
     166        function getSession()
     167        {
     168                return $_SESSION;
     169
     170        }
     171
     172        function endSession()
     173        {
     174                session_write_close();
     175                //ob_end_flush();
     176                //session_unlock();
     177                //session_destroy();
     178        }
     179
     180        function updatePollInterval( $poll_interval )
     181        {
     182                //if( ! isset( $_SESSION['poll_interval'] ) )
     183                //{
     184                        $_SESSION['poll_interval']      = $poll_interval;
     185                //}
     186        }
     187
     188        function checkSession()
     189        {
     190                // I got nothing; create session
     191                //
     192                //if( ! $this->have_session )
     193                //{
     194                //      $this->refreshSession();
     195                //
     196                //      return 0;
     197                //}
     198
     199                //if( $this->poll_stored )
     200                //{
     201                //      session_start();
     202
     203                        if( isset( $_SESSION['gather_time'] ) && isset( $_SESSION['poll_interval'] ) )
     204                        {
     205
     206                                $gather_time    = $_SESSION['gather_time'];
     207                                $poll_interval  = $_SESSION['poll_interval'];
     208
     209                                // If poll_interval time elapsed since last update; recreate session
     210                                //
     211                                if( (time() - $gather_time) >= $poll_interval )
     212                                {
     213                                        $this->refreshSession();
     214                                }
     215                        }
     216                        else
     217                        {
     218                                $this->refreshSession();
     219                        }
     220                //}
     221        }
     222}
    139223
    140224class TarchDbase
     
    459543        var $data, $ip, $port;
    460544
    461         function DataSource()
     545        function DataSource( $cluster )
    462546        {
    463547                global $DATA_SOURCE;
     
    470554                $this->ip       = $ds_ip;
    471555                $this->port     = $ds_port;
    472 
     556                $this->cluster  = $cluster;
    473557        }
    474558
     
    487571                }
    488572
     573                $clustername    = $this->cluster;
     574
     575                $rc = fputs($fp, "/$clustername"."\n" );
     576
     577                if (!$rc)
     578                {
     579                        echo "Could not sent request to gmetad: $errstr";
     580                        return;
     581                }
     582
    489583                stream_set_timeout( $fp, 30 );
    490584
     
    515609                $this->xmlhandler       = new TorqueXMLHandler( $this->cluster );
    516610
     611                xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
    517612                xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) );
    518613
     
    521616                        $error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( $this->parser ) ), xml_get_current_line_number( $this->parser ) );
    522617                }
     618        }
     619
     620        function getPollInterval()
     621        {
     622                $handler = $this->xmlhandler;
     623                //printf("d i %s\n", $handler->getPollInterval() );
     624
     625                return $handler->getPollInterval();
    523626        }
    524627
     
    555658        function getJobs()
    556659        {
    557                 $handler = $this->xmlhandler;
    558                 return $handler->getJobs();
     660                $handler = &$this->xmlhandler;
     661                return ( $handler->getJobs() );
    559662        }
    560663
     
    593696                $this->fqdn             = 0;
    594697                $this->fqdnFound        = 0;
     698                $this->pollinterval     = 0;
     699        }
     700
     701        function getPollInterval()
     702        {
     703                //printf( "t pi %s\n", $this->pollinterval );
     704                return ( $this->pollinterval );
    595705        }
    596706
     
    621731                if (isset( $this->heartbeat['time'] ))
    622732                {
    623                         return 1;
     733                        return true;
    624734                }
    625735                else
    626736                {
    627                         return 0;
     737                        return false;
    628738                }
    629739        }
     
    633743                // Should hostname be FQDN or short w/o domain
    634744                //
    635                 $nodes = &$this->nodes;
     745                //$nodes = &$this->nodes;
    636746
    637747                $domain_len     = 0 - strlen( $tdomain );
     
    640750                {
    641751                        if( substr( $thostname, $domain_len ) != $tdomain )
     752                        //if( strpos( $thostname, $tdomain ) !== false )
    642753                        {
    643754                                $thostname = $thostname . '.'.$tdomain;
     
    650761        function startElement( $parser, $name, $attrs )
    651762        {
    652                 $jobs = $this->jobs;
    653                 $nodes = $this->nodes;
     763                $jobs   = $this->jobs;
     764                $nodes  = $this->nodes;
    654765
    655766                if ( $attrs['TN'] )
     
    664775                $jobid = null;
    665776
    666                 if( $name == 'CLUSTER' )
    667                 {
    668                         $this->proc_cluster = $attrs['NAME'];
    669                 }
    670                 else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
     777                //if( $name == 'CLUSTER' )
     778                //{
     779                //      $this->proc_cluster = $attrs['NAME'];
     780                //}
     781                //else if( $name == 'HOST' and $this->proc_cluster == $this->clustername)
     782                if( $name == 'HOST' )
    671783                {
    672784                        $hostname = $attrs['NAME'];
     
    698810                        }
    699811                }
    700                 else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
    701                 {
    702                         if( strstr( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) )
     812                //else if( $name == 'METRIC' and strstr( $attrs['NAME'], 'MONARCH' ) and $this->proc_cluster == $this->clustername )
     813                else if( ($name == 'METRIC') && (strpos( $attrs['NAME'], 'MONARCH' ) !== false) )
     814                {
     815                        if( strpos( $attrs['NAME'], 'MONARCH-HEARTBEAT' ) !== false )
    703816                        {
    704817                                $this->heartbeat['time'] = $attrs['VAL'];
    705818                        }
    706                         else if( strstr( $attrs['NAME'], 'MONARCH-DOWN' ) )
     819                        else if( strpos( $attrs['NAME'], 'MONARCH-DOWN' ) !== false)
    707820                        {
    708821                                $fields         = explode( ' ', $attrs['VAL'] );
     
    717830                                        $toganame       = $togavalues[0];
    718831                                        $togavalue      = $togavalues[1];
     832
    719833
    720834                                        if( $toganame == 'nodes' )
     
    746860                                }
    747861                        }
    748                         else if( strstr( $attrs['NAME'], 'MONARCH-OFFLINE' ) )
     862                        else if( strpos( $attrs['NAME'], 'MONARCH-OFFLINE' ) !== false )
    749863                        {
    750864                                $fields         = explode( ' ', $attrs['VAL'] );
     
    788902                                }
    789903                        }
    790                         else if( strstr( $attrs['NAME'], 'MONARCH-JOB' ) )
     904                        else if( strpos( $attrs['NAME'], 'MONARCH-JOB' ) !== false )
    791905                        {
    792906                                sscanf( $attrs['NAME'], 'MONARCH-JOB-%d-%d', $jobid, $monincr );
     
    805919                                        $toganame = $togavalues[0];
    806920                                        $togavalue = $togavalues[1];
     921
     922                                        //printf( "tn %s\n", $toganame );
    807923
    808924                                        if( $toganame == 'nodes' )
     
    830946                                                        $jobs[$jobid][$toganame] = $togavalue;
    831947                                                }
     948                                        }
     949                                        else if( $toganame == 'poll_interval' )
     950                                        {
     951                                                $this->pollinterval     = $togavalue;
     952                                                //printf("u pi %s\n", $togavalue );
    832953                                        }
    833954                                        else
     
    13521473        var $filtername, $filters;
    13531474
    1354         function ClusterImage( $data, $clustername )
    1355         {
    1356                 $this->dataget          = new DataGatherer( $clustername );
    1357                 $this->data             = $data;
     1475        function ClusterImage( $datag, $clustername )
     1476        {
     1477                //$this->dataget                = new DataGatherer( $clustername );
     1478                $this->dataget          = $datag;
     1479                //$this->data           = $data;
    13581480                $this->clustername      = $clustername;
    13591481                $this->filters          = array();
     
    15031625                }
    15041626
    1505                 $mydatag = $this->dataget;
    1506                 $mydatag->parseXML( $this->data );
     1627                $mydatag                = &$this->dataget;
     1628                //$mydatag->parseXML( $this->data );
    15071629
    15081630                if( $this->isSmall() )
     
    15181640
    15191641                $nodes          = $mydatag->getNodes();
     1642                //print_r( $nodes);
    15201643                $nodes_hosts    = array_keys( $nodes );
    15211644
     
    15561679                $this->height   = ($y_offset + (($node_rows*$node_width)+1) );
    15571680
    1558                 $jobs = $mydatag->getJobs();
     1681                $jobs           = $mydatag->getJobs();
    15591682                $filtered_nodes = $this->filterNodes( $jobs, $nodes );
    15601683                $selected_host  = $this->selected;
  • trunk/web/addons/job_monarch/overview.php

    r617 r648  
    3535
    3636$ds             = new DataSource();
    37 $myxml_data     = $ds->getData();
     37//$myxml_data   = $ds->getData();
    3838
    3939$data_gatherer  = new DataGatherer( $clustername );
    40 $data_gatherer->parseXML( $myxml_data );
     40//$data_gatherer->parseXML( $myxml_data );
    4141
    4242$heartbeat      = $data_gatherer->getHeartbeat();
  • trunk/web/addons/job_monarch/templates/header.tpl

    r646 r648  
    4747        GraphSummaryWindow.show();
    4848
    49         ClusterImageWindow.html                 = '<IMG ID="clusterimage" SRC="{clusterimage}" USEMAP="#MONARCH_CLUSTER_BIG" BORDER="0">';
     49        ClusterImageWindow.html                 = '<IMG ID="clusterimage" SRC="./image.php?{session_name}={session_id}" USEMAP="#MONARCH_CLUSTER_BIG" BORDER="0">';
    5050        ClusterImageWindow.show();
    5151        setClusterImagePosition();
     
    5959
    6060        Ext.get( 'rjqjgraph' ).update( '<IMG ID="rjqj_graph" SRC="{rjqj_graph}" BORDER=0>' );
    61         Ext.get( 'pie' ).update( '<IMG ID="pie" SRC="{pie}" BORDER=0>' );
     61        //Ext.get( 'pie' ).update( '<IMG ID="pie" SRC="./image.php?{session_name}={session_id}&c={uue_clustername}&view=big-clusterimage" BORDER=0>' );
    6262});
    6363</script>
     
    7373
    7474    <MAP NAME="MONARCH_CLUSTER_BIG">
    75     <!-- START BLOCK : node_clustermap -->
    7675    {node_area_map}
    77     <!-- END BLOCK : node_clustermap -->
    7876    </MAP>
Note: See TracChangeset for help on using the changeset viewer.