Changeset 152


Ignore:
Timestamp:
06/21/05 15:01:45 (17 years ago)
Author:
bastiaans
Message:

toga/libtoga.php:

  • Only search jobs in 'F' state

toga/search.php:

  • Fixed form validation

web/addons/toga/graph.php:

  • Added x-grid determination for labels and such along x-axis
Location:
trunk/web/addons/toga
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/toga/graph.php

    r149 r152  
    329329//}
    330330
     331function determineXGrid( $p_start, $p_stop ) {
     332
     333        $period = intval( $p_stop - $p_start );
     334
     335        // Syntax: <minor_grid_lines_time_declr>:<major_grid_lines_time_declr>:<labels_time_declr>:<offset>:<format>
     336        //
     337        // Where each <*time_declr*> = <time_type>:<time_interval>
     338
     339        // Less than 1 minute
     340        if( $period < 60 )
     341
     342                $my_grid = "SECOND:5:SECOND:25:SECOND:25:0:%X";
     343
     344        // Less than 10 minutes
     345        else if( $period < 600 )
     346
     347                $my_grid = "SECOND:50:MINUTE:1:MINUTE:1:0:%X";
     348
     349        // Less than 1 hour
     350        else if( $period < 3600 )
     351
     352                $my_grid = "MINUTE:5:MINUTE:10:MINUTE:10:0:%X";
     353
     354        // Less than 1 day
     355        //
     356        else if( $period < 86400 )
     357
     358                $my_grid = "HOUR:1:HOUR:2:HOUR:2:0:%X";
     359
     360        // Less than 15 days
     361        //
     362        else if( $period < 1296000 )
     363
     364                $my_grid = "HOUR:30:DAY:1:DAY:1:0:%x";
     365               
     366        // Less than 30 days (a month)
     367        //
     368        elseif( $period < 2592000 )
     369
     370                $my_grid = "DAY:5:DAY:10:DAY:10:0:%x";
     371
     372        if( isset( $my_grid ) )
     373
     374                return "--x-grid $my_grid";
     375
     376        else
     377                return "";
     378}
     379
     380$xgrid = determineXGrid( $period_start, $period_stop );
     381
    331382#
    332383# Generate the rrdtool graph command.
     
    334385$command = RRDTOOL . " graph - --start $period_start --end $period_stop ".
    335386        "--width $width --height $height $upper_limit $lower_limit ".
    336         "--title '$title' $vertical_label $extras $background ".
     387        "--title '$title' $vertical_label $extras $background $xgrid ".
    337388        $series;
    338389
  • trunk/web/addons/toga/libtoga.php

    r145 r152  
    108108
    109109                if( $id )
    110                         $query = "SELECT job_id FROM jobs WHERE job_id = '$id'";
     110                        $query = "SELECT job_id FROM jobs WHERE job_id = '$id' AND job_status = 'F'";
    111111                else {
    112112                        $query_args = array();
     
    127127                                $query_args[] = "job_stop_timestamp <= $end_to_time";
    128128
    129                         $query = "SELECT job_id FROM jobs WHERE ";
     129                        $query = "SELECT job_id FROM jobs WHERE job_status = 'F' AND ";
    130130                        $extra_query_args = '';
    131131
  • trunk/web/addons/toga/search.php

    r150 r152  
    1111        $none_set = 0;
    1212
    13         if( $id == '' or $user == '' or $name == '' or $start_from_time == '' or $start_to_time == '' or $queue == '' or $end_from_time == '' or $end_to_time == '') $none_set = 1;
    14 
    15         if (!isset($id) and !isset($user) and !isset($start_from_time) and !isset($start_to_time) and !isset($end_from_time) and !isset($end_to_time) and !isset($queue) ) $none_set = 1;
    16 
    17         if( $none_set == 1 ) {
     13        if( $id == '' and $user == '' and $name == '' and $start_from_time == '' and $start_to_time == '' and $queue == '' and $end_from_time == '' and $end_to_time == '') {
    1814                $error = 1;
    1915                $error_msg = "<FONT COLOR=\"red\"><B>No search criteria set!</B></FONT>";
     16        }
     17
     18        if( !is_numeric($id) and !$error and $id != '') {
     19
     20                $error = 1;
     21                $error_msg = "<FONT COLOR=\"red\"><B>Id must be a number</B></FONT>";
    2022        }
    2123
     
    347349                                                $textval = "$val[VAL] $val[UNITS]";
    348350                                        } else {
    349                                                 $graphargs = "z=small&c=$cluster_url&m=$metricname&h=$host_url&v=$val[VAL]&x=$max&n=$min&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop";
     351                                                $graphargs = "z=small&c=$cluster_url&m=$metricname&h=$host_url&v=$val[VAL]&x=$max&n=$min&job_start=$job_start&job_stop=$job_stop&period_start=$period_start&period_stop=$period_stop&min=$min&max=$max";
    350352                                        }
    351353                                        if ($textval) {
Note: See TracChangeset for help on using the changeset viewer.