IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28000 for trunk


Ignore:
Timestamp:
May 18, 2010, 11:48:05 AM (16 years ago)
Author:
rhenders
Message:

Now sharing some perl scripts with ippMonitor version of czartool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czartool.pl

    r27913 r28000  
    1616if (!$db) {die;}
    1717
    18 my @stdscienceLabels = loadLabels("stdscience");
    19 my @distributionLabels = loadLabels("distribution");
    20 showLabelDifferences();
     18my @stdscienceLabels = `getLabels.pl -s stdscience`;
     19my @distributionLabels = `getLabels.pl -s distribution`;
    2120
    2221checkAllLabels("new");
     
    5453        elsif ($key eq "w") {checkAllLabels("wait");}
    5554        elsif ($key eq "l") {labelDetails();}
     55        elsif ($key eq "u") {serverStatus("stdscience");}
    5656        elsif ($key =~ m/[0-9]/) {my $key2=getc; checkOneLabel($stdscienceLabels[$key.$key2]);}
    5757        printInstructions();
     
    8484###########################################################################
    8585#
    86 # Display label differences between stdscience and distribution
    87 #
    88 ###########################################################################
    89 sub showLabelDifferences {
    90 
    91     my @diffLabels = @{getArrayDifferences(\@stdscienceLabels, \@distributionLabels)};
    92 
    93     printf("+-------------------------------------------------------+\n");
    94     printf("| Label differences between stdscience and distribution |\n");
    95     printf("+-------------------------------------------------------+\n");
    96 
    97     my $item;
    98     foreach $item (@diffLabels) {
    99 
    100         printf( "| %53s |\n", $item);
    101     }
    102     printf("+-------------------------------------------------------+\n");
    103 }
    104 
    105 ###########################################################################
    106 #
    10786# Compares two arrays and stores the differences
    10887#
     
    133112###########################################################################
    134113#
    135 # Loads labels from a particular pantasks server
    136 #
    137 ###########################################################################
    138 sub loadLabels {
     114# Prints the status of a given pantasks server
     115#
     116###########################################################################
     117sub serverStatus {
    139118    my ($server) = @_;
    140119
    141     my @cmdOut = `echo "show.labels;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;
     120    my @cmdOut = `echo "status;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;
    142121    my $line;
    143     my @labels;
    144     my $passedHeader=0;
    145122    foreach $line (@cmdOut) {
    146123
    147124        chomp($line);
    148         if ($line =~ m/pantasks:\s+(.*)/) {
    149            
    150             # HACK to get around 'dummy' label in stdscience
    151             if ($1 !~ m/.*dummy.*/) {push(@labels, $1);}
    152             $passedHeader=1;
    153             next;
    154         }
    155        
    156         if ($passedHeader){push(@labels, $line);}
    157     }
    158 
    159     return @labels;
     125   
     126        print "$line\n";
     127    }
    160128}
    161129
     
    176144    foreach $server (@servers) {
    177145
     146        my @results = `checkServer.pl -s $server`;
     147
    178148        printf("| %12s ", $server);
    179 
    180         my @cmdOut = `echo "status ;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;
    181 
    182         my $line;
    183         my $foundStatus = 0;
    184         my $isRunning = 0;
    185         foreach $line (@cmdOut) {
    186 
    187             chomp($line);
    188             if ($line =~ m/Scheduler is stopped/) {$isRunning = 0; $foundStatus=1;last;}
    189             if ($line =~ m/Scheduler is running/) {$isRunning = 1; $foundStatus=1;last;}
    190             if ($line =~ m/Task Staus/) {last;}
    191 
    192         }
    193 
    194         if (!$foundStatus){print "|    NO   ";} else {print "|   yes   ";}
    195         if (!$isRunning){print "|           NO         ";} else {print "|          yes         ";}
    196         printf("|\n");
     149        chomp($results[0]);
     150        chomp($results[1]);
     151        printf("|   %3s   |         %3s          |\n", $results[0], $results[1]);
    197152    }
    198153
     
    263218sub checkAllLabels {
    264219    my ($state) = @_;
    265 
    266     printf("\n+------------------------------------------------------------------------------------------------------------------------------------------------------------+\n");
    267     printf("|                                                                         %10s                                                                         |\n", $state);
    268     printf("+------------------------------------------------------------------------------------------------------------------------------------------------------------+\n");
    269     printf("| no  |              label               |    chip   |    cam     |    fake    |    warp    |   stack    |    diff    |   magic    |  destreak  |    dist    |\n");
    270     printf("+-----+----------------------------------+-----------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
    271 
    272     my $label;
     220#print time, $/;
     221    printf("\n+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n");
     222    printf("|                                                                           %10s (any faults are shown in parentheses)                                                  |\n", $state);
     223    printf("+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n");
     224    printf("| no  |              label               | distributing? |    chip    |    cam     |    fake    |    warp    |   stack    |    diff    |   magic    |  destreak  |    dist    |\n");
     225    printf("+-----+----------------------------------+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
     226
     227    my $stdsLabel;
     228    my $distLabel;
    273229    my $i=0;
    274     foreach $label (@stdscienceLabels) {
    275 
    276         chomp($label);
     230    my $distributing;
     231    foreach $stdsLabel (@stdscienceLabels) {
     232
     233    $distributing = 0;
     234        foreach $distLabel (@distributionLabels) {
     235            chomp($stdsLabel);
     236            if ($stdsLabel eq $distLabel) { $distributing = 1; last;}
     237
     238
     239        }
     240        chomp($stdsLabel);
    277241        printf("| %3d ", $i);
    278         printf("| %32s ", $label);
    279         printf("| %10s", getStateAndFaults($label, "chipRun", $state, "chip"));
    280         printf("| %10s ", getStateAndFaults($label, "camRun", $state, "cam"));
    281         printf("| %10s ", getStateAndFaults($label, "fakeRun", $state, "fake"));
    282         printf("| %10s ", getStateAndFaults($label, "warpRun", $state, "warp"));
    283         printf("| %10s ", getStateAndFaults($label, "stackRun", $state, "stack"));
    284         printf("| %10s ", getStateAndFaults($label, "diffRun", $state, "diff"));
    285         printf("| %10s ", getStateAndFaults($label, "magicRun", $state, "magic"));
    286         printf("| %10s ", getStateAndFaults($label, "magicDSRun", $state, "magicDS"));
    287         printf("| %10s ", getStateAndFaults($label, "distRun", $state, "dist"));
     242        printf("| %32s ", $stdsLabel);
     243        printf("| %10s    ", $distributing ? "yes" : "NO" );
     244        printf("| %10s ", getStateAndFaults($stdsLabel, "chipRun", $state, "chip"));
     245        printf("| %10s ", getStateAndFaults($stdsLabel, "camRun", $state, "cam"));
     246        printf("| %10s ", getStateAndFaults($stdsLabel, "fakeRun", $state, "fake"));
     247        printf("| %10s ", getStateAndFaults($stdsLabel, "warpRun", $state, "warp"));
     248        printf("| %10s ", getStateAndFaults($stdsLabel, "stackRun", $state, "stack"));
     249        printf("| %10s ", getStateAndFaults($stdsLabel, "diffRun", $state, "diff"));
     250        printf("| %10s ", getStateAndFaults($stdsLabel, "magicRun", $state, "magic"));
     251        printf("| %10s ", getStateAndFaults($stdsLabel, "magicDSRun", $state, "magicDS"));
     252        printf("| %10s ", getStateAndFaults($stdsLabel, "distRun", $state, "dist"));
    288253        printf("|\n");
    289254        $i++;
    290255    }
    291256
    292     printf("+-----+----------------------------------+-----------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
     257    printf("+-----+----------------------------------+---------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n");
    293258
    294259}
Note: See TracChangeset for help on using the changeset viewer.