Subversion Repositories DevTools

Rev

Rev 267 | Rev 275 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 267 Rev 271
Line 37... Line 37...
37
my %rc;
37
my %rc;
38
my %rl;
38
my %rl;
39
my %rname;
39
my %rname;
40
my %official;
40
my %official;
41
my $indefinite = 0;
41
my $indefinite = 0;
42
my %StateData = ( 4 => 'Idle' , 2 => 'Paused', 5 => 'Waiting', 3 => 'Building', 1 => 'Broken');
-
 
43
my $ff_string = "\f";
42
my $ff_string = "\f";
-
 
43
my $dead_time = ( 5 * 60 ) * 2;
-
 
44
my %StateData = ( 1 => 'Disk Full',
-
 
45
                  2 => 'Paused',
-
 
46
                  3 => 'Active',
-
 
47
                  4 => 'Idle' ,
-
 
48
                  5 => 'Waiting',
-
 
49
                  6 => 'Publishing',
-
 
50
                  );
44
 
51
 
45
#-------------------------------------------------------------------------------
52
#-------------------------------------------------------------------------------
46
# Function        : Main Entry
53
# Function        : Main Entry
47
#
54
#
48
# Description     :
55
# Description     :
Line 52... Line 59...
52
# Returns         :
59
# Returns         :
53
#
60
#
54
my $result = GetOptions (
61
my $result = GetOptions (
55
                "help:+"        => \$opt_help,          # flag, multiple use allowed
62
                "help:+"        => \$opt_help,          # flag, multiple use allowed
56
                "manual:3"      => \$opt_help,          # flag
63
                "manual:3"      => \$opt_help,          # flag
57
                "verbose:+"     => \$opt_verbose,      # flag
64
                "verbose:+"     => \$opt_verbose,       # flag
58
                "repeat=i"      => \$opt_repeat,        # Integer
65
                "repeat=i"      => \$opt_repeat,        # Integer
59
                "short:+"       => \$opt_short,         # Flag
66
                "short:+"       => \$opt_short,         # Flag
60
                "color"         => \$opt_color,         # Flag
67
                "color"         => \$opt_color,         # Flag
61
                "rtag=s"        => \@opt_rtag,          # Array
68
                "rtag=s"        => \@opt_rtag,          # Array
62
                "filter"        => \$opt_filter,        # Flag
69
                "filter"        => \$opt_filter,        # Flag
Line 158... Line 165...
158
        {
165
        {
159
            my $rtag_id = $pname{$pname}{$rname};
166
            my $rtag_id = $pname{$pname}{$rname};
160
            my @orderm;
167
            my @orderm;
161
            my @orders;
168
            my @orders;
162
            my $building = 0;
169
            my $building = 0;
-
 
170
            my $dead = 0;
-
 
171
            my $paused = 0;
-
 
172
            my $in_error = 0;
-
 
173
            
163
 
174
 
164
            foreach my $rcon_id ( keys %{$rc{$rtag_id}}  )
175
            foreach my $rcon_id ( keys %{$rc{$rtag_id}}  )
165
            {
176
            {
-
 
177
                next unless ( exists $rl{$rcon_id} );
-
 
178
 
-
 
179
                #
-
 
180
                #   Maintain alive info
-
 
181
                #
-
 
182
                if ( $rl{$rcon_id}{deltat} )
-
 
183
                {
-
 
184
                    if ( $rl{$rcon_id}{deltat} > $dead_time )
-
 
185
                    {
-
 
186
                        $dead = 1;
-
 
187
                    }
-
 
188
                }
166
 
189
 
167
                #
190
                #
168
                #   Determine if any of the machines are building a package
191
                #   Determine if any of the machines are building a package
169
                #
192
                #
170
                $building = 1 if ( $rl{$rcon_id}{cpid} );
193
                $building = 1 if ( $rl{$rcon_id}{cpid} );
Line 179... Line 202...
179
                }
202
                }
180
                else
203
                else
181
                {
204
                {
182
                    push @orders, $rcon_id;
205
                    push @orders, $rcon_id;
183
                }
206
                }
-
 
207
 
-
 
208
                #
-
 
209
                #   Paused deamons don't maintain alive data
-
 
210
                #
-
 
211
                $paused += 1
-
 
212
                    if ( $rl{$rcon_id}{crl} == 2 );
-
 
213
 
-
 
214
                $dead = 0
-
 
215
                    if ( $paused );
-
 
216
 
-
 
217
                $in_error ++
-
 
218
                    if ( $rl{$rcon_id}{crl} == 1 );
-
 
219
                
184
            }
220
            }
185
 
221
 
186
            if ( $building || $opt_short < 2  )
222
            if ( $in_error || $dead || $building || $opt_short < 2  )
187
            {
223
            {
188
                print BOLD GREEN "[$rtag_id] $rname{$rtag_id} ($official{$rtag_id})", RESET, "\n";
224
                print BOLD GREEN "[$rtag_id] $rname{$rtag_id} ($official{$rtag_id})", RESET, "\n";
189
            }
225
            }
190
            
226
            
191
            if ( $building || $opt_short < 1 )
227
            if ( $in_error || $dead || $building || $opt_short < 1 )
192
            {
228
            {
193
                foreach my $rcon_id ( @orderm, sort(@orders) )
229
                foreach my $rcon_id ( @orderm, sort(@orders) )
194
                {
230
                {
195
                    if ( $opt_filter )
231
                    if ( $opt_filter )
196
                    {
232
                    {
Line 199... Line 235...
199
                            $rc{$rtag_id}{$rcon_id}{hostname},
235
                            $rc{$rtag_id}{$rcon_id}{hostname},
200
                            $rc{$rtag_id}{$rcon_id}{filter};
236
                            $rc{$rtag_id}{$rcon_id}{filter};
201
                    }
237
                    }
202
                    else
238
                    else
203
                    {
239
                    {
204
                             printf "    %1.1s: %-20s %s%10s%s(%1.1s) %-20s\n",
240
                             printf "    %1.1s: %-20s %s%10s%s(%1.1s) %-20s %-20s (%5s)\n",
205
                #                $rtag_id, $rcon_id,
241
                #                $rtag_id, $rcon_id,
206
                                $rc{$rtag_id}{$rcon_id}{hostmode},
242
                                $rc{$rtag_id}{$rcon_id}{hostmode},
207
                                $rc{$rtag_id}{$rcon_id}{hostname},
243
                                $rc{$rtag_id}{$rcon_id}{hostname},
208
                                $indefinite ? RED : RESET,
244
                                $indefinite ? RED : RESET,
209
                                $indefinite ? ('AllStop') : (getState($rl{$rcon_id}{crl})),
245
                                $indefinite ? ('AllStop') : (getState($rl{$rcon_id}{crl})),
210
                                RESET,
246
                                RESET,
211
                                defined ($rl{$rcon_id}{pause} ) ? $rl{$rcon_id}{pause} : '-',
247
                                defined ($rl{$rcon_id}{pause} ) ? $rl{$rcon_id}{pause} : '-',
212
                                $rl{$rcon_id}{cpid} || '-'
248
                                $rl{$rcon_id}{cpid} || '-',
-
 
249
                                $rl{$rcon_id}{alive} || '-',
-
 
250
                                $rl{$rcon_id}{deltat} || '-',
213
                            ;
251
                            ;
214
                    }
252
                    }
215
                }
253
                }
216
                print "\n";
254
                print "\n";
217
            }
255
            }
Line 286... Line 324...
286
    # if we are not or cannot connect then return 0 as we have not found anything
324
    # if we are not or cannot connect then return 0 as we have not found anything
287
    connectRM( \$RM_DB) unless $RM_DB;
325
    connectRM( \$RM_DB) unless $RM_DB;
288
 
326
 
289
    # First get details from pv_id
327
    # First get details from pv_id
290
 
328
 
291
    my $m_sqlstr = "SELECT rc.RCON_ID, rc.RTAG_ID, rc.GBE_ID, rc.DAEMON_HOSTNAME, rc.DAEMON_MODE, rc.GBE_BUILDFILTER, rt.RTAG_NAME, p.PROJ_NAME, rt.OFFICIAL" .
329
    my $m_sqlstr = "SELECT rc.RCON_ID, rc.RTAG_ID, rc.GBE_ID, rc.DAEMON_HOSTNAME, " .
-
 
330
                          "rc.DAEMON_MODE, rc.GBE_BUILDFILTER, rt.RTAG_NAME, " .
-
 
331
                          "p.PROJ_NAME, rt.OFFICIAL" .
292
                    " FROM release_config rc, RELEASE_TAGS rt, PROJECTS p" .
332
                    " FROM release_config rc, RELEASE_TAGS rt, PROJECTS p" .
-
 
333
                    " WHERE      rt.RTAG_ID = rc.RTAG_ID " .
293
                    " WHERE rt.RTAG_ID = rc.RTAG_ID AND rt.PROJ_ID = p.PROJ_ID AND rt.OFFICIAL != 'A'";
334
                            "AND rt.PROJ_ID = p.PROJ_ID " .
294
 
-
 
-
 
335
                            "AND rt.OFFICIAL != 'A' " .
-
 
336
                            "AND rt.OFFICIAL != 'Y' "
-
 
337
                            ;
295
 
338
 
296
    my $sth = $RM_DB->prepare($m_sqlstr);
339
    my $sth = $RM_DB->prepare($m_sqlstr);
297
    if ( defined($sth) )
340
    if ( defined($sth) )
298
    {
341
    {
299
        if ( $sth->execute( ) )
342
        if ( $sth->execute( ) )
Line 366... Line 409...
366
    # if we are not or cannot connect then return 0 as we have not found anything
409
    # if we are not or cannot connect then return 0 as we have not found anything
367
    connectRM( \$RM_DB) unless $RM_DB;
410
    connectRM( \$RM_DB) unless $RM_DB;
368
 
411
 
369
    # First get details from pv_id
412
    # First get details from pv_id
370
 
413
 
371
    my $m_sqlstr = "SELECT rl.RCON_ID, rl.CURRENT_BUILD_FILES, rl.CURRENT_RUN_LEVEL, rl.PAUSE, rl.CURRENT_PKG_ID_BEING_BUILT, pkg.PKG_NAME" .
414
    my $m_sqlstr = "SELECT rl.RCON_ID, rl.CURRENT_BUILD_FILES, rl.CURRENT_RUN_LEVEL, rl.PAUSE, " .
-
 
415
                            "rl.CURRENT_PKG_ID_BEING_BUILT, pkg.PKG_NAME, " .
-
 
416
                            "rl.KEEP_ALIVE, TRUNC (86400*(SYSDATE - rl.KEEP_ALIVE))" .
372
                    " FROM RUN_LEVEL rl, PACKAGES pkg" .
417
                    " FROM RUN_LEVEL rl, PACKAGES pkg" .
373
                    " WHERE pkg.PKG_ID (+)= rl.CURRENT_PKG_ID_BEING_BUILT";
418
                    " WHERE pkg.PKG_ID (+)= rl.CURRENT_PKG_ID_BEING_BUILT";
374
 
419
 
375
 
420
 
376
    my $sth = $RM_DB->prepare($m_sqlstr);
421
    my $sth = $RM_DB->prepare($m_sqlstr);
Line 386... Line 431...
386
                    my $rcon_id = $row[0] || '';
431
                    my $rcon_id = $row[0] || '';
387
                    my $cbf     = $row[1] || '';
432
                    my $cbf     = $row[1] || '';
388
                    my $crl     = $row[2] || '-';
433
                    my $crl     = $row[2] || '-';
389
                    my $pause   = $row[3] || '0';
434
                    my $pause   = $row[3] || '0';
390
                    my $cpid    = $row[5] || '';
435
                    my $cpid    = $row[5] || '';
-
 
436
                    my $alive   = $row[6] || '';
-
 
437
                    my $deltat  = $row[7] || '0';
391
 
438
 
392
                    $rl{$rcon_id}{crl} = $crl;
439
                    $rl{$rcon_id}{crl} = $crl;
393
                    $rl{$rcon_id}{pause} = $pause;
440
                    $rl{$rcon_id}{pause} = $pause;
394
                    $rl{$rcon_id}{cpid} = $cpid;
441
                    $rl{$rcon_id}{cpid} = $cpid;
-
 
442
                    $rl{$rcon_id}{alive} = $alive;
-
 
443
                    $rl{$rcon_id}{deltat} = $deltat;
395
#                    printf "%10s, %10s, %10s, %10s, %10s\n", $rcon_id, $cbf, $crl, $pause, $cpid;
444
#                    printf "%10s, %10s, %10s, %10s, %10s, %20s\n", $rcon_id, $cbf, $crl, $pause, $cpid, "$alive, $deltat";
396
                }
445
                }
397
            }
446
            }
398
            $sth->finish();
447
            $sth->finish();
399
        }
448
        }
400
        else
449
        else