Big update of Clearadm
[clearscm.git] / clearadm / index.cgi
1 #!/usr/local/bin/perl
2
3 =pod
4
5 =head1 NAME $RCSfile: index.cgi,v $
6
7 Clearadm: Portal to your Clearcase Infrastructure
8
9 =head1 VERSION
10
11 =over
12
13 =item Author
14
15 Andrew DeFaria <Andrew@ClearSCM.com>
16
17 =item Revision
18
19 $Revision: 1.22 $
20
21 =item Created:
22
23 Mon Oct 25 11:10:47 PDT 2008
24
25 =item Modified:
26
27 $Date: 2011/02/14 14:50:48 $
28
29 =back
30
31 =head1 DESCRIPTION
32
33 Clearadm is a web based portal into your Clearcase infrastucture. It seeks to
34 provide your CM staff with an easy to use, yet informative interface to locate,
35 report on and monitor various aspects of the Clearcase infrastructure.
36
37 =cut
38
39 use strict;
40 use warnings;
41
42 use FindBin;
43 use Getopt::Long;
44
45 use CGI qw (:standard *table start_Tr end_Tr);
46 use CGI::Carp 'fatalsToBrowser';
47
48 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
49
50 use ClearadmWeb;
51 use Clearadm;
52 use Clearcase;
53 use Clearcase::Views;
54 use Display;
55 use Utils;
56
57 my $clearadm = Clearadm->new;
58
59 # Main
60 GetOptions (
61   'usage'        => sub { Usage },
62   'verbose'      => sub { set_verbose },
63   'debug'        => sub { set_debug },
64 ) or Usage "Invalid parameter";
65
66 # Announce ourselves
67 verbose "$ClearadmWeb::APPNAME V$ClearadmWeb::VERSION";
68
69 heading;
70
71 display p '&nbsp;';
72 display p <<"END";
73 Clearadm is a web based portal into your infrastructure. It seeks to provide
74 your system administrative staff with an easy to use, yet informative interface
75 to locate, report on and monitor various aspects of your infrastructure. 
76 END
77   display p <<"END";
78 Additionally, Clearacdm is aware of Clearcase servers as well as Clearcase
79 objects such as views, vobs, etc. When systems are added to Clearadm that house
80 or server Clearcase objects, additional information is collected about those
81 objects.
82 END
83
84 display h1 {class => 'center'}, 'Systems Snapshot';
85
86 display start_table {cellspacing => 1};
87
88 my $i = 0;
89 my $perRow = 5;
90
91 display start_Tr;
92
93 my @systems = $clearadm->FindSystem;
94
95 $perRow = @systems if @systems < $perRow;
96
97 foreach (@systems) {
98   my %system = %{$_};
99   
100   if ($i++ % $perRow == 0) {
101     display end_Tr;
102     display start_Tr; 
103   } # if
104
105   my %load = $clearadm->GetLatestLoadavg ($system{name});
106
107   my $data;
108   
109   $data = '<strike>'
110     if $system{active} eq 'false';
111     
112   $data .= a {
113     href => "systemdetails.cgi?system=$system{name}"
114   }, ucfirst $system{name};
115   
116   if ($system{notification}) {
117     $data .= '&nbsp;' . a {
118       href => "alertlog.cgi?system=$system{name}"}, img {
119       src    => 'alert.png',
120       border => 0,
121       alt    => 'Alert!',
122       title  => 'This system has alerts', 
123     };
124   } # if
125   
126   $data .=  '<br>' .  
127     a {href => 
128       "plot.cgi?type=loadavg&system=$system{name}&scaling=Hour&points=24"
129      }, img {
130        src    => "plotloadavg.cgi?system=$system{name}&tiny=1",
131        border => 0,
132      };
133    
134   $data .= '</strike>'
135     if $system{active} eq 'false';
136     
137   $load{uptime} ||= 'Unknown';
138
139   display td {class => 'dataCentered'}, "$data ",
140     font {class => 'dim' }, "<br>Up: $load{uptime}";
141 } # foreach
142
143 while ($i % $perRow != 0) {
144    $i++;
145    display td {class => 'data'}, '&nbsp;';
146 } # while
147
148 display end_Tr;
149
150 display end_table;
151
152 footing;
153
154 =pod
155
156 =head1 CONFIGURATION AND ENVIRONMENT
157
158 DEBUG: If set then $debug is set to this level.
159
160 VERBOSE: If set then $verbose is set to this level.
161
162 TRACE: If set then $trace is set to this level.
163
164 =head1 DEPENDENCIES
165
166 =head2 Perl Modules
167
168 L<CGI|CGI.html>
169
170 L<CGI::Carp|CGI::Carp>
171
172 L<FindBin>
173
174 L<Getopt::Long|Getopt::Long>
175
176 =head2 ClearSCM Perl Modules
177
178 =begin man 
179
180  Clearadm
181  ClearadmWeb
182  Display
183  Utils
184
185 =end man
186
187 =begin html
188
189 <blockquote>
190 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
191 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
192 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
193 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
194 </blockquote>
195
196 =end html
197
198 =head1 BUGS AND LIMITATIONS
199
200 There are no known bugs in this script
201
202 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
203
204 =head1 LICENSE AND COPYRIGHT
205
206 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
207
208 =cut