Subversion Repositories DevTools

Rev

Rev 5710 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : Create an HTML page of build status links
10
#
11
# Usage         : See POD at end of file
12
#
13
#......................................................................#
14
 
15
require 5.6.1;
16
use strict;
17
use warnings;
18
use JatsError;
19
use JatsSystem;
20
use Getopt::Long;
21
use Pod::Usage;
22
use JatsRmApi;
23
use Term::ANSIColor qw(:constants);
24
use DBI;
25
 
26
my $VERSION = "1.0.0";                      # Update this
27
my $opt_verbose = 1;
28
my $opt_help = 0;
29
my $RM_DB;
30
my %pname;
31
my %rname;
32
my %official;
33
my %rc;
34
my %rl;
35
 
36
#-------------------------------------------------------------------------------
37
# Function        : Main Entry
38
#
39
# Description     :
40
#
41
# Inputs          :
42
#
43
# Returns         :
44
#
45
my $result = GetOptions (
46
                "help:+"        => \$opt_help,          # flag, multiple use allowed
47
                "manual:3"      => \$opt_help,          # flag
48
                "verbose:+"     => \$opt_verbose,       # flag
49
                );
50
 
51
#
52
#   Process help and manual options
53
#
54
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
55
pod2usage(-verbose => 1)  if ($opt_help == 2 );
56
pod2usage(-verbose => 2)  if ($opt_help > 2);
57
 
58
ErrorConfig( 'name'    =>'DSTATUS' );
59
 
60
GetConfigData();
61
GetRunData();
62
DisplayInfo();
63
 
64
disconnectRM(\$RM_DB);
65
exit;
66
 
67
#-------------------------------------------------------------------------------
68
# Function        : DisplayInfo
69
#
70
# Description     : Display collected information
71
#
72
# Inputs          : 
73
#
74
# Returns         : 
75
#
76
sub DisplayInfo
77
{
78
 
79
#DebugDumpData ("Data", \%rc);
80
 
81
my @fnames;
82
 
83
my $fname = 'BuildStatusBody.html';
84
push @fnames, $fname;
85
 
86
open HTML ,">", $fname || Error "cannot open outputfile. $fname";
87
print HTML '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
88
<html>
89
<head>
90
<title>Build Status Summary</title>
91
</head>
92
 
93
 
94
<body leftmargin="0" topmargin="0" bgcolor="#ffffff" text="#000000">
95
';
96
 
97
    #
98
    #  Sort by Project Name and Release Name
99
    #
100
    foreach my $pname ( sort keys %pname )
101
    {
102
        print HTML '<p>' . $pname . '<br>' .  "\n";
103
 
104
        foreach my $rname ( sort keys %{$pname{$pname}} )
105
        {
106
            my $rtag_id = $pname{$pname}{$rname};
107
#            print "[$rtag_id] $rname{$rtag_id}\n";
5710 dpurdie 108
            print HTML '<a target="BODY" href="http://bms:8002/ManagerSuiteDevelopment/Release_Manager//build_status.asp?rtag_id=' . $rtag_id . '">' . $rname{$rtag_id} . '</a><br>' . "\n";
392 dpurdie 109
        }
110
    }
111
 
112
print HTML '
113
</body>
114
</html>';
115
close HTML;
116
 
117
 
118
#
119
#   Create frameset
120
#
121
$fname = 'BuildStatus.html';
122
push @fnames, $fname;
123
 
124
open HTML ,">", $fname || Error "cannot open outputfile. $fname";
125
print HTML '
126
<HTML>
127
<HEAD>
128
<TITLE>Build Deamons</TITLE>
129
</HEAD>
130
 
131
     <FRAMESET COLS="20%,*">
132
          <FRAME SRC="BuildStatusBody.html" NAME=SIDEBAR>
133
          <FRAME NAME=BODY>
134
     </FRAMESET>
135
 
136
</HTML>';
137
close HTML;
138
 
139
Message ("Creaeted Files", @fnames );
140
 
141
}
142
 
