IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 27, 2019, 11:39:38 AM (7 years ago)
Author:
eugene
Message:

merge changes from trunk (mostly Ohana & ippMonitor improvements, some work on ippTools)

Location:
branches/eam_branches/ipp-20191011
Files:
13 edited
5 copied

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20191011

  • branches/eam_branches/ipp-20191011/ippMonitor

  • branches/eam_branches/ipp-20191011/ippMonitor/INSTALL

    r40435 r41170  
     1#!/bin/sh
    12
    23# below are commands to configure ippMonitor
     
    1112# testing of those parts of ippMonitor which depend on IPP code without modifyin
    1213# the operational installation
     14# 2019.11.18 CCL: not sure which parts of ippMonitor depends on IPP codes?  If there is not many
     15#                 , just use trunk version should work fine.
    1316psconfig ipp-trunk-20180515
    1417
    15 # run psconfigure to generate Makefile and raw/site.php
     18# run psconfigure to generate Makefile and raw/site.php
     19# $CZARPLOTDIR and $METRICSPLOTDIR will be generated a link in the same folder as ippMonitor 
    1620psconfigure --htdocs /var/www/localhost/htdocs --site ~/ippconfig/ippmonitor.config
    1721
     22# copy these files and modify them (CCL removed CZARPLOTDIR)
     23cp config.dat.in config.dat
     24
    1825# install the php code:
     26# czartool_plots and ippMetrics will be linked to different path in different hostnames
    1927make
     28
     29# for running czarpool.pl,
     30cp czartool/czarconfig.xml.in czartool/czarconfig.xml
     31# then set gnuplot path for czartool_plots and ippMetrics in ippMonitor dir
     32# <path>/var/www/localhost/htdocs/ippMonitor/czartool_plots</path>
     33# <savelocation>/var/www/localhost/htdocs/ippMonitor/ippMetrics</savelocation>
     34# enter czartool
     35./czarpool.pl
     36
  • branches/eam_branches/ipp-20191011/ippMonitor/Makefile.in

    r40844 r41170  
    1 default: updateVersion php
     1default: updateVersion php mklink
    22help:
    33        @echo "USAGE: make php"
    44
    5 SRC     =       src
    6 DEF     =       def
    7 RAW     =       raw
    8 SCRIPTS =       scripts
    9 DESTBIN =       @BINDIR@
    10 DESTWWW =       @HTDOCS@/ippMonitor
     5SRC     = src
     6DEF     = def
     7RAW     = raw
     8SCRIPTS = scripts
     9DESTBIN = @BINDIR@
     10DESTWWW = @HTDOCS@/ippMonitor
     11CZARPLOTDIR = /export/@HOST2@.0/ipp/czartool_plots
     12METRICSPLOTDIR = /export/@HOST2@.0/ipp/ippMetrics
    1113
    1214GENERATE = $(SCRIPTS)/generate
     
    172174$(DESTWWW)/fullforceRun.php \
    173175$(DESTWWW)/fullforceSummary.php \
     176$(DESTWWW)/fullforce_failure.php \
    174177$(DESTWWW)/failedFullforce.php \
    175178$(DESTWWW)/diffSummary.php \
     
    280283$(DESTWWW)/noimage.png
    281284
    282 DESTLINK = $(DESTWWW)/index.php
    283 
    284 php: $(RAWSRC) $(DEFSRC) $(PICTURES) $(DESTLINK) $(PROGRAMS)
     285DESTLINK = $(DESTWWW)/index.php
     286CZPLOTSLINK = $(DESTWWW)/czartool_plots
     287METRICSLINK = $(DESTWWW)/ippMetrics
     288
     289
     290php: $(RAWSRC) $(DEFSRC) $(PICTURES) $(DESTLINK) $(PROGRAMS)
    285291
    286292# dependancy rules for binary code #########################
     
    288294# .PRECIOUS: $(BIN)/%.$(ARCH)
    289295
    290 $(DESTLINK): $(DESTWWW)/Login.php
     296$(DESTLINK): $(DESTWWW)/Login.php 
    291297        rm -f $@
    292298        ln -s $(DESTWWW)/Login.php $@
     
    311317updateVersion:
    312318        rm -f $(DESTWWW)/version.php
    313 
    314 test:
     319        @if [ ! -d $(CZARPLOTDIR) ]; then mkdir -p $(CZARPLOTDIR); fi
     320        @if [ ! -d $(METRICSPLOTDIR) ]; then mkdir -p $(METRICSPLOTDIR); fi
     321
     322mklink: $(CZPLOTSLINK) $(METRICSLINK)
     323
     324$(CZPLOTSLINK): $(CZARPLOTDIR)
     325        rm -f $@
     326        ln -s $(CZARPLOTDIR) $@
     327
     328$(METRICSLINK): $(METRICSPLOTDIR)
     329        rm -f $@
     330        ln -s $(METRICSPLOTDIR) $@
     331
     332test:
    315333#DESTWWW := $(DESTWWW)/test
    316334        echo $(DESTWWW)
     
    355373        cp $(SCRIPTS)/$* $(DESTBIN)/$* || exit
    356374        chmod +x $(DESTBIN)/$* || exit
     375
     376
     377
    357378
    358379# utilities #################################################
  • branches/eam_branches/ipp-20191011/ippMonitor/configure.tcsh

    r39498 r41170  
    134134
    135135set hostname = `hostname -f`
     136set hostname2 = `hostname`
    136137
    137138echo
     
    182183if (-e Makefile) mv -f Makefile Makefile~
    183184cat Makefile.in | sed "s|@HTDOCS@|$htdocs|" > tmp.1
    184 cat tmp.1       | sed "s|@BINDIR@|$bindir|" > Makefile
    185 rm -f tmp.1
     185cat tmp.1       | sed "s|@HOST2@|$hostname2|"  > tmp.2
     186cat tmp.2       | sed "s|@BINDIR@|$bindir|" > Makefile
     187rm -f tmp.2
    186188
    187189# convert raw/site.php.in to raw/site.php
     
    193195cat tmp.1           | sed "s|@DBI@|$DBI|"        > tmp.2
    194196cat tmp.2           | sed "s|@HOST@|$hostname|"  > tmp.1
    195 awk 'BEGIN{t = 0}((t == 0) && ($1 != "@CONFIG.DAT@")){print $0}($1 == "@CONFIG.DAT@"){t = 1}' tmp.1 > raw/site.php
     197cat tmp.1           | sed "s|@HOST2@|$hostname2|"  > tmp.2
     198awk 'BEGIN{t = 0}((t == 0) && ($1 != "@CONFIG.DAT@")){print $0}($1 == "@CONFIG.DAT@"){t = 1}' tmp.2 > raw/site.php
    196199cat config.dat >> raw/site.php
    197 awk 'BEGIN{t = 0}(t == 1){print $0}($1 == "@CONFIG.DAT@"){t = 1}' tmp.1 >> raw/site.php
     200awk 'BEGIN{t = 0}(t == 1){print $0}($1 == "@CONFIG.DAT@"){t = 1}' tmp.2 >> raw/site.php
    198201
    199202rm -f tmp.1 tmp.2
  • branches/eam_branches/ipp-20191011/ippMonitor/czartool/czarDbSchema.sql

    r40055 r41170  
    404404
    405405--
     406-- Table structure for table `science_labels` (from current_labels)
     407--
     408
     409DROP TABLE IF EXISTS `science_labels`;
     410SET @saved_cs_client     = @@character_set_client;
     411SET character_set_client = utf8;
     412CREATE TABLE `science_labels` (
     413  `server` varchar(128) default NULL,
     414  `label` varchar(128) default NULL,
     415  `telescope` varchar(128) NOT NULL,
     416  `priority` int(11) NOT NULL default '0',
     417  KEY `science_labels` (`server`,`label`, `telescope`)
     418) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     419SET character_set_client = @saved_cs_client;
     420
     421--
     422-- Table structure for table `science_nightlyscience` (from nightlyscience)
     423--
     424
     425DROP TABLE IF EXISTS `science_nightlyscience`;
     426SET @saved_cs_client     = @@character_set_client;
     427SET character_set_client = utf8;
     428CREATE TABLE `science_nightlyscience` (
     429  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
     430  `status` varchar(128) default 'NONE',
     431  `telescope` varchar(128) NOT NULL
     432) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     433SET character_set_client = @saved_cs_client;
     434
     435--
     436-- Table structure for table `science_reverts` (from reverts)
     437--
     438
     439DROP TABLE IF EXISTS `science_reverts`;
     440SET @saved_cs_client     = @@character_set_client;
     441SET character_set_client = utf8;
     442CREATE TABLE `science_reverts` (
     443  `stage` varchar(128) default NULL,
     444  `telescope` varchar(128) NOT NULL,
     445  `reverting` tinyint(4) default NULL
     446) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     447SET character_set_client = @saved_cs_client;
     448
     449--
     450-- Table structure for table `science_server_dates` (from server_dates)
     451--
     452
     453DROP TABLE IF EXISTS `science_server_dates`;
     454SET @saved_cs_client     = @@character_set_client;
     455SET character_set_client = utf8;
     456CREATE TABLE `science_server_dates` (
     457  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
     458  `server` varchar(64) default 'NONE',
     459  `telescope` varchar(128) NOT NULL,
     460  `date` varchar(64) default 'NONE'
     461) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     462SET character_set_client = @saved_cs_client;
     463
     464--
     465-- Table structure for table `science_servers` (from servers)
     466--
     467
     468DROP TABLE IF EXISTS `science_servers`;
     469SET @saved_cs_client     = @@character_set_client;
     470SET character_set_client = utf8;
     471CREATE TABLE `science_servers` (
     472  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
     473  `server` varchar(128) default NULL,
     474  `telescope` varchar(128) NOT NULL,
     475  `alive` tinyint(4) default NULL,
     476  `running` tinyint(4) default NULL
     477) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     478SET character_set_client = @saved_cs_client;
     479
     480--
     481-- Table structure for table `live_servers` (from servers)
     482--
     483
     484DROP TABLE IF EXISTS `live_servers`;
     485SET @saved_cs_client     = @@character_set_client;
     486SET character_set_client = utf8;
     487CREATE TABLE `live_servers` (
     488  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
     489  `server` varchar(128) default NULL,
     490  `telescope` varchar(128) NOT NULL,
     491  `alive` tinyint(4) default NULL,
     492  `running` tinyint(4) default NULL
     493) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     494SET character_set_client = @saved_cs_client;
     495
     496--
    406497-- Table structure for table `server_dates`
    407498--
  • branches/eam_branches/ipp-20191011/ippMonitor/czartool/czarpoll.pl

    r40879 r41170  
    236236        $pantasks->getServerStatus($server,'gpc2', \$alive, \$running);
    237237        $czarDb->updateServerStatus($server,'gpc2', $alive, $running);
     238   }
     239}
     240
     241###########################################################################
     242#
     243# Updates pantasks server status TODO should really get info for all servers at once
     244#
     245###########################################################################
     246sub updateServerStatusLive {
     247    print "* Checking all pantasks servers\n";
     248
     249    my $servers = $pantasks->getServerList();
     250
     251    my $server = undef;
     252    my $alive = undef;
     253    my $running = undef;
     254    foreach $server (@{$servers}) {
     255        $pantasks->getServerStatus($server,'gpc1', \$alive, \$running);
     256        $czarDb->updateServerStatusLive($server,'gpc1', $alive, $running);
     257        $pantasks->getServerStatus($server,'gpc2', \$alive, \$running);
     258        $czarDb->updateServerStatusLive($server,'gpc2', $alive, $running);
    238259   }
    239260}
     
    272293    my $newDayTime = $config->getMetricsStartTime();
    273294    my $lastDayDailyTasks = "2010-01-01";
    274 
     295    my $checkneb = 1; # 1 for nebulous, 0 for localhost test
    275296    # main polling loop
    276297    while (1) {
     298
    277299        my $iterationStartTime = time();
    278 
     300 
    279301        #get the time of last czarpoll update
    280302        $polldate = $czarDb->getPollDate();
     
    287309        if($timediff > 120.) {
    288310            print "There is no recent Czarpoll iteration\n";
    289             print "*Updating database entries*\n";
     311            print "* Updating database entries*\n";
    290312            $dbupdate = 1;
    291313        } else {
    292314            print "There is a recent Czarpoll iteration already made ($timediff sec ago)\n";
    293             print "*Skipping database queries and entries*\n";
     315            print "* Skipping database queries and entries\n";
    294316            $dbupdate = 0;
    295317        }
     
    326348                #TdB20190703: The ipp113 and ipp117 instances of czarpoll use the same stage DBs in czarDB.
    327349                #Therefore, it makes no sense to run the cleanup+optimising twice
    328                 #print "* Performing database cleanup\n";
    329                 #$czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
     350                print "* Performing database cleanup\n";
     351                $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
    330352                #print "* Optimizing the database\n";
    331353                #$czarDb->optimize();
     
    344366
    345367        # check nebulous
    346         print "* Checking Nebulous\n";
    347         if($dbupdate == 1) {$nebulous->updateClusterSpaceInfo();}
    348         $plotter0->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
    349         $plotter0->plotDiskUsageHistogram();
    350         $plotter0->plotDiskUsageHistogramLarge();
     368        if ($checkneb == 1) {
     369            print "* Checking Nebulous\n";
     370            if($dbupdate == 1) {$nebulous->updateClusterSpaceInfo();}
     371            $plotter0->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
     372            $plotter0->plotDiskUsageHistogram();
     373            $plotter0->plotDiskUsageHistogramLarge();
     374        }
     375        else {
     376            print "* Locahost, so no checking nebulous\n";
     377        }
     378
     379        # check pantasks status
    351380        if($dbupdate == 1) {updateServerStatus();}
     381        if($dbupdate == 1) {updateServerStatusLive();}
    352382
    353383        # check pantasks dates
  • branches/eam_branches/ipp-20191011/ippMonitor/czartool/czartool/CzarDb.pm

    r40878 r41170  
    166166SQL
    167167
     168       $query->execute;
     169}
     170
     171###########################################################################
     172#
     173# Updates server table
     174#
     175###########################################################################
     176sub updateServerStatusLive {
     177    my ($self, $server,$telescope, $alive, $running) = @_;
     178
     179    my $query = $self->{_db}->prepare(<<SQL);
     180    DELETE FROM live_servers where timestamp < CURRENT_TIMESTAMP - INTERVAL 12 hour;
     181SQL
     182       $query->execute;
     183
     184    $query = $self->{_db}->prepare(<<SQL);
     185    INSERT INTO live_servers
     186        (server,telescope, alive, running)
     187        VALUES
     188        ('$server','$telescope', $alive, $running);
     189SQL
    168190       $query->execute;
    169191}
  • branches/eam_branches/ipp-20191011/ippMonitor/czartool/czartool/Pantasks.pm

    r40840 r41170  
    77
    88my @servers = (
    9 #        "addstar",
    10 #        "addstarlap",
    11         "ippqub:stdscience_ws",
     9##### standard pantasks ######
    1210        "cleanup",
    13 #        "deepstack",
    14 #        "detrend",
    1511        "distribution",
    1612        "pstamp",
    17 #        "update",
    18 #        "publishing",
    1913        "registration",
    20         "replication",
    2114        "stack",
    2215        "stdscience",
    23         "summitcopy"
     16        "summitcopy",
     17##### additional pantasks ######
     18        "addstar",
     19        "addstarlap",
     20        "deepstack",
     21        "detrend",
     22        "ippqub:stdscience_ws",
     23        "publishing",
     24        "replication",
     25        "update"
    2426        );
     27# current home dir of gpc1 and gpc2
     28my $ipphome1 = "/data/ippc64.1/ippitc";
     29my $ipphome2 = "/data/ippc18.0/home/ippps2";
    2530
    2631###########################################################################
     
    9095
    9196    if ($telescope eq 'gpc1') {
    92        $ipphome = "/data/ippc64.1/ippitc";
    93     }
    94     elsif ($telescope eq 'gpc2') {
    95        $ipphome = "/data/ippc18.0/home/ippps2";
     97       $ipphome = $ipphome1;
     98    }
     99    elsif ($telescope eq 'gpc2') {
     100       $ipphome = $ipphome2;
    96101    }
    97102    else {
     
    134139
    135140    if ($telescope eq 'gpc1') {
    136        $ipphome = "/data/ippc64.1/ippitc";
    137     }
    138     elsif ($telescope eq 'gpc2') {
    139        $ipphome = "/data/ippc18.0/home/ippps2";
     141       $ipphome = $ipphome1;
     142    }
     143    elsif ($telescope eq 'gpc2') {
     144       $ipphome = $ipphome2;
    140145    }
    141146    else {
     
    177182
    178183    if ($telescope eq 'gpc1') {
    179        $ipphome = "/data/ippc64.1/ippitc";
    180     }
    181     elsif ($telescope eq 'gpc2') {
    182        $ipphome = "/data/ippc18.0/home/ippps2";
     184       $ipphome = $ipphome1;
     185    }
     186    elsif ($telescope eq 'gpc2') {
     187       $ipphome = $ipphome2;
    183188    }
    184189    else {
     
    209214    my $ipphome;
    210215    if ($telescope eq 'gpc1') {
    211        $ipphome = "/data/ippc64.1/ippitc";
    212     }
    213     elsif ($telescope eq 'gpc2') {
    214        $ipphome = "/data/ippc18.0/home/ippps2";
     216       $ipphome = $ipphome1;
     217    }
     218    elsif ($telescope eq 'gpc2') {
     219       $ipphome = $ipphome2;
    215220    }
    216221    else {
     
    239244    my $ipphome;
    240245    if ($telescope eq 'gpc1') {
    241        $ipphome = "/data/ippc64.1/ippitc";
    242     }
    243     elsif ($telescope eq 'gpc2') {
    244        $ipphome = "/data/ippc18.0/home/ippps2";
     246       $ipphome = $ipphome1;
     247    }
     248    elsif ($telescope eq 'gpc2') {
     249       $ipphome = $ipphome2;
    245250    }
    246251    else {
     
    279284
    280285    if ($telescope eq 'gpc1') {
    281        $ipphome = "/data/ippc64.1/ippitc";
    282     }
    283     elsif ($telescope eq 'gpc2') {
    284        $ipphome = "/data/ippc18.0/home/ippps2";
     286       $ipphome = $ipphome1;
     287    }
     288    elsif ($telescope eq 'gpc2') {
     289       $ipphome = $ipphome2;
    285290    }
    286291    else {
  • branches/eam_branches/ipp-20191011/ippMonitor/def/fullforce_failure.d

    r40882 r41170  
    1 TABLE staticskyRun JOIN staticskyResult USING (sky_id) JOIN staticskyInput USING (sky_id) JOIN stackRun USING (stack_id)
    2 TITLE Static Sky Failed (Log)
    3 FILE  failedStaticsky.php
    4 MENU  ipp.stack.dat
     1TABLE fullForceInput JOIN warpRun USING (warp_id) JOIN fullForceRun USING (ff_id) JOIN fullForceResult USING (ff_id)
     2TITLE Full Force Failed
     3FILE  fullforce_failure.php
     4MENU  ipp.ffs.dat
    55
    6 WHERE staticskyResult.fault != 0
     6ARGS  ARG1 fullForceRun.ff_id=$fullForceRun.ff_id
     7ARGS  ARG1 basename=$fullForceResult.path_base
    78
    8 ARGS  ARG1   staticskyResult.path_base=$staticskyResult.path_base
     9WHERE fullForceResult.fault != 0
     10#        field                       size     format             name           show     link to         extras
     11FIELD   fullForceRun.ff_id,             5,        %d,           FF ID
     12FIELD   fullForceRun.label,             7,        %s,           Label
     13FIELD   fullForceRun.state,             7,        %s,           State,     value,  fullforce_failure.php, ARG1
     14FIELD   warpRun.tess_id,                5,        %s,           Tess ID
     15FIELD   warpRun.label AS warpRunLabel,  5,        %s,           warp Label
     16FIELD   fullForceRun.data_group,        7,        %s,           data grp
     17FIELD   fullForceRun.dist_group,        7,        %s,           dist grp
     18FIELD   fullForceResult.fault,          7,        %d,           fault
     19FIELD   fullForceResult.quality,        7,        %d,           quality
     20FIELD   fullForceResult.path_base,      7,        %s,           path_base, none
    921
    10 #        field                          size  format  name           show     link to         extras
    11 FIELD staticskyRun.sky_id,          5, %d,     Sky ID
    12 FIELD staticskyRun.label,           7, %s,     Label
    13 FIELD staticskyRun.state,           7, %s,     State,           value,          staticsky_failure.php, ARG1
    14 FIELD stackRun.skycell_id,          5, %s,     Skycell ID
    15 FIELD stackRun.tess_id,             5, %s,     Tess ID
    16 FIELD count(stackRun.filter),       5, %d,     #Filters
    17 FIELD stackRun.label,               5, %s,     Stack Label
    18 FIELD staticskyRun.data_group,      7, %s,     data grp
    19 FIELD staticskyRun.dist_group,      7, %s,     dist grp
    20 FIELD staticskyResult.sources,      7, %d,     n(sources)
    21 FIELD staticskyResult.fault,        7, %d,     fault
    22 FIELD staticskyResult.quality,      7, %d,     quality
    23 FIELD staticskyResult.path_base,    5, %s,     path_base,     none
    24 
    25 GROUP staticskyRun.sky_id
     22MODE summary
     23GROUP fullForceRun.ff_id
    2624
    2725TAIL PHP insert_log ('LOG.EXP');
     26
  • branches/eam_branches/ipp-20191011/ippMonitor/raw/czartool_labels.php

    r40883 r41170  
    214214echo "<td style=height:200px;width:400px;text-align:top;\">";
    215215
    216 #echo "<br>";
     216/////////////////////////////////////////
     217// timer begin for status and links
     218/////////////////////////////////////////
     219$time = microtime();
     220$time = explode(' ', $time);
     221$time = $time[1] + $time[0];
     222$start = $time;
    217223
    218224// status table at top
    219225$nsStatus = getNightlyScienceStatus($czardb, $proj);
    220226$plotTypeLink = ($plotType == "linear") ? "log" : "linear";
    221 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
     227$link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel .
     228        "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
     229
    222230echo "<br>";
    223231echo $table;
    224 
    225 createTableTitle("Status and links", 3);
     232createTableTitle("Status and links", 2);
    226233echo "<tr>\n";
    227 echo "<tr><td>Time of last update</td><td>$lastUpdateTime</td></tr>";
    228 echo "<tr><td>ippMonitor SVN version</td><td>"; include 'version.php'; echo "</td></tr>";
    229 echo "<tr><td>Current nightly science status</td><td>$nsStatus</td></tr>";
    230 echo "<tr><td>Postage stamp server status</td><td><a href=\"http://pstamp.ipp.ifa.hawaii.edu/status.php\"><font color=\"blue\">here</font></a></td></tr>";
    231 echo "<tr><td>Documentation</td><td><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\"><font color=\"blue\">here</font></a></td></tr>";
    232 echo "<tr><td>Cluster load</td><td><a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?r=hour&s=descending&hc=6&c=IPP%2520Production\"><font color=\"blue\">here</font></a> <a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?m=cpu_report&r=hour&s=by%2520name&c=IPP+Production&h=&sh=1&hc=8&z=small\"><font color=\"blue\">cpu_report</font></a> <a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?m=mem_report&r=hour&s=by%2520name&c=IPP+Production&h=&sh=1&hc=8&z=small\"><font color=\"blue\">mem_report</font></a></td></tr>";
    233 echo "<tr><td>IPP metrics</td><td><a href=\"https://ps1wiki.ifa.hawaii.edu/data/metrics/index.html\"><font color=\"blue\">here</font></a></td></tr>";
    234 echo "<tr><td>Czar log pages</td><td><a href=\"https://confluence.ipp.ifa.hawaii.edu/pages/viewrecentblogposts.action?key=IPPCZAR\"><font color=\"blue\">here</font></a></td></tr>";
    235 echo "<tr><td>Exposure summary</td><td><a href=\"czartool_exposures.php?pass=$pass&proj=$proj\"><font color=\"blue\">here</font></a></td></tr>";
    236 echo "<tr><td>Confluence</td><td><a href=\"https://confluence.ipp.ifa.hawaii.edu/display/IPPCZAR/IPP-Czaring+Home\"><font color=\"blue\">here</font></a></td></tr>";
    237 echo "<tr><td>JIRA</td><td><a href=\"https://jira.ipp.ifa.hawaii.edu/secure/Dashboard.jspa\"><font color=\"blue\">here</font></a></td></tr>";
     234echo "<tr><td>Time of last update</td>
     235          <td>$lastUpdateTime</td></tr>";
     236echo "<tr><td>ippMonitor SVN version</td>
     237          <td>"; include 'version.php'; echo "</td></tr>";
     238echo "<tr><td>Current nightly science status</td>
     239          <td>$nsStatus</td></tr>";
     240echo "<tr><td>Postage stamp server status</td>
     241          <td><a href=\"http://pstamp.ipp.ifa.hawaii.edu/status.php\" target=new><font color=\"blue\">here</font></a></td></tr>";
     242echo "<tr><td>Documentation</td>
     243          <td><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\" target=new><font color=\"blue\">here</font></a></td></tr>";
     244echo "<tr><td>Cluster load</td>
     245          <td><a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?r=hour&s=descending&hc=6&c=IPP%2520Production\">
     246              <font color=\"blue\">here</font></a>
     247              <a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?m=cpu_report&r=hour&s=by%2520name&c=IPP+Production&h=&sh=1&hc=8&z=small\">
     248              <font color=\"blue\">cpu_report</font></a>
     249              <a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?m=mem_report&r=hour&s=by%2520name&c=IPP+Production&h=&sh=1&hc=8&z=small\">
     250              <font color=\"blue\">mem_report</font></a></td></tr>";
     251echo "<tr><td>IPP metrics</td>
     252          <td><a href=\"https://ps1wiki.ifa.hawaii.edu/data/metrics/index.html\"><font color=\"blue\" target=new>here</font></a></td></tr>";
     253echo "<tr><td>Czar log pages</td>
     254          <td><a href=\"https://confluence.ipp.ifa.hawaii.edu/pages/viewrecentblogposts.action?key=IPPCZAR\" target=new><font color=\"blue\">here</font></a></td></tr>";
     255echo "<tr><td>Exposure summary</td>
     256          <td><a href=\"czartool_exposures.php?pass=$pass&proj=$proj\"><font color=\"blue\">here</font></a></td></tr>";
     257echo "<tr><td>Confluence</td>
     258          <td><a href=\"https://confluence.ipp.ifa.hawaii.edu/display/IPPCZAR/IPP-Czaring+Home\" target=new><font color=\"blue\">here</font></a></td></tr>";
     259echo "<tr><td>JIRA</td>
     260          <td><a href=\"https://jira.ipp.ifa.hawaii.edu/secure/Dashboard.jspa\" target=new><font color=\"blue\">here</font></a></td></tr>";
     261echo "<tr><td>data store</td>
     262          <td><a href=\"https://svn.ifa.hawaii.edu/\" target=new><font color=\"blue\">here</font></a></td></tr>";
    238263
    239264$plotTypeLink = ($plotType == "linear") ? "log" : "linear";
    240 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&mode=" . $selectedMode . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
    241 
    242 echo "</table>\n";
    243 
    244 echo "<br>";
    245 
    246        createLabelsTable($pass,
    247          $proj,
    248          $czardb,
    249          $selectedMode,
    250          $labels,
    251          $distLabelsExist,
    252          $pubLabelsExist,
    253          $stages,
    254          "new",
    255          $selectedLabel,
    256          $selectedStage,
    257          $plotType);
    258 
    259       if ($selectedMode == "update") {echo "<br>"; createPStampDataTable();}
    260       echo "<br>";
    261 
    262       # XXX EAM : 2017.09.17 : debugging slowness
    263       createServersTable($pass, $proj,$selectedMode,$czardb, $servers, $selectedLabel, $selectedStage, $plotType); echo "<br>";
    264       createSummitDataTable($projectdb); echo "<br>"; // this is slow because of the join between summitExp and rawExp
    265       createChunkDataTable($projectdb); echo "<br>";
    266       createDatesTable($czardb, $proj); echo "<br>";
    267 
    268       echo $table;
    269       echo "<tr>";
    270       createTableTitle("Database status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\">here</a>)", 2);
    271 
    272       echo "<tr>";
    273       createTableColumnHeader("Database");
    274       createTableColumnHeader("Status (sec behind master)");
    275       showDatabaseStatus($HOST_GPC1, $USER_GPC1, $PASSWORD_GPC1, $DBNAME_GPC1);
    276       showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_DBNAME_GPC1);
    277       showReplicationsStatus($REPL_HOST_GPC1_SECONDARY, $REPL_USER_GPC1_SECONDARY, $REPL_PASSWORD_GPC1_SECONDARY, $REPL_DBNAME_GPC1_SECONDARY);
    278 
    279       echo "<tr>";
    280 
    281       showDatabaseStatus($HOST_NEBULOUS, $USER_NEBULOUS, $PASSWORD_NEBULOUS, $DBNAME_NEBULOUS);
    282       showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_DBNAME_NEBULOUS);
    283       showReplicationsStatus($REPL_HOST_NEBULOUS_SECONDARY, $REPL_USER_NEBULOUS_SECONDARY, $REPL_PASSWORD_NEBULOUS_SECONDARY, $REPL_DBNAME_NEBULOUS_SECONDARY);
    284       showReplicationsStatus($REPL_HOST_DATASTORE_SECONDARY, $REPL_USER_DATASTORE_SECONDARY, $REPL_PASSWORD_DATASTORE_SECONDARY, $REPL_DBNAME_DATASTORE_SECONDARY);
    285 
    286 #     some mysql replication slaves to add when they are returned to service
    287 #     showReplicationsStatus($REPL_HOST_PSTAMP, $REPL_USER_PSTAMP, $REPL_PASSWORD_PSTAMP, $REPL_DBNAME_PSTAMP);
    288 #     showReplicationsStatus($REPL_HOST_ISP, $REPL_USER_ISP, $REPL_PASSWORD_ISP, $REPL_DBNAME_ISP);
    289       echo "</table>";
    290 
    291       echo $table;
    292       echo "<tr>";
    293       createTableTitle("Critical machine status", 2);
    294 
    295       echo "<tr>";
    296       createTableColumnHeader("Hostname");
    297       createTableColumnHeader("Status");
    298       showPingStatus($HOST_GATEWAY, $DBNAME_GATEWAY);
    299       showPingStatus($HOST_GATEWAY_SECONDARY, $DBNAME_GATEWAY_SECONDARY);
    300 
    301 #      showPingStatus($HOST_APACHE1, $DBNAME_APACHE1);
    302       showPingStatus($HOST_APACHE2, $DBNAME_APACHE2);
    303       showPingStatus($HOST_APACHE3, $DBNAME_APACHE3);
    304       showPingStatus($HOST_APACHE4, $DBNAME_APACHE4);
    305       showPingStatus($HOST_APACHE5, $DBNAME_APACHE5);
    306       showPingStatus($HOST_APACHE6, $DBNAME_APACHE6);
    307       showPingStatus($HOST_APACHE7, $DBNAME_APACHE7);
    308       showPingStatus($HOST_PROXY, $DBNAME_PROXY);
    309       showPingStatus($HOST_SVN, $DBNAME_SVN);
    310       showPingStatus($HOST_CONFLUENCE, $DBNAME_CONFLUENCE);
    311 
    312       echo "</table>";
    313 
    314 echo "</table>";
     265$link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&mode=" . $selectedMode .
     266        "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
     267
     268// timer finished
     269echo "<tr><th colspan=4>";
     270$time = microtime();
     271$time = explode(' ', $time);
     272$time = $time[1] + $time[0];
     273$finish = $time;
     274$total_time = round(($finish - $start), 3);
     275echo "loading in $total_time seconds.";
     276echo "</th></tr>";
     277echo "</table><br>";
     278
     279createLabelsTable($pass, $proj, $czardb, $selectedMode, $labels,
     280  $distLabelsExist, $pubLabelsExist, $stages, "new", $selectedLabel,
     281  $selectedStage, $plotType);
     282if ($selectedMode == "update") {echo "<br>"; createPStampDataTable();}
     283
     284# XXX EAM : 2017.09.17 : debugging slowness
     285# CCL : 2019.11.09 : debugging slowness
     286//createSummitDataTable($projectdb); // this is slow because of the join between summitExp and rawExp, but not the major one
     287createSummitDataTable2($projectdb); // this is slow because of the join between summitExp and rawExp, but not the major one
     288
     289createServersTable($pass, $proj,$selectedMode,$czardb, $servers, $selectedLabel, $selectedStage, $plotType);
     290// this was the major slowness part due to large table in czardb
     291
     292createChunkDataTable($projectdb);  // this is another part for slowness during nightly processing
     293
     294createDatesTable($czardb, $proj);
     295
     296/////////////////////////////////////////
     297// timer begin for Database status
     298/////////////////////////////////////////
     299$time = microtime();
     300$time = explode(' ', $time);
     301$time = $time[1] + $time[0];
     302$start = $time;
     303
     304// status table at top
     305  echo $table;
     306  echo "<tr>";
     307  createTableTitle("Database status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\">here</a>)", 2);
     308 
     309  echo "<tr>";
     310  createTableColumnHeader("Database");
     311  createTableColumnHeader("Status (sec behind master)");
     312  showDatabaseStatus($HOST_GPC1, $USER_GPC1, $PASSWORD_GPC1, $DBNAME_GPC1);
     313  showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_DBNAME_GPC1);
     314  showReplicationsStatus($REPL_HOST_GPC1_SECONDARY, $REPL_USER_GPC1_SECONDARY, $REPL_PASSWORD_GPC1_SECONDARY, $REPL_DBNAME_GPC1_SECONDARY);
     315 
     316  echo "<tr>";
     317  showDatabaseStatus($HOST_NEBULOUS, $USER_NEBULOUS, $PASSWORD_NEBULOUS, $DBNAME_NEBULOUS);
     318  showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_DBNAME_NEBULOUS);
     319  showReplicationsStatus($REPL_HOST_NEBULOUS_SECONDARY, $REPL_USER_NEBULOUS_SECONDARY, $REPL_PASSWORD_NEBULOUS_SECONDARY, $REPL_DBNAME_NEBULOUS_SECONDARY);
     320  showReplicationsStatus($REPL_HOST_DATASTORE_SECONDARY, $REPL_USER_DATASTORE_SECONDARY, $REPL_PASSWORD_DATASTORE_SECONDARY, $REPL_DBNAME_DATASTORE_SECONDARY);
     321 
     322//  some mysql replication slaves to add when they are returned to service
     323//  showReplicationsStatus($REPL_HOST_PSTAMP, $REPL_USER_PSTAMP, $REPL_PASSWORD_PSTAMP, $REPL_DBNAME_PSTAMP);
     324//  showReplicationsStatus($REPL_HOST_ISP, $REPL_USER_ISP, $REPL_PASSWORD_ISP, $REPL_DBNAME_ISP);
     325
     326// timer finished
     327echo "<tr><th colspan=2>";
     328$time = microtime();
     329$time = explode(' ', $time);
     330$time = $time[1] + $time[0];
     331$finish = $time;
     332$total_time = round(($finish - $start), 3);
     333echo "loading in $total_time seconds.";
     334echo "</th></tr>";
     335echo "</table><br>";
     336
     337/////////////////////////////////////////
     338// timer begin for critical machines
     339/////////////////////////////////////////
     340$time = microtime();
     341$time = explode(' ', $time);
     342$time = $time[1] + $time[0];
     343$start = $time;
     344
     345// status table at top
     346  $PingStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">DOWN</font>";
     347  echo $table;
     348  echo "<tr>";
     349  createTableTitle("Critical machine status", 3);
     350
     351  echo "<tr>";
     352  createTableColumnHeader("Hostname");
     353  createTableColumnHeader("Status");
     354  createTableColumnHeader("Loading time");
     355  showPingStatus($HOST_GATEWAY, $DBNAME_GATEWAY);
     356  showPingStatus($HOST_GATEWAY_SECONDARY, $DBNAME_GATEWAY_SECONDARY);
     357  showPingStatus($HOST_APACHE1, $DBNAME_APACHE1);
     358  showPingStatus($HOST_APACHE2, $DBNAME_APACHE2);
     359  showPingStatus($HOST_APACHE3, $DBNAME_APACHE3);
     360  showPingStatus($HOST_APACHE4, $DBNAME_APACHE4);
     361  showPingStatus($HOST_APACHE5, $DBNAME_APACHE5);
     362  showPingStatus($HOST_APACHE6, $DBNAME_APACHE6);
     363  showPingStatus($HOST_APACHE7, $DBNAME_APACHE7);
     364  showPingStatus($HOST_APACHE8, $DBNAME_APACHE8);
     365//     echo "<td>ippc70 (apache node) <td> $PingStatus <td> 0 seconds ";  // comment out if ippc70 is back
     366  showPingStatus($HOST_PROXY, $DBNAME_PROXY);
     367  showPingStatus($HOST_SVN, $DBNAME_SVN);
     368  showPingStatus($HOST_CONFLUENCE, $DBNAME_CONFLUENCE);
     369
     370// timer finished
     371echo "<tr><th colspan=3>";
     372$time = microtime();
     373$time = explode(' ', $time);
     374$time = $time[1] + $time[0];
     375$finish = $time;
     376$total_time = round(($finish - $start), 3);
     377echo "loading in $total_time seconds.";
     378echo "</th></tr>";
     379echo "</table><br>";
     380   
     381
    315382menu_end();
    316383
     384
     385#############################################################################
     386#############################  Functions Below  #############################
     387#############################################################################
    317388
    318389###########################################################################
     
    361432}
    362433
    363 ###########################################################################
    364 #
    365 # Creates a table of summitExp against rawExp
    366 #
    367 ###########################################################################
    368 function createSummitDataTable($projectdb) {
    369 
    370     $date = date("Y-m-d");
    371     $sql = "SELECT DISTINCT exp_type FROM summitExp WHERE dateobs > '$date'";
    372 
    373     $qry = $projectdb->query($sql);
    374     if (dberror($qry)) {
    375         echo "<b>error reading newExp table</b><br>\n";
    376         echo "<br><small><b> table query : $sql </b></small><br>\n";
    377         menu_end();
    378     }
    379 
    380     // set up the table
    381     global $table;
    382     echo $table;
    383     echo "<tr>";
    384     createTableTitle("Status of last night's data", 4);
    385     echo "<tr>";
    386     createTableColumnHeader("Exposure type");
    387     createTableColumnHeader("At summit");
    388     createTableColumnHeader("Registered at MHPCC");
    389     createTableColumnHeader("At summit (Dropped)");
    390 
    391     $msg = "No science images taken since $date";
    392 
    393     // list the results
    394     while ($qry->fetchInto($expType)) {
    395 
    396         $sql = "SELECT COUNT(*) FROM summitExp left join pzDownloadExp using (summit_id) WHERE dateobs > '$date' AND exp_type = '$expType[0]' and (state != 'drop' or state is null) and fault != 1042";
    397 #       $sql = "SELECT COUNT(*) FROM summitExp WHERE dateobs > '$date' AND exp_type = '$expType[0]'";
    398         $qry2 = $projectdb->query($sql);
    399         $qry2->fetchInto($summit);
    400 
    401 
    402         $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND rawExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
    403         $qry2 = $projectdb->query($sql);
    404         $qry2->fetchInto($mhpcc);
    405 
    406         $sql = "SELECT COUNT(*) FROM summitExp join pzDownloadExp using (summit_id) WHERE dateobs > '$date' AND exp_type = '$expType[0]' and state = 'drop'";
    407         $qry2 = $projectdb->query($sql);
    408         $qry2->fetchInto($dropped);
    409 
    410 
    411         #Query with 30 minutes delay to check during the night if any exposures are missing.
    412         $datehour = gmdate("Y-m-d H:i:s");
    413         $sql = "SELECT COUNT(*) FROM summitExp left join pzDownloadExp using (summit_id) WHERE dateobs > '$date' AND dateobs <= date_sub('$datehour', interval 30 minute) AND exp_type = '$expType[0]' and (state != 'drop' or state is null) and fault != 1042";
    414         $qry2 = $projectdb->query($sql);
    415         $qry2->fetchInto($summitdelay);
    416 
    417         $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.dateobs <= date_sub('$datehour', interval 30 minute) AND rawExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
    418         $qry2 = $projectdb->query($sql);
    419         $qry2->fetchInto($mhpccdelay);
    420 
    421         echo "<tr>";
    422 
    423         $DLdiff = $summit[0] - $mhpcc[0];
    424         if ($DLdiff == 0) $error = 0;
    425         else $error = 1;
    426 
    427         $delayDLdiff = $summitdelay[0] - $mhpccdelay[0];
    428         if ($delayDLdiff == 0) $errordelay = 0;
    429         else $errordelay = 1;
    430 
    431         echo "<td>$expType[0]</td>";
    432         echo "<td>$summit[0]</td>";
    433         #createFormattedTableCell("", "", $mhpcc[0], $error, 0);
    434         if ($delayDLdiff==0) {
    435            createFormattedTableCell("", "", $mhpcc[0], $error, 0);
    436         } else {
    437            $DLStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">$mhpcc[0] ($delayDLdiff)</font>";
    438            echo "<td>$DLStatus</td>";
    439         }
    440 
    441         echo "<td>$dropped[0]</td>";
    442 
    443         echo "</tr>";
    444     }
    445 
    446     echo "</table>\n";
    447 
    448 }
    449434
    450435###########################################################################
     
    455440function createChunkDataTable($projectdb) {
    456441
     442    // timer start
     443    $time = microtime();
     444    $time = explode(' ', $time);
     445    $time = $time[1] + $time[0];
     446    $start = $time;
     447
     448    // function begin
    457449    #First find the reference exposure ID to speed up the subsequent queries
    458450    $date = gmdate("Y-m-d");
     
    464456    }
    465457    $qry->fetchInto($refExpID);
    466 
    467     #Find the number of chunks
    468     $query = "SELECT groupchunk.chunk,groupchunk.Nquad_firstvisit,group4.Nquad_fourvisits FROM";
    469     $query .= "   (";
    470     $query .= "     SELECT dateobs,comment,substr(comment, 1, position(' ' in comment)) AS chunk,count(distinct(comment)) AS Nquad_firstvisit";
    471     $query .= "     FROM rawExp";
    472     $query .= "     WHERE dateobs LIKE '$date%' AND exp_id > $refExpID[0]";
    473     $query .= "     AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING'";
    474     $query .= "     AND comment LIKE '%visit 1%'";
    475     $query .= "     GROUP BY chunk";
    476     $query .= "   ) AS groupchunk";
    477     $query .= "   LEFT JOIN";
    478     $query .= "   (";
    479     $query .= "     SELECT groupobj.chunk,count(*) AS Nquad_fourvisits FROM ";
    480     $query .= "       (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(distinct(comment)) AS Nvisits";
    481     $query .= "         FROM rawExp";
    482     $query .= "         WHERE dateobs LIKE '$date%' AND exp_id > $refExpID[0] AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
    483     $query .= "         AND obs_mode NOT LIKE 'ENGINEERING' AND comment LIKE '%visit%'";
    484     $query .= "         GROUP BY object, filter, chunk";
    485     $query .= "       ) AS groupobj";
    486     $query .= "     WHERE groupobj.Nvisits = 4 ";
    487     $query .= "     GROUP BY groupobj.chunk";
    488     $query .= "   ) AS group4";
    489     $query .= "   on groupchunk.chunk=group4.chunk ORDER BY dateobs";
    490 
    491     #$sql = "SELECT DISTINCT substr(comment, 1, position(' ' in comment)) FROM rawExp WHERE dateobs LIKE '$date%' AND exp_id > $refExpID AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND comment LIKE '%visit 1%'";
     458    if ($refExpID[0] = 'NULL') {
     459        $refExpID[0] = 0;
     460    }
     461
     462    #do a query of raw/chip/cam/warp counts for this night, split by chunk.
     463    #we need to do a subquery to find the total number of skycells in warpSkyfile, as well as the number of those with a bad quality
     464    $query = "SELECT suba.chunk,suba.Nvis1,suba.Nvis2,suba.Nvis3,suba.Nvis4,suba.Ncamgood,suba.Ncambad,subb.Nwarpgood,subb.Nwarpbad FROM ";
     465    $query .= "    (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(if(rawExp.comment LIKE '%visit 1%',1,NULL)) AS Nvis1,";
     466    $query .= "    count(if(rawExp.comment LIKE '%visit 2%',1,NULL)) AS Nvis2,count(if(rawExp.comment LIKE '%visit 3%',1,NULL)) AS Nvis3,";
     467    $query .= "    count(if(rawExp.comment LIKE '%visit 4%',1,NULL)) AS Nvis4, count(if(camProcessedExp.sigma_ra <= 5 AND camProcessedExp.sigma_dec <= 5 AND camProcessedExp.quality = 0,1,NULL)) AS Ncamgood,";
     468    $query .= "    count(if(camProcessedExp.sigma_ra > 5 OR camProcessedExp.sigma_dec > 5 OR camProcessedExp.quality > 0,1,NULL)) AS Ncambad";
     469    $query .= "    FROM rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) JOIN camProcessedExp USING (cam_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id)";
     470    $query .= "    WHERE dateobs like '$date%' AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%'";
     471    $query .= "    AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
     472    $query .= "    GROUP BY chunk ORDER BY dateobs) as suba ";
     473    $query .= "LEFT JOIN";
     474    $query .= "    (SELECT subc.chunk, count(if(subc.Nwarpskycellbad < subc.Nwarpskycell,1,NULL)) AS Nwarpgood, count(if(subc.Nwarpskycellbad = subc.Nwarpskycell,1,NULL)) AS Nwarpbad";
     475    $query .= "    FROM ";
     476    $query .= "      (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(warpSkyfile.quality) AS Nwarpskycell,count(if(warpSkyfile.quality > 0,1,NULL)) AS Nwarpskycellbad";
     477    $query .= "      FROM rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) JOIN warpSkyfile USING (warp_id)";
     478    $query .= "      WHERE dateobs like '$date%' AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%'";
     479    $query .= "      AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
     480    $query .= "      GROUP BY exp_name) as subc";
     481    $query .= "    GROUP BY chunk) AS subb ";
     482    $query .= "ON suba.chunk=subb.chunk";
    492483
    493484    $qry = $projectdb->query($query);
    494485    if (dberror($qry)) {
    495         echo "<b>error reading rawExp table</b><br>\n";
     486        echo "<b>error querying SQL table</b><br>\n";
    496487        echo "<br><small><b> table query : $query </b></small><br>\n";
    497488        menu_end();
     
    502493    echo $table;
    503494    echo "<tr>";
    504     createTableTitle("Status of last night's chunks", 5);
     495    createTableTitle("Status of last night's chunks", 10);
    505496    echo "<tr>";
    506497    createTableColumnHeader("Chunk");
    507     createTableColumnHeader("Nobs_1stvisit");
    508     createTableColumnHeader("Nobs_4visits(bad cam)");
    509     createTableColumnHeader("Ndiffs_published");
     498    createTableColumnHeader("Nobs");
     499    createTableColumnHeader("Ncam");
     500    createTableColumnHeader("Nwrp");
     501    createTableColumnHeader("wrp_pub");
     502    createTableColumnHeader("Nwwd");
     503    createTableColumnHeader("wwd_pub");
     504    createTableColumnHeader("Nwsd");
     505    createTableColumnHeader("wsd_pub");
    510506    createTableColumnHeader("Completion");
    511507
     
    514510    // list the results
    515511    while ($qry->fetchInto($row)) {
    516         $Nfirstvisits = 0;
    517         $Nfourvisits = 0;
    518         $badcam = 0;
     512        $Nvis1 = 0;
     513        $Nvis2 = 0;
     514        $Nvis3 = 0;
     515        $Nvis4 = 0;
     516        $Ncamgood = 0;
     517        $Ncambad = 0;
     518        $Nwarpgood = 0;
     519        $Nwarpbad = 0;
     520        $NexpWWdiff = 0;
     521        $Npubwarps = 0;
    519522
    520523        $chunkname = $row[0];
    521         if($row[1] > 0) $Nfirstvisits = $row[1];
    522         if($row[2] > 0) $Nfourvisits = $row[2];
    523 
    524         $query2 = "     SELECT warp_id FROM ";
    525         $query2 .= "           warpRun JOIN fakeRun USING (fake_id) JOIN camRun USING (cam_id) JOIN camProcessedExp USING (cam_id) JOIN chipRun USING (chip_id) JOIN rawExp USING (exp_id)";
    526         $query2 .= "           WHERE rawExp.dateobs LIKE '$date%' AND exp_id > $refExpID[0] AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
    527         $query2 .= "           AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%'";
     524        if($row[1] > 0) $Nvis1 = $row[1];
     525        if($row[2] > 0) $Nvis2 = $row[2];
     526        if($row[3] > 0) $Nvis3 = $row[3];
     527        if($row[4] > 0) $Nvis4 = $row[4];
     528        if($row[5] > 0) $Ncamgood = $row[5];
     529        if($row[6] > 0) $Ncambad = $row[6];
     530        if($row[7] > 0) $Nwarpgood = $row[7];
     531        if($row[8] > 0) $Nwarpbad = $row[8];
     532
     533        #set flags if present
     534        if($Ncambad >= 1) $badcamflag = 1;
     535        if($Nwarpbad >= 1) $badwarpflag = 1;
     536
     537        $query1 = "SELECT suba.chunk, SUM(IF(suba.Nvisits = 2,1,NULL)) as totvis2, SUM(IF(suba.Nvisits = 3 OR suba.Nvisits = 4,2,NULL)) as totvis34 FROM";
     538        $query1 .= "    (SELECT substr(comment, 1, position(' ' in comment)) AS chunk,count(distinct(comment)) AS Nvisits FROM";
     539        $query1 .= "    rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) WHERE dateobs like '$date%'";
     540        $query1 .= "    AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%') AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL'";
     541        $query1 .= "    AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%' group by object) as suba group by chunk;";
     542        $qry1 = $projectdb->query($query1);
     543        while ($qry1->fetchInto($row)) {$NexpWWdiff = $row[1] + $row[2];}
     544
     545        #find the unique diff_ids for each chunk, to be matched to the diffRun catalog
     546        $query2 = "     SELECT diff_id,warp1,stack1,warp2,stack2 FROM ";
     547        $query2 .= "           diffInputSkyfile JOIN warpRun ON (warp1=warp_id OR warp2=warp_id) JOIN fakeRun USING (fake_id) JOIN camRun USING (cam_id) JOIN camProcessedExp USING (cam_id) JOIN chipRun USING (chip_id) JOIN rawExp USING (exp_id)";
     548        $query2 .= "           WHERE rawExp.dateobs LIKE '$date%' AND exp_id > $refExpID[0] AND exp_type = 'OBJECT' AND rawExp.comment like '%visit%' AND (obs_mode LIKE '%SS%' OR obs_mode LIKE '%BRIGHT%')";
     549        $query2 .= "            AND obs_mode NOT LIKE 'ENGINEERING' AND obs_mode NOT LIKE 'MANUAL' AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%' GROUP By diff_id";
    528550        $qry2 = $projectdb->query($query2);
    529551
    530         $Ndiffs = 0;
     552        $NWWdiffgood = 0;
     553        $NWWdiffbad = 0;
     554        $NWWdiffpub = 0;
     555
     556        $NWSdiffgood = 0;
     557        $NWSdiffbad = 0;
     558        $NWSdiffpub = 0;
     559        $wrpcnt = array();
     560
    531561        while ($qry2->fetchInto($row2)) {
    532             $query3 = "     SELECT diff_id FROM ";
    533             $query3 .= "           diffRun JOIN diffInputSkyfile USING (diff_id) JOIN publishRun ON (diff_id = stage_id) JOIN warpRun ON (warp1=warp_id)";
    534             $query3 .= "           WHERE stack2 IS NULL AND publishRun.state LIKE 'full' AND warp_id='$row2[0]' GROUP BY diff_id";
    535             $qry3 = $projectdb->query($query3);
    536             while ($qry3->fetchInto($row3)) {
    537                 if ($row3[0] !=0) $Ndiffs ++;
    538             }
    539 
    540             $query3 = "     SELECT diff_id FROM ";
    541             $query3 .= "           diffRun JOIN diffInputSkyfile USING (diff_id) JOIN publishRun ON (diff_id = stage_id) JOIN warpRun ON (warp2=warp_id)";
    542             $query3 .= "           WHERE stack2 IS NULL AND publishRun.state LIKE 'full' AND warp_id='$row2[0]' GROUP BY diff_id";
    543             $qry3 = $projectdb->query($query3);
    544             while ($qry3->fetchInto($row3)) {
    545                 if ($row3[0] !=0) $Ndiffs ++;
    546             }
     562              #distinguish between WW and WS diffs based on stack2
     563              if ($row2[4] == 0) {
     564                  #find the total number of skycell and the number of skycell with a bad quality flag as well as the full publish state
     565                  $query3 = "     SELECT count(diffSkyfile.quality) AS Ndiff,count(if(diffSkyfile.quality > 0,1,NULL)) AS Ndiffbad,count(if(publishRun.state LIKE 'full',1,NULL)) AS Npub FROM ";
     566                  $query3 .= "           diffRun JOIN diffSkyfile USING (diff_id) LEFT JOIN publishRun ON (diffRun.diff_id = stage_id)";
     567                  $query3 .= "           WHERE diff_id='$row2[0]' GROUP BY diffRun.diff_id";
     568                  $qry3 = $projectdb->query($query3);
     569
     570                  while ($qry3->fetchInto($row3)) {
     571                      #if all skycells have bad quality, this is a bad diff. If all the skycells are in a full state in publishRun, it is fully published
     572                      if ($row3[1]<$row3[0]) $NWWdiffgood ++;
     573                      if ($row3[1]==$row3[0]) $NWWdiffbad ++;
     574                      if ($row3[2]==$row3[0]) $NWWdiffpub ++;
     575
     576                      #if this wwdiff is published, record its corresponding warp_ids to see how many unique ones there are
     577                      if ($row3[2]==$row3[0]) $wrpcnt{$row2[1]}++;  # record the presence of warp1
     578                      if ($row3[2]==$row3[0]) $wrpcnt{$row2[3]}++;  # record the presence of warp2
     579                  }
     580              }
     581
     582              if ($row2[4] > 0) {
     583                  #find the total number of skycell and the number of skycell with a bad quality flag as well as the full publish state
     584                  $query3 = "     SELECT count(diffSkyfile.quality) AS Ndiff,count(if(diffSkyfile.quality > 0,1,NULL)) AS Ndiffbad,count(if(publishRun.state LIKE 'full',1,NULL)) AS Npub FROM ";
     585                  $query3 .= "           diffRun JOIN diffSkyfile USING (diff_id) LEFT JOIN publishRun ON (diffRun.diff_id = stage_id)";
     586                  $query3 .= "           WHERE diff_id='$row2[0]' GROUP BY diffRun.diff_id";
     587                  $qry3 = $projectdb->query($query3);
     588
     589                  while ($qry3->fetchInto($row3)) {
     590                      #if all skycells have bad quality, this is a bad diff. If all the skycells are in a full state in publishRun, it is fully published
     591                      if ($row3[1]<$row3[0]) $NWSdiffgood ++;
     592                      if ($row3[1]==$row3[0]) $NWSdiffbad ++;
     593                      if ($row3[2]==$row3[0]) $NWSdiffpub ++;
     594                  }
     595              }
    547596        }
    548 
    549         if ($Ndiffs != ($Nfirstvisits*4)) $complete = "chunk not done"; 
    550         if ($Ndiffs == ($Nfirstvisits*4)) $complete = "chunk done";       
    551 
    552         if ($Nfirstvisits != $Nfourvisits) {
    553             $Ndiffs .= "/?  ";
     597        #pull out the unique warp_ids
     598        $Npubwarps = count($wrpcnt);
     599
     600        #check for bad diffs
     601        if(($NWWdiffbad >= 1) or ($NWSdiffbad >= 1)) $baddiffflag = 1;
     602
     603        if ($Nvis1 != $Nvis4) {
     604          if ($NWWdiffpub != $NexpWWdiff) $complete = "chunk incomplete, not done"; 
     605          if ($NWWdiffpub == $NexpWWdiff) $complete = "chunk incomplete, done"; 
    554606        }
    555         if ($Nfirstvisits == $Nfourvisits) {
    556             $Ndiffs .= "/";
    557             $Ndiffs .= $Nfirstvisits*4;
     607        if ($Nvis1 == $Nvis4) {
     608          if ($NWWdiffpub != $NexpWWdiff) $complete = "chunk complete, not done"; 
     609          if ($NWWdiffpub == $NexpWWdiff) $complete = "chunk complete, done"; 
     610
    558611        }
    559612
    560         #also query for bad quality camRun exposures
    561         $query4 = "SELECT count(*) ";
    562         $query4 .= " FROM rawExp";
    563         $query4 .= " JOIN chipRun USING (exp_id)";
    564         $query4 .= " JOIN camRun USING (chip_id)";
    565         $query4 .= " JOIN camProcessedExp USING (cam_id)";
    566         $query4 .= " WHERE dateobs LIKE '$date%'";
    567         $query4 .= " AND exp_id > $refExpID[0]";
    568         $query4 .= " AND exp_type = 'OBJECT'";
    569         $query4 .= " AND substr(comment, 1, position(' ' in comment)) LIKE '$chunkname%'";
    570         $query4 .= " AND (camProcessedExp.quality > 0)";
    571         $qry4 = $projectdb->query($query4);
    572         $qry4->fetchInto($badcam);
    573 
    574 
    575 
    576613        echo "<tr>";
    577614
    578615        echo "<td>$chunkname</td>";
    579         echo "<td>$Nfirstvisits</td>";
    580         if ($badcam[0]==0) {
    581            echo "<td>$Nfourvisits</td>";
    582         } else {
    583            $DLStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">$Nfourvisits ($badcam[0])</font>";
    584            echo "<td>$DLStatus</td>";
    585         }
    586         echo "<td>$Ndiffs</td>";
     616        echo "<td>$Nvis1/$Nvis2/$Nvis3/$Nvis4</td>";
     617        echo "<td>$Ncamgood/$Ncambad</td>";
     618        echo "<td>$Nwarpgood/$Nwarpbad</td>";
     619        echo "<td>$Npubwarps</td>";
     620        echo "<td>$NWWdiffgood/$NWWdiffbad</td>";
     621        echo "<td>$NWWdiffpub</td>";
     622        echo "<td>$NWSdiffgood/$NWSdiffbad</td>";
     623        echo "<td>$NWSdiffpub</td>";
    587624        echo "<td>$complete</td>";
    588625
    589626        echo "</tr>";
    590627    }
    591     echo "</table>\n";
     628
     629
     630    // timer finished
     631    echo "<tr><th colspan=10>";
     632    $time = microtime();
     633    $time = explode(' ', $time);
     634    $time = $time[1] + $time[0];
     635    $finish = $time;
     636    $total_time = round(($finish - $start), 3);
     637    echo "loading in $total_time seconds.";
     638    $start= $finish;
     639    echo "</th></tr>";
     640    echo "</table></br>";
    592641
    593642}
     
    631680        $selectedLabel, $selectedStage, $plotType) {
    632681
     682    // timer start
     683    $time = microtime();
     684    $time = explode(' ', $time);
     685    $time = $time[1] + $time[0];
     686    $start = $time;
     687
     688    // function begin
    633689    $isUpdate = ($selectedMode == "update");
    634690    global $headerColor;
     
    754810
    755811    echo "</tr>\n";
    756     echo "</table>\n";
     812
     813    // timer finished
     814    echo "<tr><th colspan=11>";
     815    $time = microtime();
     816    $time = explode(' ', $time);
     817    $time = $time[1] + $time[0];
     818    $finish = $time;
     819    $total_time = round(($finish - $start), 3);
     820    echo "loading in $total_time seconds.";
     821    $start= $finish;
     822    echo "</th></tr>";
     823    echo "</table><br>";
    757824}
    758825
     
    902969function createDatesTable($db, $proj) {
    903970
     971    // timer start
     972    $time = microtime();
     973    $time = explode(' ', $time);
     974    $time = $time[1] + $time[0];
     975    $start = $time;
     976
     977    // function begin
    904978    global $table;
    905979    echo $table;
     
    914988    createServerDateRow($db, $proj, "registration");
    915989
    916     echo "</table>\n";
     990    // timer finished
     991    echo "<tr><th colspan=11>";
     992    $time = microtime();
     993    $time = explode(' ', $time);
     994    $time = $time[1] + $time[0];
     995    $finish = $time;
     996    $total_time = round(($finish - $start), 3);
     997    echo "loading in $total_time seconds.";
     998    $start= $finish;
     999    echo "</th></tr>";
     1000    echo "</table><br>";
     1001
    9171002}
    9181003
     
    9561041function createServersTable($pass, $proj, $selectedMode, $db, $servers, $selectedLabel, $selectedStage, $plotType) {
    9571042
     1043    // timer start
     1044    $time = microtime();
     1045    $time = explode(' ', $time);
     1046    $time = $time[1] + $time[0];
     1047    $start = $time;
     1048
     1049    // function begin
    9581050    // set up table columns
    9591051    global $table;
     
    10421134    }
    10431135
    1044     echo "</table>\n";
     1136    // timer finished
     1137    echo "<tr><th colspan=5>";
     1138    $time = microtime();
     1139    $time = explode(' ', $time);
     1140    $time = $time[1] + $time[0];
     1141    $finish = $time;
     1142    $total_time = round(($finish - $start), 3);
     1143    echo "loading in $total_time seconds.";
     1144    $start= $finish;
     1145    echo "</th></tr>";
     1146    echo "</table><br>\n";
    10451147}
    10461148
     
    10841186function getServerStatus($db,$proj, $server, &$alive, &$running) {
    10851187
    1086     $sql = "SELECT alive, running FROM science_servers WHERE server LIKE '$server' AND telescope LIKE '$proj' ORDER BY timestamp DESC LIMIT 1";
     1188#    $sql = "SELECT alive, running FROM science_servers WHERE server LIKE '$server' AND telescope LIKE '$proj' ORDER BY timestamp DESC LIMIT 1";
     1189    $sql = "SELECT alive, running FROM live_servers WHERE server LIKE '$server' AND telescope LIKE '$proj' ORDER BY timestamp DESC LIMIT 1";
    10871190    if($debug){echo "$sql<br>";}
    10881191
     
    12031306###########################################################################
    12041307function showPingStatus($Host, $DatabaseName) {
     1308    // timer start
     1309    $time = microtime();
     1310    $time = explode(' ', $time);
     1311    $time = $time[1] + $time[0];
     1312    $start = $time;
     1313
     1314    // function begin
    12051315    exec("ping -c 1 $Host", $res, $rval);
    12061316    if ($rval == 0){
     
    12091319      $PingStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">DOWN</font>";
    12101320    }
    1211     echo "<tr><td>$DatabaseName</td><td>$PingStatus</td></tr>";
    1212 }
    1213 
     1321    echo "<tr><td>$DatabaseName</td>";
     1322
     1323    echo "</td><td>$PingStatus</td>";
     1324    // timer finished
     1325    echo "<td>";
     1326    $time = microtime();
     1327    $time = explode(' ', $time);
     1328    $time = $time[1] + $time[0];
     1329    $finish = $time;
     1330    $total_time = round(($finish - $start), 3);
     1331    echo "$total_time seconds";
     1332    $start= $finish;
     1333    echo "</td></tr>";
     1334}
     1335
     1336
     1337###########################################################################
     1338#
     1339# Creates a table of summitExp against rawExp
     1340#
     1341###########################################################################
     1342function createSummitDataTable($projectdb) {
     1343
     1344    // timer start
     1345    $time = microtime();
     1346    $time = explode(' ', $time);
     1347    $time = $time[1] + $time[0];
     1348    $start = $time;
     1349
     1350    // function begin
     1351    $date = date("Y-m-d");
     1352    $sql = "SELECT DISTINCT exp_type FROM summitExp WHERE dateobs > '$date'";
     1353
     1354    $qry = $projectdb->query($sql);
     1355    if (dberror($qry)) {
     1356        echo "<b>error reading newExp table</b><br>\n";
     1357        echo "<br><small><b> table query : $sql </b></small><br>\n";
     1358        menu_end();
     1359    }
     1360
     1361    // set up the table
     1362    global $table;
     1363    echo $table;
     1364    echo "<tr>";
     1365    createTableTitle("Data status > $date", 4);
     1366    echo "<tr>";
     1367    createTableColumnHeader("Exposure type");
     1368    createTableColumnHeader("At summit");
     1369    createTableColumnHeader("Registered at MHPCC");
     1370    createTableColumnHeader("Summit (Drop/Null)");
     1371
     1372    $msg = "No science images taken since $date";
     1373
     1374    // list the results
     1375    while ($qry->fetchInto($expType)) {
     1376
     1377        $sql = "SELECT COUNT(*) FROM summitExp LEFT JOIN pzDownloadExp USING (summit_id)
     1378                WHERE dateobs > '$date' AND exp_type = '$expType[0]'";
     1379             //   AND state != 'drop' AND state is not null AND fault != 1042";
     1380        $qry2 = $projectdb->query($sql);
     1381        $qry2->fetchInto($summit);
     1382
     1383        $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name
     1384                WHERE summitExp.dateobs > '$date' AND rawExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
     1385        $qry2 = $projectdb->query($sql);
     1386        $qry2->fetchInto($mhpcc);
     1387
     1388        $sql = "SELECT COUNT(*) FROM summitExp LEFT JOIN pzDownloadExp USING (summit_id)
     1389                WHERE dateobs > '$date' AND exp_type = '$expType[0]' AND (state = 'drop' OR state is null)";
     1390        $qry2 = $projectdb->query($sql);
     1391        $qry2->fetchInto($dropped);
     1392
     1393
     1394        #Query with 30 minutes delay to check during the night if any exposures are missing.
     1395        $datehour = gmdate("Y-m-d H:i:s");
     1396        $sql = "SELECT COUNT(*) FROM summitExp LEFT JOIN pzDownloadExp USING (summit_id)
     1397                WHERE dateobs > '$date' AND dateobs <= date_sub('$datehour', interval 30 minute)
     1398                AND exp_type = '$expType[0]' AND (state != 'drop' OR state is null) and fault != 1042";
     1399
     1400        $qry2 = $projectdb->query($sql);
     1401        $qry2->fetchInto($summitdelay);
     1402
     1403        $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name
     1404                WHERE summitExp.dateobs > '$date' AND summitExp.dateobs <= date_sub('$datehour', interval 30 minute)
     1405                AND rawExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
     1406        $qry2 = $projectdb->query($sql);
     1407        $qry2->fetchInto($mhpccdelay);
     1408
     1409        echo "<tr>";
     1410
     1411        $DLdiff = $summit[0] - $mhpcc[0];
     1412        if ($DLdiff == 0) $error = 0;
     1413        else $error = 1;
     1414
     1415        $delayDLdiff = $summitdelay[0] - $mhpccdelay[0];
     1416        if ($delayDLdiff == 0) $errordelay = 0;
     1417        else $errordelay = 1;
     1418
     1419        echo "<td>$expType[0]</td>";
     1420        echo "<td>$summit[0]</td>";
     1421        if ($delayDLdiff==0) {
     1422           createFormattedTableCell("", "", $mhpcc[0], $error, 0);
     1423        } else {
     1424           $DLStatus = "<font style=\"BACKGROUND-COLOR: yellow\"  color=\"red\">$mhpcc[0] ($delayDLdiff)</font>";
     1425           echo "<td>$DLStatus</td>";
     1426        }
     1427
     1428        echo "<td>$dropped[0]</td>";
     1429
     1430        echo "</tr>";
     1431    }
     1432
     1433    // timer finished
     1434    echo "<tr><th colspan=4>";
     1435    $time = microtime();
     1436    $time = explode(' ', $time);
     1437    $time = $time[1] + $time[0];
     1438    $finish = $time;
     1439    $total_time = round(($finish - $start), 3);
     1440    echo "loading in $total_time seconds.";
     1441    $start= $finish;
     1442    echo "</th></tr>";
     1443    echo "</table><br>";
     1444}
     1445
     1446
     1447function createSummitDataTable2($projectdb) {
     1448
     1449    // timer start
     1450    $time = microtime();
     1451    $time = explode(' ', $time);
     1452    $time = $time[1] + $time[0];
     1453    $start = $time;
     1454
     1455    // function begin
     1456    $date = date("Y-m-d");
     1457    // set up the table
     1458    global $table;
     1459    global $columnHeaderColor;
     1460    echo $table;
     1461    echo "<tr>";
     1462    createTableTitle("Data status > $date", 4);
     1463    echo "<tr>";
     1464    createTableColumnHeader("Exp_type at summit");
     1465    createTableColumnHeader("Status at summit");
     1466    createTableColumnHeader("Status at mhpcc");
     1467    createTableColumnHeader("Number");
     1468    $sql = "SELECT summitExp.exp_type,pzDownloadExp.state,rawExp.state,COUNT(*) FROM summitExp
     1469            LEFT JOIN pzDownloadExp USING (summit_id) LEFT JOIN rawExp on summitExp.exp_name = rawExp.exp_name
     1470            WHERE summitExp.dateobs > '$date' group by summitExp.exp_type,pzDownloadExp.state,rawExp.state";
     1471    $qry = $projectdb->query($sql);
     1472    while ($qry->fetchInto($tmp)) {
     1473        if ($tmp[1] == NULL) {
     1474          echo  "<tr><td>$tmp[0]<td> null <td> null <td bgcolor=\"yellow\"> <font color=\"red\">$tmp[3]";
     1475        }
     1476        else {
     1477          if ($tmp[1] == 'run') {
     1478            echo  "<tr><td>$tmp[0]<td> loading <td> null <td bgcolor=$columnHeaderColor> <font color=\"red\">$tmp[3]";
     1479          }
     1480          else {
     1481            if ($tmp[2] == NULL) {
     1482              echo  "<tr><td>$tmp[0] <td> $tmp[1] <td> loading <td bgcolor=$columnHeaderColor> <font color=\"blue\">$tmp[3]";
     1483            }
     1484            else {
     1485              echo  "<tr><td>$tmp[0]<td> $tmp[1] <td> downloaded <td> $tmp[3]";
     1486            }
     1487          }
     1488        }
     1489    }
     1490
     1491    // timer finished
     1492    echo "<tr><th colspan=4>";
     1493    $time = microtime();
     1494    $time = explode(' ', $time);
     1495    $time = $time[1] + $time[0];
     1496    $finish = $time;
     1497    $total_time = round(($finish - $start), 3);
     1498    echo "loading in $total_time seconds.";
     1499    $start= $finish;
     1500    echo "</th></tr>";
     1501    echo "</table><br>";
     1502}
    12141503?>
    12151504
  • branches/eam_branches/ipp-20191011/ippMonitor/raw/ipp.php

    r40842 r41170  
    351351  // loop over the lines in the file and generate lines in the menu
    352352  while ($line = fgetcsv ($file, 1024, "|")) {
    353     if (ereg ('^[:blank:]*#', $line[0])) continue;
     353    if (preg_match ("/#/", $line[0])) continue;
     354 // if (ereg ('^[:blank:]*#', $line[0])) continue;
    354355    if (count($line) < 2) continue;
    355356
  • branches/eam_branches/ipp-20191011/ippMonitor/raw/site.php.in

    r40432 r41170  
    1313$DBI     = "@DBI@";
    1414
     15// location of plots produced by czarpoll.pl
     16$CZARPLOTDIR     = "./czartool_plots";
     17$METRICSPLOTDIR  = "./ippMetrics";
     18
    1519// insert config.dat here. this contains a number of system-specific things like
    1620// the names of database machines and users
Note: See TracChangeset for help on using the changeset viewer.