Changeset 801 for branches/0.4/web


Ignore:
Timestamp:
04/06/13 23:24:25 (11 years ago)
Author:
ramonb
Message:
  • more fixes
  • added values in legend for network_report
File:
1 edited

Legend:

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

    r800 r801  
    245245                }
    246246
    247                 $series .= "GPRINT:'${r}_last':'${spacefill}Now\:%6.1lf%s' "
    248                         . "GPRINT:'${r}_min':'${space1}Min\:%6.1lf%s${eol1}' "
    249                         . "GPRINT:'${r}_avg':'${space2}Avg\:%6.1lf%s' "
    250                         . "GPRINT:'${r}_max':'${space1}Max\:%6.1lf%s\\l' ";
     247                $series .= "GPRINT:'${r}_last':'${spacefill}Now\:%6.1lf%%' "
     248                        . "GPRINT:'${r}_min':'${space1}Min\:%6.1lf%%${eol1}' "
     249                        . "GPRINT:'${r}_avg':'${space2}Avg\:%6.1lf%%' "
     250                        . "GPRINT:'${r}_max':'${space1}Max\:%6.1lf%%\\l' ";
    251251                       
    252252                $r_count = $r_count + 1;
     
    476476        foreach( $rrd_dirs as $rrd_dir )
    477477        {
    478 
    479             if( $def_nr == 0 )
    480             {
    481 
    482                 $in_str = ":'In'";
    483                 $out_str = ":'Out'";
    484             }
    485             else
    486             {
    487 
    488                 $in_str = "";
    489                 $out_str = "";
    490             }
    491 
    492478            $series .= "DEF:'bytes_in${def_nr}'='${rrd_dir}/bytes_in.rrd':'sum':AVERAGE "
    493                 ."DEF:'bytes_out${def_nr}'='${rrd_dir}/bytes_out.rrd':'sum':AVERAGE "
    494                 ."LINE2:'bytes_in${def_nr}'#".$conf['mem_cached_color']."${in_str} "
    495                 ."LINE2:'bytes_out${def_nr}'#".$conf['mem_used_color']."${out_str} ";
     479                    ."DEF:'bytes_out${def_nr}'='${rrd_dir}/bytes_out.rrd':'sum':AVERAGE ";
     480
     481            $report_names = array( "in", "out" );
     482
     483            if( $conf['graphreport_stats'] )
     484            {
     485                foreach( $report_names as $r )
     486                {
     487                    $series .= "CDEF:bytes_${r}${def_nr}_nonans=bytes_${r}${def_nr},UN,0,bytes_${r}${def_nr},IF ";
     488                }
     489            }
    496490
    497491            $def_nr++;
     492        }
     493
     494        if( $conf['graphreport_stats'] )
     495        {
     496            $s_last     = $def_nr - 1;
     497
     498            foreach( $report_names as $r )
     499            {
     500                $cdef_sum   = "CDEF:bytes_${r}=bytes_${r}0_nonans";
     501
     502                if( $s_last > 1 )
     503                {
     504                    foreach (range(1, ($s_last)) as $print_nr )
     505                    {
     506                        $user_sum   .= ",bytes_${r}{$print_nr}_nonans,+";
     507                    }
     508                }
     509                $cdef_sum .= " ";
     510
     511                $series   .= $cdef_sum;
     512            }
     513
     514            $r_count = 0;
     515
     516            $conf['bytes_out_color'] = $conf['mem_used_color'];
     517            $conf['bytes_in_color']  = $conf['mem_cached_color'];
     518
     519            foreach( $report_names as $r )
     520            {
     521                $legend_str = ucfirst( $r );
     522
     523                $graph_str  = "LINE2";
     524
     525                foreach (range(0, ($s_last)) as $print_nr )
     526                {
     527                    $series .= "${graph_str}:'bytes_${r}${print_nr}'#".$conf['bytes_'.${r}.'_color'].":'${legend_str}\g' ";
     528                    $legend_str = '';
     529                }
     530
     531                $series .= "VDEF:'${r}_last'=bytes_${r},LAST ";
     532                $series .= "VDEF:'${r}_min'=bytes_${r},MINIMUM ";
     533                $series .= "VDEF:'${r}_avg'=bytes_${r},AVERAGE ";
     534                $series .= "VDEF:'${r}_max'=bytes_${r},MAXIMUM ";
     535
     536                $spacefill = '';
     537
     538                $spacesize = 6-strlen($r); // max length 'swapped' = 7
     539                foreach ( range( 0, $spacesize ) as $whatever )
     540                {
     541                    $spacefill .= ' ';
     542                }
     543                $series .= "GPRINT:'${r}_last':'${spacefill}Now\:%6.1lf%s' "
     544                        . "GPRINT:'${r}_min':'${space1}Min\:%6.1lf%s${eol1}' "
     545                        . "GPRINT:'${r}_avg':'${space2}Avg\:%6.1lf%s' "
     546                        . "GPRINT:'${r}_max':'${space1}Max\:%6.1lf%s\\l' ";
     547
     548            }
     549        }
     550        else
     551        {
     552                $series .= "LINE2:'bytes_in${def_nr}'#".$conf['mem_cached_color']."'Bytes In' "
     553                        ."LINE2:'bytes_out${def_nr}'#".$conf['mem_used_color']."'Bytes Out' ";
    498554        }
    499555
     
    763819    }
    764820        $command = $conf['rrdtool']. " graph - --start $start --end $end ".
    765                 "--width $width --height $height $lower_limit ".
     821                "--width $width --height $height $lower_limit $vertical_label ".
    766822                "--title '$title' $extras $background ".
    767823                $series;
     
    770826{
    771827    $command = $conf['rrdtool'] . " graph - --start $period_start --end $period_stop ".
    772                "--width $width --height $height $lower_limit --color BACK#$load_color ".
     828               "--width $width --height $height $lower_limit --color BACK#$load_color $vertical_label ".
    773829               "--title '$title' $extras $background ".
    774830               $series;
Note: See TracChangeset for help on using the changeset viewer.