Changeset 651 for trunk


Ignore:
Timestamp:
02/04/10 13:57:28 (14 years ago)
Author:
ramonb
Message:
  • PHP4 fixes
Location:
trunk/web/addons/job_monarch
Files:
2 edited

Legend:

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

    r648 r651  
    2323 */
    2424
    25 ini_set("memory_limit","1G");
    26 set_time_limit(0);
     25//ini_set("memory_limit","1G");
     26//set_time_limit(0);
    2727
    2828include_once "./libtoga.php";
     
    4646$mySession->checkSession();
    4747
    48 $session        = &$mySession->getSession();
     48$session        = $mySession->getSession();
    4949$myXML          = $session['data'];
    5050
  • trunk/web/addons/job_monarch/libtoga.php

    r649 r651  
    3434                $this->restvars         = array();
    3535
    36                 $this->clustername      = $httpvars['c'] ? $httpvars['c'] : $getvars['c'];
    37                 $this->metricname       = $httpvars['m'] ? $httpvars['m'] : $getvars['m'];
     36                $this->clustername      = isset( $httpvars['c'] ) ? $httpvars['c'] : $getvars['c'];
     37                $this->metricname       = isset( $httpvars['m'] ) ? $httpvars['m'] : $getvars['m'];
    3838
    3939                if( count( $httpvars ) > 0 )
     
    8484
    8585$CLUSTER_CONFS  = array();
     86
     87ini_set("memory_limit","1024000000");
     88set_time_limit(0);
    8689
    8790// Monarch's conf
     
    559562        function getData()
    560563        {
    561                 $errstr;
    562                 $errno = 0;
    563                 $timeout = 3;
     564                $errstr         = '';
     565                $errno          = 0;
     566                $timeout        = 3;
    564567
    565568                $fp = fsockopen( $this->ip, $this->port, $errno, $errstr, $timeout );
     
    582585
    583586                stream_set_timeout( $fp, 30 );
     587
     588                $data   = '';
    584589
    585590                while ( !feof( $fp ) )
     
    601606        {
    602607                $this->cluster  = $cluster;
    603                 $this->httpvars = $httpvars;
     608                //$this->httpvars = $httpvars;
    604609        }
    605610
    606611        function parseXML( $data )
    607612        {
    608                 $this->parser           = xml_parser_create();
     613                //$this->parser                 = xml_parser_create();
    609614                $this->xmlhandler       = new TorqueXMLHandler( $this->cluster );
    610615
    611                 xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
    612                 xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) );
    613 
    614                 if ( !xml_parse( $this->parser, $data ) )
    615                 {
    616                         $error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( $this->parser ) ), xml_get_current_line_number( $this->parser ) );
    617                 }
     616                preg_match_all( '/<HOST (.*)?>/', $data, $hosts );
     617                unset( $hosts[1] );
     618                preg_match_all( '/<METRIC NAME="MONARCH-(.*)?\>/', $data, $metrics );
     619                unset( $metrics[1] );
     620
     621                //print_r( $metrics );
     622                //print_r( $hosts );
     623
     624                $togas  = $metrics[0];
     625
     626                //print_r( $togas );
     627
     628                foreach( $togas as $mid=>$metric )
     629                {
     630                //      printf( "%s\n", $metric );
     631                        preg_match( '/<METRIC NAME="MONARCH-(.*?)" VAL="(?<toga>\d+)" /', $metric, $toga );
     632                        //print_r( $toga );
     633                }
     634
     635                //xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, 0 );
     636                //xml_parser_set_option( $this->parser, XML_OPTION_SKIP_WHITE, 1 );
     637                //xml_set_element_handler( $this->parser, array( &$this->xmlhandler, 'startElement' ), array( &$this->xmlhandler, 'stopElement' ) );
     638
     639                //if ( !xml_parse( $this->parser, $data ) )
     640                //{
     641                //      $error = sprintf( 'XML error: %s at %d', xml_error_string( xml_get_error_code( $this->parser ) ), xml_get_current_line_number( $this->parser ) );
     642                //}
     643                //xml_parser_free( $this->parser );
    618644        }
    619645
Note: See TracChangeset for help on using the changeset viewer.