Changeset 751 for branches


Ignore:
Timestamp:
03/25/13 21:41:14 (11 years ago)
Author:
ramonb
Message:

job_monarch/libtoga.php:

  • why call Ganglia's get_ganglia.php Gmetad() if we are already parsing ourself
  • now create $metrics ourself while TorqueXMLHandler.parseXML() runs
  • more speedup...

job_monarch/host_view.php,
job_monarch/graph.php:

  • dont need job information, so no DataGatherer?: call get_ganglia.php now for $metrics
Location:
branches/0.4/web/addons/job_monarch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/0.4/web/addons/job_monarch/graph.php

    r739 r751  
    2323 */
    2424
    25 global $metrics, $rrds, $range, $start, $r, $conf, $m;
     25global $rrds, $range, $start, $r, $conf, $m;
    2626$range = $r;
    2727
    2828include "./libtoga.php";
     29
     30$my_dir = getcwd();
     31
     32global $context;
     33
     34$context = 'cluster';
     35
     36chdir( $GANGLIA_PATH );
     37
     38include "./ganglia.php";
     39include "./get_ganglia.php";
     40
     41chdir( $my_dir );
    2942
    3043if ( !empty( $_GET ) )
  • branches/0.4/web/addons/job_monarch/host_view.php

    r740 r751  
    2424
    2525include_once "./libtoga.php";
     26
     27$my_dir = getcwd();
     28
     29global $context;
     30
     31$context = 'cluster';
     32
     33chdir( $GANGLIA_PATH );
     34
     35include "./ganglia.php";
     36include "./get_ganglia.php";
     37
     38chdir( $my_dir );
    2639
    2740function datetimeToEpoch( $datetime )
  • branches/0.4/web/addons/job_monarch/libtoga.php

    r750 r751  
    108108include_once "./eval_conf.php";
    109109include_once "./functions.php";
    110 include_once "./ganglia.php";
    111110include_once "./get_context.php";
    112111
     112global $GLOBALS, $conf, $metrics, $version, $rrdtool_version, $context;
     113
     114// ganglia start
     115$metrics = array();
     116$version = array();
     117
     118$version["webfrontend"] = $GLOBALS["ganglia_version"];
     119
     120# Get rrdtool version
     121$rrdtool_version = array();
     122exec($conf['rrdtool'], $rrdtool_version);
     123$rrdtool_version = explode(" ", $rrdtool_version[0]);
     124$rrdtool_version = $rrdtool_version[1];
     125$version["rrdtool"] = "$rrdtool_version";
     126
     127// ganglia end
     128
    113129$context = 'cluster';
    114 include_once "./get_ganglia.php";
    115130
    116131// Back to our PHP
     
    129144// Ganglia's array of host metrics
    130145//
    131 global $metrics, $hosts_up;
     146global $hosts_up;
    132147global $start;
    133148
     
    554569    }
    555570
     571    function getMetrics()
     572    {
     573        $handler = $this->xmlhandler;
     574        return $handler->getMetrics();
     575    }
    556576    function getNodes()
    557577    {
     
    606626        $this->clusters     = array();
    607627        $this->nodes         = array();
     628        $this->metrics      = array();
    608629        $this->heartbeat     = array();
    609630        $this->down_nodes    = array();
     
    611632        $this->clustername    = $clustername;
    612633        $this->proc_cluster = null;
     634        $this->proc_hostname = null;
    613635        $this->fqdn        = 1;
    614636    }
     
    696718    function startElement( $parser, $name, $attrs )
    697719    {
    698 
    699         if( isset( $attrs['TN'] ) )
    700         {
    701             if ( $attrs['TN'] )
    702             {
    703                 // Ignore dead metrics. Detect and mask failures.
    704                 if ( $attrs['TN'] > $attrs['TMAX'] * 4 )
    705                 {
    706                     return null;
    707                 }
    708             }
    709         }
     720        global $cluster, $metrics;
    710721
    711722        $jobid = null;
     
    713724        if( $name == 'CLUSTER' )
    714725        {
     726            // ganglia start
     727            $cluster = $attrs;
     728            // ganglia end
     729
    715730            $this->proc_cluster = $attrs['NAME'];
    716731            //printf("set proc cluster to %s\n", $attrs['NAME'] );
     
    725740        if( $name == 'HOST' )
    726741        {
     742            // ganglia start
    727743            $hostname = $attrs['NAME'];
     744            $this->proc_hostname = $hostname;
     745
     746            # Pseudo metrics - add useful HOST attributes like gmond_started & last_reported to the metrics list:
     747            $metrics[$hostname]['gmond_started']['NAME'] = "GMOND_STARTED";
     748            $metrics[$hostname]['gmond_started']['VAL'] = $attrs['GMOND_STARTED'];
     749            $metrics[$hostname]['gmond_started']['TYPE'] = "timestamp";
     750            $metrics[$hostname]['last_reported']['NAME'] = "REPORTED";
     751            $metrics[$hostname]['last_reported']['VAL'] = uptime($cluster['LOCALTIME'] - $attrs['REPORTED']);
     752            $metrics[$hostname]['last_reported']['TYPE'] = "string";
     753            $metrics[$hostname]['last_reported_timestamp']['NAME'] = "REPORTED TIMESTAMP";
     754            $metrics[$hostname]['last_reported_timestamp']['VAL'] = $attrs['REPORTED'];
     755            $metrics[$hostname]['last_reported_timestamp']['TYPE'] = "uint32";
     756            $metrics[$hostname]['ip_address']['NAME'] = "IP";
     757            $metrics[$hostname]['ip_address']['VAL'] = $attrs['IP'];
     758            $metrics[$hostname]['ip_address']['TYPE'] = "string";
     759            $metrics[$hostname]['location']['NAME'] = "LOCATION";
     760            $metrics[$hostname]['location']['VAL'] = $attrs['LOCATION'];
     761            $metrics[$hostname]['location']['TYPE'] = "string";
     762            // ganglia end
    728763
    729764            //printf( "host %s\n", $hostname );
     
    736771            return null;
    737772        }
    738         if( $name == 'METRIC' and ( strpos( $attrs['NAME'], 'zplugin_monarch' ) !== false ) )
    739         {
     773
     774        if( $name == 'METRIC' )
     775        {
     776            $hostname = $this->proc_hostname;
     777
     778            // ganglia start
     779            $metricname = rawurlencode($attrs['NAME']);
     780            $metrics[$hostname][$metricname] = $attrs;
     781            // ganglia end
     782
     783            if ( strpos( $attrs['NAME'], 'zplugin_monarch' ) === false )
     784            {
     785                return null;
     786            }
     787
    740788            if( strpos( $attrs['NAME'], 'zplugin_monarch_heartbeat' ) !== false )
    741789            {
Note: See TracChangeset for help on using the changeset viewer.