143
#-------------------------------------------------------------------------------
144
# Function        : GetConfigData
145
#
146
# Description     : Build up a list of all releases that have daemons
147
#                   configured
148
#
149
# Inputs          : 
150
#
151
# Returns         : 
152
#
153
sub  GetConfigData
154
{
155
    my $foundDetails = 0;
156
    my (@row);
157
 
158
    # if we are not or cannot connect then return 0 as we have not found anything
159
    connectRM( \$RM_DB) unless $RM_DB;
160
 
161
    # First get details from pv_id
162
 
163
    my $m_sqlstr = "SELECT rc.RCON_ID, rc.RTAG_ID, rc.GBE_ID, rc.DAEMON_HOSTNAME, " .
164
                          "rc.DAEMON_MODE, rc.GBE_BUILDFILTER, rt.RTAG_NAME, " .
165
                          "p.PROJ_NAME, rt.OFFICIAL" .
166
                    " FROM release_config rc, RELEASE_TAGS rt, PROJECTS p" .
167
                    " WHERE      rt.RTAG_ID = rc.RTAG_ID " .
168
                            "AND rt.PROJ_ID = p.PROJ_ID " .
169
                            "AND rt.OFFICIAL != 'A' " .
170
                            "AND rt.OFFICIAL != 'Y' "
171
                            ;
172
 
173
    my $sth = $RM_DB->prepare($m_sqlstr);
174
    if ( defined($sth) )
175
    {
176
        if ( $sth->execute( ) )
177
        {
178
            if ( $sth->rows )
179
            {
180
                while ( @row = $sth->fetchrow_array )
181
                {
182
                    my $rcon_id = $row[0];
183
                    my $rtag_id = $row[1];
184
                    my $gbe_id =  $row[2];
185
                    my $hostname = $row[3];
186
                    my $hostmode = $row[4];
187
                    my $filter = $row[5];
188
                    my $rname = $row[6];
189
                    my $pname = $row[7];
190
                    my $official = $row[8];
191
 
192
                    next unless ( $hostname );
193
 
194
                    my %data;
195
                    $data{rcon_id}  = $rcon_id;
196
                    $data{hostname} = $hostname;
197
                    $data{hostname} = $hostname;
198
                    $data{hostmode} = $hostmode;
199
                    $data{filter}   = $filter;
200
 
201
                    $rc{$rtag_id}{$rcon_id} = \%data;
202
 
203
                    $rname{$rtag_id} = $rname;
204
 
205
                    $pname{$pname}{$rname} = $rtag_id;
206
 
207
                    $official{$rtag_id} = $official;
208
 
209
#                    print "@row\n";
210
                }
211
            }
212
            $sth->finish();
213
        }
214
        else
215
        {
216
        Error("Execute failure" );
217
        }
218
    }
219
    else
220
    {
221
        Error("Prepare failure" );
222
    }
223
}
224
 
225
#-------------------------------------------------------------------------------
226
# Function        : GetRunData
227
#
228
# Description     : Build up data for each daemon
229
#
230
# Inputs          : 
231
#
232
# Returns         : 
233
#
234
sub  GetRunData
235
{
236
    my $foundDetails = 0;
237
    my (@row);
238
 
239
    # if we are not or cannot connect then return 0 as we have not found anything
240
    connectRM( \$RM_DB) unless $RM_DB;
241
 
242
    # First get details from pv_id
243
 
244
    my $m_sqlstr = "SELECT rl.RCON_ID, rl.CURRENT_BUILD_FILES, rl.CURRENT_RUN_LEVEL, rl.PAUSE, " .
245
                            "rl.CURRENT_PKG_ID_BEING_BUILT, pkg.PKG_NAME, " .
246
                            "rl.KEEP_ALIVE, TRUNC (86400*(SYSDATE - rl.KEEP_ALIVE))" .
247
                    " FROM RUN_LEVEL rl, PACKAGES pkg" .
248
                    " WHERE pkg.PKG_ID (+)= rl.CURRENT_PKG_ID_BEING_BUILT";
249
 
250
 
251
    my $sth = $RM_DB->prepare($m_sqlstr);
252
    if ( defined($sth) )
253
    {
254
        if ( $sth->execute( ) )
255
        {
256
            if ( $sth->rows )
257
            {
258
                while ( @row = $sth->fetchrow_array )
259
                {
260
#                    print "@row\n";
261
                    my $rcon_id = $row[0] || '';
262
                    my $cbf     = $row[1] || '';
263
                    my $crl     = $row[2] || '-';
264
                    my $pause   = $row[3] || '0';
265
                    my $cpid    = $row[5] || '';
266
                    my $alive   = $row[6] || '';
267
                    my $deltat  = $row[7] || '0';
268
 
269
                    $rl{$rcon_id}{crl} = $crl;
270
                    $rl{$rcon_id}{pause} = $pause;
271
                    $rl{$rcon_id}{cpid} = $cpid;
272
                    $rl{$rcon_id}{alive} = $alive;
273
                    $rl{$rcon_id}{deltat} = $deltat;
274
#                    printf "%10s, %10s, %10s, %10s, %10s, %20s\n", $rcon_id, $cbf, $crl, $pause, $cpid, "$alive, $deltat";
275
                }
276
            }
277
            $sth->finish();
278
        }
279
        else
280
        {
281
        Error("Execute failure: GetRunData", $m_sqlstr );
282
        }
283
    }
284
    else
285
    {
286
        Error("Prepare failure" );
287
    }
288
}
289
 
290
#-------------------------------------------------------------------------------
291
#   Documentation
292
#
293
 
294
=pod
295
 
296
=head1 NAME
297
 
298
dstatus - Display Daemon Status
299
 
300
=head1 SYNOPSIS
301
 
302
  jats dstatus [options]
303
 
304
 Options:
305
    -help              - brief help message
306
    -help -help        - Detailed help message
307
    -man               - Full documentation
308
 
309
=head1 OPTIONS
310
 
311
=over 8
312
 
313
=item B<-help>
314
 
315
Print a brief help message and exits.
316
 
317
=item B<-help -help>
318
 
319
Print a detailed help message with an explanation for each option.
320
 
321
=item B<-man>
322
 
323
Prints the manual page and exits.
324
 
325
=back
326
 
327
=head1 DESCRIPTION
328
 
329
This program will display the status of the build daemons on all daemon enabled
330
releases.
331
 
332
=cut
333