Changeset 798 for branches/0.4/web


Ignore:
Timestamp:
04/06/13 18:09:15 (11 years ago)
Author:
ramonb
Message:
  • rewrote cpu_report to include Now/Min/Avg/Max? values in both current and archive RRDs
Location:
branches/0.4/web/addons/job_monarch
Files:
3 edited

Legend:

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

    r797 r798  
    161161        {
    162162
    163             if( $def_nr == 0 )
    164             {
    165 
    166                 $user_str = ":'User CPU'";
    167                 $nice_str = ":'Nice CPU'";
    168                 $system_str = ":'System CPU'";
    169                 $wio_str = ":'WAIT CPU'";
    170                 $idle_str = ":'Idle CPU'";
    171             }
    172             else
    173             {
    174 
    175                 $user_str = "";
    176                 $nice_str = "";
    177                 $system_str = "";
    178                 $wio_str = "";
    179                 $idle_str = "";
    180             }
    181 
    182163            $series .= "DEF:'cpu_user${def_nr}'='${rrd_dir}/cpu_user.rrd':'sum':AVERAGE "
    183164                ."DEF:'cpu_nice${def_nr}'='${rrd_dir}/cpu_nice.rrd':'sum':AVERAGE "
    184165                ."DEF:'cpu_system${def_nr}'='${rrd_dir}/cpu_system.rrd':'sum':AVERAGE "
    185166                ."DEF:'cpu_idle${def_nr}'='${rrd_dir}/cpu_idle.rrd':'sum':AVERAGE "
    186                 ."AREA:'cpu_user${def_nr}'#".$conf['cpu_user_color']."${user_str} "
    187                 ."STACK:'cpu_nice${def_nr}'#".$conf['cpu_nice_color']."${nice_str} "
    188                 ."STACK:'cpu_system${def_nr}'#".$conf['cpu_system_color']."${system_str} ";
    189 
    190             if (file_exists("$rrd_dir/cpu_wio.rrd"))
    191             {
    192                 $series .= "DEF:'cpu_wio${def_nr}'='${rrd_dir}/cpu_wio.rrd':'sum':AVERAGE "
    193                     ."STACK:'cpu_wio${def_nr}'#".$conf['cpu_wio_color']."${wio_str} ";
    194             }
    195 
    196             $series .= "STACK:'cpu_idle${def_nr}'#".$conf['cpu_idle_color']."${idle_str} ";
     167                ."DEF:'cpu_wio${def_nr}'='${rrd_dir}/cpu_wio.rrd':'sum':AVERAGE ";
     168
     169            if( $conf['graphreport_stats'] )
     170            {
     171                $series .= "CDEF:cpu_user${def_nr}_nonans=cpu_user${def_nr},UN,0,cpu_user${def_nr},IF ";
     172                $series .= "CDEF:cpu_nice${def_nr}_nonans=cpu_nice${def_nr},UN,0,cpu_nice${def_nr},IF ";
     173                $series .= "CDEF:cpu_system${def_nr}_nonans=cpu_system${def_nr},UN,0,cpu_system${def_nr},IF ";
     174                $series .= "CDEF:cpu_wio${def_nr}_nonans=cpu_wio${def_nr},UN,0,cpu_wio${def_nr},IF ";
     175                $series .= "CDEF:cpu_idle${def_nr}_nonans=cpu_idle${def_nr},UN,0,cpu_idle${def_nr},IF ";
     176            }
    197177
    198178            $def_nr++;
     179        }
     180
     181
     182        if( $conf['graphreport_stats'] )
     183        {
     184            $s_last     = $def_nr - 1;
     185            $user_sum   = "CDEF:cpu_user=cpu_user0_nonans";
     186            $nice_sum   = "CDEF:cpu_nice=cpu_nice0_nonans";
     187            $system_sum = "CDEF:cpu_system=cpu_system0_nonans";
     188            $wio_sum    = "CDEF:cpu_wio=cpu_wio0_nonans";
     189            $idle_sum   = "CDEF:cpu_idle=cpu_idle0_nonans";
     190
     191            if( $s_last > 1 )
     192            {
     193                foreach (range(1, ($s_last)) as $print_nr )
     194                {
     195                    $user_sum   .= ",cpu_user{$print_nr}_nonans,+";
     196                    $nice_sum   .= ",cpu_nice{$print_nr}_nonans,+";
     197                    $system_sum .= ",cpu_system{$print_nr}_nonans,+";
     198                    $wio_sum    .= ",cpu_wio{$print_nr}_nonans,+";
     199                    $idle_sum   .= ",cpu_idle{$print_nr}_nonans,+";
     200                }
     201            }
     202
     203            $user_sum .= " ";
     204            $nice_sum .= " ";
     205            $system_sum .= " ";
     206            $wio_sum .= " ";
     207            $idle_sum .= " ";
     208
     209            $series .= $user_sum . $nice_sum . $system_sum . $wio_sum . $idle_sum;
     210
     211            $report_names = array( "user", "nice", "system", "wio", "idle" );
     212
     213            $r_count = 0;
     214
     215            foreach( $report_names as $r )
     216            {
     217                if( $r_count == 0 )
     218                {
     219                    $graph_str = "AREA";
     220                    $legend_str = ucfirst( $r );
     221                }
     222                else
     223                {
     224                    $graph_str = "STACK";
     225                }
     226                foreach (range(0, ($s_last)) as $print_nr )
     227                {
     228                    $series .= "${graph_str}:'cpu_${r}${print_nr}'#".$conf['cpu_'.${r}.'_color'].":'${legend_str}\g' ";
     229                }
     230
     231                $series .= "VDEF:'${r}_last'=cpu_${r},LAST ";
     232                $series .= "VDEF:'${r}_min'=cpu_${r},MINIMUM ";
     233                $series .= "VDEF:'${r}_avg'=cpu_${r},AVERAGE ";
     234                $series .= "VDEF:'${r}_max'=cpu_${r},MAXIMUM ";
     235
     236                $spacefill = '';
     237
     238                $spacesize = 6-strlen($r);
     239                foreach ( range( 0, $spacesize ) as $whatever )
     240                {
     241                    $spacefill .= ' ';
     242                }
     243
     244                $series .= "GPRINT:'${r}_last':'${spacefill}Now\:%6.1lf%s' "
     245                        . "GPRINT:'${r}_min':'${space1}Min\:%6.1lf%s${eol1}' "
     246                        . "GPRINT:'${r}_avg':'${space2}Avg\:%6.1lf%s' "
     247                        . "GPRINT:'${r}_max':'${space1}Max\:%6.1lf%s\\l' ";
     248            }
     249        }
     250        else
     251        {
     252            $series .= "AREA:'cpu_user${def_nr}'#".$conf['cpu_user_color']."${user_str} "
     253                    ."STACK:'cpu_nice${def_nr}'#".$conf['cpu_nice_color']."${nice_str} "
     254                    ."STACK:'cpu_system${def_nr}'#".$conf['cpu_system_color']."${system_str} "
     255                    ."STACK:'cpu_wio${def_nr}'#".$conf['cpu_wio_color']."${wio_str} "
     256                    ."STACK:'cpu_idle${def_nr}'#".$conf['cpu_idle_color']."${idle_str} ";
    199257        }
    200258
  • branches/0.4/web/addons/job_monarch/overview.php

    r796 r798  
    11461146                    $cell    = "<td class=$class>".  "<b><a href=$host_link>$host</a></b><br>".  "<i>$metricname:</i> <b>$textval</b></td>";
    11471147                } else {
    1148                     $cell    = "<A HREF=\"$host_link\">" . "<IMG SRC=\"./graph.php?$graphargs\" " . "ALT=\"$host\" BORDER=0  WIDTH=381 HEIGHT=148></A>";
     1148                    $cell    = "<A HREF=\"$host_link\">" . "<IMG SRC=\"./graph.php?$graphargs\" " . "ALT=\"$host\" BORDER=0></A>";
    11491149                }
    11501150
  • branches/0.4/web/addons/job_monarch/templates/host_view.tpl

    r759 r798  
    5454<TD ALIGN="CENTER" VALIGN="TOP" WIDTH="395">
    5555<div id="monarchimage">
    56 <IMG ALT="{$cluster_url} LOAD" SRC="./graph.php?g=load_report&z=overview-medium&c={$cluster_url}&{$graphargs}" WIDTH=381 HEIGHT=148>
    57 <IMG ALT="{$cluster_url} MEM" SRC="./graph.php?g=mem_report&z=overview-medium&c={$cluster_url}&{$graphargs}" WIDTH=381 HEIGHT=148>
    58 <IMG ALT="{$cluster_url} CPU" SRC="./graph.php?g=cpu_report&z=overview-medium&c={$cluster_url}&{$graphargs}" WIDTH=381 HEIGHT=148>
    59 <IMG ALT="{$cluster_url} NETWORK" SRC="./graph.php?g=network_report&z=overview-medium&c={$cluster_url}&{$graphargs}" WIDTH=381 HEIGHT=148>
    60 <IMG ALT="{$cluster_url} PACKETS" SRC="./graph.php?g=packet_report&z=overview-medium&c={$cluster_url}&{$graphargs}" WIDTH=381 HEIGHT=148>
     56<IMG ALT="{$cluster_url} LOAD" SRC="./graph.php?g=load_report&z=overview-medium&c={$cluster_url}&{$graphargs}">
     57<IMG ALT="{$cluster_url} MEM" SRC="./graph.php?g=mem_report&z=overview-medium&c={$cluster_url}&{$graphargs}">
     58<IMG ALT="{$cluster_url} CPU" SRC="./graph.php?g=cpu_report&z=overview-medium&c={$cluster_url}&{$graphargs}">
     59<IMG ALT="{$cluster_url} NETWORK" SRC="./graph.php?g=network_report&z=overview-medium&c={$cluster_url}&{$graphargs}">
     60<IMG ALT="{$cluster_url} PACKETS" SRC="./graph.php?g=packet_report&z=overview-medium&c={$cluster_url}&{$graphargs}">
    6161</div>
    6262</TD>
Note: See TracChangeset for help on using the changeset viewer.