Rev 5710 | Blame | Compare with Previous | Last modification | View Log | RSS feed
######################################################################### COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.## Module name : jats.sh# Module type : Makefile system# Compiler(s) : n/a# Environment(s): jats## Description : Create an HTML page of build status links## Usage : See POD at end of file##......................................................................#require 5.6.1;use strict;use warnings;use JatsError;use JatsSystem;use Getopt::Long;use Pod::Usage;use JatsRmApi;use Term::ANSIColor qw(:constants);use DBI;my $VERSION = "1.0.0"; # Update thismy $opt_verbose = 1;my $opt_help = 0;my $RM_DB;my %pname;my %rname;my %official;my %rc;my %rl;#-------------------------------------------------------------------------------# Function : Main Entry## Description :## Inputs :## Returns :#my $result = GetOptions ("help:+" => \$opt_help, # flag, multiple use allowed"manual:3" => \$opt_help, # flag"verbose:+" => \$opt_verbose, # flag);## Process help and manual options#pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);pod2usage(-verbose => 1) if ($opt_help == 2 );pod2usage(-verbose => 2) if ($opt_help > 2);ErrorConfig( 'name' =>'DSTATUS' );GetConfigData();GetRunData();DisplayInfo();disconnectRM(\$RM_DB);exit;#-------------------------------------------------------------------------------# Function : DisplayInfo## Description : Display collected information## Inputs :## Returns :#sub DisplayInfo{#DebugDumpData ("Data", \%rc);my @fnames;my $fname = 'BuildStatusBody.html';push @fnames, $fname;open HTML ,">", $fname || Error "cannot open outputfile. $fname";print HTML '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Build Status Summary</title></head><body leftmargin="0" topmargin="0" bgcolor="#ffffff" text="#000000">';## Sort by Project Name and Release Name#foreach my $pname ( sort keys %pname ){print HTML '<p>' . $pname . '<br>' . "\n";foreach my $rname ( sort keys %{$pname{$pname}} ){my $rtag_id = $pname{$pname}{$rname};# print "[$rtag_id] $rname{$rtag_id}\n";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";}}print HTML '</body></html>';close HTML;## Create frameset#$fname = 'BuildStatus.html';push @fnames, $fname;open HTML ,">", $fname || Error "cannot open outputfile. $fname";print HTML '<HTML><HEAD><TITLE>Build Deamons</TITLE></HEAD><FRAMESET COLS="20%,*"><FRAME SRC="BuildStatusBody.html" NAME=SIDEBAR><FRAME NAME=BODY></FRAMESET></HTML>';close HTML;Message ("Creaeted Files", @fnames );}#-------------------------------------------------------------------------------# Function : GetConfigData## Description : Build up a list of all releases that have daemons# configured## Inputs :## Returns :#sub GetConfigData{my $foundDetails = 0;my (@row);# if we are not or cannot connect then return 0 as we have not found anythingconnectRM( \$RM_DB) unless $RM_DB;# First get details from pv_idmy $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" ." FROM release_config rc, RELEASE_TAGS rt, PROJECTS p" ." WHERE rt.RTAG_ID = rc.RTAG_ID " ."AND rt.PROJ_ID = p.PROJ_ID " ."AND rt.OFFICIAL != 'A' " ."AND rt.OFFICIAL != 'Y' ";my $sth = $RM_DB->prepare($m_sqlstr);if ( defined($sth) ){if ( $sth->execute( ) ){if ( $sth->rows ){while ( @row = $sth->fetchrow_array ){my $rcon_id = $row[0];my $rtag_id = $row[1];my $gbe_id = $row[2];my $hostname = $row[3];my $hostmode = $row[4];my $filter = $row[5];my $rname = $row[6];my $pname = $row[7];my $official = $row[8];next unless ( $hostname );my %data;$data{rcon_id} = $rcon_id;$data{hostname} = $hostname;$data{hostname} = $hostname;$data{hostmode} = $hostmode;$data{filter} = $filter;$rc{$rtag_id}{$rcon_id} = \%data;$rname{$rtag_id} = $rname;$pname{$pname}{$rname} = $rtag_id;$official{$rtag_id} = $official;# print "@row\n";}}$sth->finish();}else{Error("Execute failure" );}}else{Error("Prepare failure" );}}#-------------------------------------------------------------------------------# Function : GetRunData## Description : Build up data for each daemon## Inputs :## Returns :#sub GetRunData{my $foundDetails = 0;my (@row);# if we are not or cannot connect then return 0 as we have not found anythingconnectRM( \$RM_DB) unless $RM_DB;# First get details from pv_idmy $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, " ."rl.KEEP_ALIVE, TRUNC (86400*(SYSDATE - rl.KEEP_ALIVE))" ." FROM RUN_LEVEL rl, PACKAGES pkg" ." WHERE pkg.PKG_ID (+)= rl.CURRENT_PKG_ID_BEING_BUILT";my $sth = $RM_DB->prepare($m_sqlstr);if ( defined($sth) ){if ( $sth->execute( ) ){if ( $sth->rows ){while ( @row = $sth->fetchrow_array ){# print "@row\n";my $rcon_id = $row[0] || '';my $cbf = $row[1] || '';my $crl = $row[2] || '-';my $pause = $row[3] || '0';my $cpid = $row[5] || '';my $alive = $row[6] || '';my $deltat = $row[7] || '0';$rl{$rcon_id}{crl} = $crl;$rl{$rcon_id}{pause} = $pause;$rl{$rcon_id}{cpid} = $cpid;$rl{$rcon_id}{alive} = $alive;$rl{$rcon_id}{deltat} = $deltat;# printf "%10s, %10s, %10s, %10s, %10s, %20s\n", $rcon_id, $cbf, $crl, $pause, $cpid, "$alive, $deltat";}}$sth->finish();}else{Error("Execute failure: GetRunData", $m_sqlstr );}}else{Error("Prepare failure" );}}#-------------------------------------------------------------------------------# Documentation#=pod=head1 NAMEdstatus - Display Daemon Status=head1 SYNOPSISjats dstatus [options]Options:-help - brief help message-help -help - Detailed help message-man - Full documentation=head1 OPTIONS=over 8=item B<-help>Print a brief help message and exits.=item B<-help -help>Print a detailed help message with an explanation for each option.=item B<-man>Prints the manual page and exits.=back=head1 DESCRIPTIONThis program will display the status of the build daemons on all daemon enabledreleases.=cut