IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2010, 2:45:13 PM (16 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/ippMonitor/raw/czartool_labels.php

    r29124 r29515  
    2525
    2626menu($myMenu, 'Czartool on '.$lastUpdateTime, 'ipp.css', $ID['link'], $ID['proj']);
    27 
    28 $pass = $ID['pass'];
    29 $proj = $ID['proj'];
    30 $menu = $ID['menu'];
    31 
    32 $selectedStage = $_GET[stage];
    33 $selectedLabel = $_GET[label];
    34 $selectedServer = $_GET[server];
    35 $selectedRevertStage = $_GET[revertstage];
    36 $selectedRevertMode = $_GET[revertmode];
    37 
    38 if ($selectedLabel == "") { $selectedLabel = "all_stdscience_labels"; }
    39 if ($selectedStage == "") { $selectedStage = "all_stages"; }
    40 
    41 $nsStatus = getNightlyScienceStatus($czardb);
    42 echo "<p  align=\"center\"> Current status of the IPP as of $lastUpdateTime (faults are shown in parentheses). <br>Documentation can be found <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\">here</a> and cluster load monitored <a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?r=hour&s=descending&c=IPP%2520Production\">here</a><br>Current nightly science status: $nsStatus</p>";
    43 
    44 
    45 // deal with reverts: turn on or off if requested and pass current revert state for this stage onto labels table later
    46 if ($selectedRevertStage != "" && $selectedRevertMode != "") {
    47 
    48     exec("czartool_revert.pl -t $selectedRevertStage -o $selectedRevertMode", $response, $status);
    49     $currentRevertMode;
    50     if ($response[0] == "off") $currentRevertMode = 0;
    51     else if ($response[0] == "on") $currentRevertMode = 1;
    52 
    53     setRevertStatus($czardb, $selectedRevertStage, $currentRevertMode);
    54 }
    55 $debug = 0;
    56 
    57 $stdsLabels = getLabels($czardb, "stdscience");
    58 $distLabels = getLabels($czardb, "distribution");
    59 $pubLabels = getLabels($czardb, "publishing");
    60 $updateLabels = getLabels($czardb, "update");
    61 
    62 if ($debug) {
    63     echo "prog returned $status, and output:<br>";
    64     for ($i = 0; $i < count($distLabels); $i++) {
    65         echo "$distLabels[$i]<br>";
    66     }
    67 }
    6827
    6928$states=array("full","new","drop","wait");
     
    8241        "summitcopy");
    8342
     43$pass = $ID['pass'];
     44$proj = $ID['proj'];
     45$menu = $ID['menu'];
     46
     47$selectedStage = $_GET[stage];
     48$selectedLabel = $_GET[label];
     49$selectedServer = $_GET[server];
     50$selectedRevertStage = $_GET[revertstage];
     51$selectedRevertMode = $_GET[revertmode];
     52$plotType = $_GET[plottype];
     53$serverCmd = $_GET[servercmd];
     54$allServerCmd = $_GET[allservercmd];
     55
     56if ($selectedLabel == "") { $selectedLabel = "all_stdscience_labels"; }
     57if ($selectedStage == "") { $selectedStage = "all_stages"; }
     58if ($plotType == "") { $plotType = "linear"; }
     59
     60$nsStatus = getNightlyScienceStatus($czardb);
     61$plotTypeLink = ($plotType == "linear") ? "log" : "linear";
     62$link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
     63echo "<p  align=\"center\"> Current status of the IPP as of $lastUpdateTime (faults are shown in parentheses). <br>Documentation can be found <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\">here</a> and cluster load monitored <a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?r=hour&s=descending&c=IPP%2520Production\">here</a><br>Current nightly science status: $nsStatus<br>Use <a href=\"$link\"> $plotTypeLink</a> plots </p>";
     64
     65
     66// deal with reverts: turn on or off if requested and pass current revert state for this stage onto labels table later
     67if ($selectedRevertStage && $selectedRevertMode) turnRevertsOnOff($czardb, $selectedRevertStage, $selectedRevertMode);
     68
     69// tell selected server to stop or run
     70if ($selectedServer && $serverCmd) serverStopRun($czardb, $selectedServer,  $serverCmd);
     71
     72// tell all servers to stop or run
     73if ($allServerCmd) {
     74
     75    foreach ($servers as &$server) serverStopRun($czardb, $server,  $allServerCmd);
     76}
     77
     78
     79$debug = 0;
     80
     81$stdsLabels = getLabels($czardb, "stdscience");
     82$distLabels = getLabels($czardb, "distribution");
     83$pubLabels = getLabels($czardb, "publishing");
     84$updateLabels = getLabels($czardb, "update");
     85
     86if ($debug) {
     87    echo "prog returned $status, and output:<br>";
     88    for ($i = 0; $i < count($distLabels); $i++) {
     89        echo "$distLabels[$i]<br>";
     90    }
     91}
     92
     93
    8494// set up the form
    8595echo "<form action=\"czartool_labels.php\" method=\"POST\">\n";
     
    91101
    92102echo "<table>\n";
    93   echo "<tr>\n";
    94     echo "<td>\n";
    95       echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage\"><br>";
    96     echo "</td>\n";
    97 
    98     echo "<td> \n";
    99       createLabelsTable($pass, $proj, $czardb, "stdscience", $stdsLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage);
    100     echo "</td>\n";
    101   echo "</tr>\n";
    102 
    103   echo "<tr>\n";
    104     echo "<td>\n";
    105       echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage\"><br>";
    106     echo "</td>\n";
    107 
    108     echo "<td> \n";
    109       createLabelsTable($pass, $proj, $czardb, "update", $updateLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage);
    110     echo "</td>\n";
    111   echo "</tr>\n";
    112 
    113   echo "<tr>\n";
    114     echo "<table>\n";
    115       echo "<tr valign=top>\n";
    116         echo "<td> \n";
    117           echo "<img src=\"czartool_getplot.php?type=s\"><br>";
    118         echo "</td>\n";
    119         echo "<td>\n";
    120           createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage);
    121         echo "</td>\n";
    122 
    123         echo "<td> \n";
    124           $today = date("Y-m-d");
    125           showSummitData($gpc1db, $today);
    126         echo "</td>\n";
    127       echo "</tr>\n";
    128     echo "</table>\n";
    129 
    130     echo "<table>\n";
    131       echo "<tr valign=top>\n";
    132         echo "<td> \n";
    133         echo "</td>\n";
    134         echo "<td>\n";
    135       if ($selectedServer) showServerStatus($selectedServer);
    136         echo "</td>\n";
    137       echo "</tr>\n";
    138     echo "</table>\n";
    139   echo "</tr>\n";
     103echo "<tr>\n";
     104echo "<td>\n";
     105echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage&plottype=$plotType\"><br>";
     106echo "</td>\n";
     107
     108echo "<td> \n";
     109createLabelsTable($pass, $proj, $czardb, "stdscience", $stdsLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage, $plotType);
     110echo "</td>\n";
     111echo "</tr>\n";
     112
     113echo "<tr>\n";
     114echo "<td>\n";
     115echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
     116echo "</td>\n";
     117
     118echo "<td> \n";
     119createLabelsTable($pass, $proj, $czardb, "update", $updateLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage, $plotType);
     120echo "</td>\n";
     121echo "</tr>\n";
     122
     123echo "<tr>\n";
     124echo "<table>\n";
     125echo "<tr valign=top>\n";
     126echo "<td> \n";
     127echo "<img src=\"czartool_getplot.php?type=s\"><br>";
     128echo "</td>\n";
     129echo "<td>\n";
     130createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage, $plotType);
     131echo "</td>\n";
     132
     133echo "<td> \n";
     134$today = date("Y-m-d");
     135showSummitData($gpc1db, $today);
     136echo "</td>\n";
     137echo "</tr>\n";
     138echo "</table>\n";
     139
     140echo "<table>\n";
     141echo "<tr valign=top>\n";
     142echo "<td> \n";
     143echo "</td>\n";
     144echo "<td>\n";
     145if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
     146echo "</td>\n";
     147echo "</tr>\n";
     148echo "</table>\n";
     149echo "</tr>\n";
    140150echo "</table>\n";
    141151
     
    225235#
    226236###########################################################################
    227 function createLabelsTable($pass, $proj, $db, $server, $labels, $distLabels, $pubLabels, $stages, $states, $selectedState, $selectedLabel, $selectedStage) {
     237function createLabelsTable(
     238        $pass,
     239        $proj,
     240        $db,
     241        $server,
     242        $labels,
     243        $distLabels,
     244        $pubLabels,
     245        $stages,
     246        $states,
     247        $selectedState,
     248        $selectedLabel, $selectedStage, $plotType) {
    228249
    229250    // set up table columns
     
    241262        if ($stage == "burntool") continue;
    242263        $reverting = getRevertStatus($db, $stage);
    243         $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&revertmode=";
     264        $link =
     265            "czartool_labels.php?pass=".$pass
     266            ."&proj=".$proj
     267            ."&label=".$selectedLabel
     268            ."&stage=".$selectedStage
     269            ."&plottype=".$plotType
     270            ."&revertstage=".$stage
     271            ."&revertmode=";
     272
    244273        if(!$reverting) {$label =  "Start";$link = $link . "on";}
    245274        if($reverting) {$label = "Stop";$link = $link . "off";}
     
    254283    write_header_cell($class, "Label (in order of priority)");
    255284    foreach ($stages as &$stage) {
    256        
     285
    257286        if ($stage == $selectedStage) $link = "";
    258         else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $stage;
     287        else $link =
     288            "czartool_labels.php?pass=".$pass
     289                ."&proj=".$proj
     290                ."&label=".$selectedLabel
     291                ."&stage=".$stage
     292                ."&plottype=".$plotType;
     293
    259294        write_table_cell($class, '%s', $link, $stage);
    260295    }
    261296
    262297    if ($selectedStage=="all_stages") $link = "";
    263     else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=all_stages";
     298    else $link =
     299        "czartool_labels.php?pass=".$pass
     300            ."&proj=".$proj
     301            ."&label=".$selectedLabel
     302            ."&stage=all_stages"
     303            ."&plottype=".$plotType;
     304
    264305    write_table_cell($class, '%s', $link, "All stages");
    265306
     
    267308    echo "<tr><td></td>\n";
    268309
    269     $defaultlink = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj;
     310    $defaultlink =
     311        "czartool_labels.php?pass=".$pass
     312        ."&proj=".$proj
     313        ."&label=".$selectedLabel
     314        ."&stage=".$selectedStage
     315        ."&plottype=".$plotType;
    270316
    271317    // write rows
     
    285331        // create link to label summary page for each label
    286332        if ($thisLabel == $selectedLabel) $link = "";
    287         else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $thisLabel . "&stage=" . $selectedStage;
     333        else $link =
     334            "czartool_labels.php?pass=".$pass
     335                ."&proj=".$proj
     336                ."&label=".$thisLabel
     337                ."&stage=".$selectedStage
     338                ."&plottype=".$plotType;
    288339
    289340        echo "<tr><td></td>\n";
     
    342393
    343394    if ($selectedLabel == "all_".$server."_labels") $link = "";
    344     else  $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage;
     395    else  $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage."&plottype=".$plotType;
    345396
    346397    echo "<tr><td></td>\n";
     
    385436###########################################################################
    386437#
     438#  Turns reverts on or off for a given task
     439#
     440###########################################################################
     441function turnRevertsOnOff($db, $stage, $mode) {
     442
     443    exec("czartool_revert.pl -t $stage -o $mode", $response, $status);
     444    $currentRevertMode;
     445    if ($response[0] == "off") $currentRevertMode = 0;
     446    else if ($response[0] == "on") $currentRevertMode = 1;
     447
     448    setRevertStatus($db, $stage, $currentRevertMode);
     449}
     450
     451###########################################################################
     452#
    387453# Returns whether this stage is reverting or not
    388454#
     
    420486    $faults = $row[1];
    421487
    422     $str = "$pending";
     488    if ($pending == 0)
     489        $str = "";
     490    else
     491        $str = "$pending";
    423492
    424493    if ($state == "new") {
     
    437506#
    438507###########################################################################
    439 function createServersTable($pass, $proj, $db, $servers, $selectedLabel, $selectedStage) {
     508function createServersTable($pass, $proj, $db, $servers, $selectedLabel, $selectedStage, $plotType) {
    440509
    441510    // set up table columns
     
    445514    write_header_cell($class, "Server");
    446515    write_header_cell($class, "Alive?");
    447     write_header_cell($class, "Scheduler running?");
     516    $link = "czartool_labels.php?pass=".$pass
     517        ."&proj=".$proj
     518        ."&label=".$selectedLabel
     519        ."&stage=".$selectedStage
     520        ."&plottype=".$plotType
     521        ."&allservercmd=stop";
     522
     523    write_table_cell($class, '%s', $link, "Stop all");
     524    $link = "czartool_labels.php?pass=".$pass
     525        ."&proj=".$proj
     526        ."&label=".$selectedLabel
     527        ."&stage=".$selectedStage
     528        ."&plottype=".$plotType
     529        ."&allservercmd=run";
     530
     531    write_table_cell($class, '%s', $link, "Run all");
    448532    echo "</tr>\n";
    449533
    450534    foreach ($servers as &$server) {
    451535
    452         $link = "czartool_labels.php?pass=".$pass."&proj=".$proj."&server=".$server."&label=".$selectedLabel."&stage=".$selectedStage;
    453         //      $link = "";
    454 
    455536        getServerStatus($db, $server, $alive, $running);
    456537
    457538        echo "<tr><td></td>\n";
     539        $link = "czartool_labels.php?pass=".$pass
     540            ."&proj=".$proj
     541            ."&server=".$server
     542            ."&label=".$selectedLabel
     543            ."&stage=".$selectedStage
     544            ."&plottype=".$plotType;
     545
    458546        write_table_cell($class, '%s', $link, $server);
    459547        write_table_cell($class, '%s', "", $alive ? "yes" : "NO");
    460         write_table_cell($class, '%s', "", $running ? "yes" : "NO");
     548
     549        if ($alive) {
     550
     551            $link = "czartool_labels.php?pass=".$pass
     552                ."&proj=".$proj
     553                ."&label=".$selectedLabel
     554                ."&stage=".$selectedStage
     555                ."&plottype=".$plotType
     556                ."&server=".$server
     557                ."&servercmd=";
     558
     559            if ($running)  {
     560
     561                $link = $link . "stop";
     562                write_table_cell($class, '%s', $link, "stop");
     563                write_table_cell($class, '%s', "", "");
     564            }
     565            else {
     566
     567                $link = $link . "run";
     568                write_table_cell($class, '%s', "", "");
     569                write_table_cell($class, '%s', $link, "run");
     570            }
     571        }
     572        else {
     573
     574            write_table_cell($class, '%s', "", "");
     575            write_table_cell($class, '%s', "", "");
     576        }
    461577        echo "</tr>\n";
    462578    }
     
    464580    echo "</table>\n";
    465581}
     582
     583###########################################################################
     584#
     585#  Commands a server to stop or run
     586#
     587###########################################################################
     588function serverStopRun($db, $server, $cmd) {
     589
     590    exec("czartool_serverstoprun.pl -s $server -c $cmd", $response, $status);
     591    $alive = 0;
     592    $running = 0;
     593    if ($response[0] == "running") {$alive = 1; $running = 1;}
     594    else if ($response[0] == "stopped") {$alive = 1; $running = 0;}
     595    else if ($response[0] == "dead") {$alive = 0; $running = 0;}
     596    setServerStatus($db, $server, $alive, $running);
     597}
     598
     599###########################################################################
     600#
     601# Sets server status
     602#
     603###########################################################################
     604function setServerStatus($db, $server, $alive, $running) {
     605
     606    $sql = "INSERT INTO servers (server, alive, running) VALUES ('$server', $alive, $running)";
     607
     608    if ($debug) {echo "$sql<br>";}
     609
     610    $qry = $db->query($sql);
     611    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
     612}
     613
    466614
    467615###########################################################################
Note: See TracChangeset for help on using the changeset viewer.