Ignore:
Timestamp:
04/06/13 23:32:53 (11 years ago)
Author:
ramonb
Message:
  • fixed packet_report to include values in legend
File:
1 edited

Legend:

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

    r801 r802  
    568568        {
    569569
    570             if( $def_nr == 0 )
    571             {
    572 
    573                 $in_str = ":'In'";
    574                 $out_str = ":'Out'";
    575             }
    576             else
    577             {
    578 
    579                 $in_str = "";
    580                 $out_str = "";
    581             }
    582 
    583             $series .= "DEF:'bytes_in${def_nr}'='${rrd_dir}/pkts_in.rrd':'sum':AVERAGE "
    584                 ."DEF:'bytes_out${def_nr}'='${rrd_dir}/pkts_out.rrd':'sum':AVERAGE "
    585                 ."LINE2:'bytes_in${def_nr}'#".$conf['mem_cached_color']."${in_str} "
    586                 ."LINE2:'bytes_out${def_nr}'#".$conf['mem_used_color']."${out_str} ";
     570            $series .= "DEF:'pkts_in${def_nr}'='${rrd_dir}/pkts_in.rrd':'sum':AVERAGE "
     571                    ."DEF:'pkts_out${def_nr}'='${rrd_dir}/pkts_out.rrd':'sum':AVERAGE ";
     572
     573            $report_names = array( "in", "out" );
     574
     575            if( $conf['graphreport_stats'] )
     576            {
     577                foreach( $report_names as $r )
     578                {
     579                    $series .= "CDEF:pkts_${r}${def_nr}_nonans=pkts_${r}${def_nr},UN,0,pkts_${r}${def_nr},IF ";
     580                }
     581            }
    587582
    588583            $def_nr++;
     584        }
     585
     586        if( $conf['graphreport_stats'] )
     587        {
     588            $s_last     = $def_nr - 1;
     589
     590            foreach( $report_names as $r )
     591            {
     592                $cdef_sum   = "CDEF:pkts_${r}=pkts_${r}0_nonans";
     593
     594                if( $s_last > 1 )
     595                {
     596                    foreach (range(1, ($s_last)) as $print_nr )
     597                    {
     598                        $user_sum   .= ",pkts_${r}{$print_nr}_nonans,+";
     599                    }
     600                }
     601                $cdef_sum .= " ";
     602
     603                $series   .= $cdef_sum;
     604            }
     605
     606            $r_count = 0;
     607
     608            $conf['pkts_out_color'] = $conf['mem_used_color'];
     609            $conf['pkts_in_color']  = $conf['mem_cached_color'];
     610
     611            foreach( $report_names as $r )
     612            {
     613                $legend_str = ucfirst( $r );
     614
     615                $graph_str  = "LINE2";
     616
     617                foreach (range(0, ($s_last)) as $print_nr )
     618                {
     619                    $series .= "${graph_str}:'pkts_${r}${print_nr}'#".$conf['pkts_'.${r}.'_color'].":'${legend_str}\g' ";
     620                    $legend_str = '';
     621                }
     622
     623                $series .= "VDEF:'${r}_last'=pkts_${r},LAST ";
     624                $series .= "VDEF:'${r}_min'=pkts_${r},MINIMUM ";
     625                $series .= "VDEF:'${r}_avg'=pkts_${r},AVERAGE ";
     626                $series .= "VDEF:'${r}_max'=pkts_${r},MAXIMUM ";
     627
     628                $spacefill = '';
     629
     630                $spacesize = 6-strlen($r); // max length 'swapped' = 7
     631                foreach ( range( 0, $spacesize ) as $whatever )
     632                {
     633                    $spacefill .= ' ';
     634                }
     635                $series .= "GPRINT:'${r}_last':'${spacefill}Now\:%6.1lf%s' "
     636                        . "GPRINT:'${r}_min':'${space1}Min\:%6.1lf%s${eol1}' "
     637                        . "GPRINT:'${r}_avg':'${space2}Avg\:%6.1lf%s' "
     638                        . "GPRINT:'${r}_max':'${space1}Max\:%6.1lf%s\\l' ";
     639
     640            }
     641        }
     642        else
     643        {
     644                $series .= "LINE2:'pkts_in${def_nr}'#".$conf['mem_cached_color']."'Packets In' "
     645                        ."LINE2:'pkts_out${def_nr}'#".$conf['mem_used_color']."'Packets Out' ";
    589646        }
    590647
Note: See TracChangeset for help on using the changeset viewer.