Removed /usr/local from CDPATH
[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 use Convert::Base64;
48
49 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
50
51 use ClearadmWeb;
52 use Clearadm;
53 use Clearcase;
54 use Clearcase::Views;
55 use Display;
56 use Utils;
57
58 my $clearadm = Clearadm->new;
59
60 # Main
61 GetOptions(
62   'usage'        => sub { Usage },
63   'verbose'      => sub { set_verbose },
64   'debug'        => sub { set_debug },
65 ) or Usage "Invalid parameter";
66
67 # Announce ourselves
68 verbose "$ClearadmWeb::APPNAME V$ClearadmWeb::VERSION";
69
70 heading;
71
72 display p '&nbsp;';
73 display p <<"END";
74 Clearadm is a web based portal into your infrastructure. It seeks to provide
75 your system administrative staff with an easy to use, yet informative interface
76 to locate, report on and monitor various aspects of your infrastructure. 
77 END
78   display p <<"END";
79 Additionally, Clearacdm is aware of Clearcase servers as well as Clearcase
80 objects such as views, vobs, etc. When systems are added to Clearadm that house
81 or server Clearcase objects, additional information is collected about those
82 objects.
83 END
84
85 display h1 {class => 'center'}, 'Systems Snapshot';
86
87 display start_table {cellspacing => 1};
88
89 my $i = 0;
90 my $perRow = 5;
91
92 display start_Tr;
93
94 my @systems = $clearadm->FindSystem;
95
96 $perRow = @systems if @systems < $perRow;
97
98 for (@systems) {
99   my %system = %{$_};
100   
101   if ($i++ % $perRow == 0) {
102     display end_Tr;
103     display start_Tr; 
104   } # if
105
106   my %load = $clearadm->GetLatestLoadavg ($system{name});
107
108   my $data;
109   
110   $data = '<strike>' 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   my $image = $system{loadavgsmall}
127     ? "data:image/png;base64,$system{loadavgsmall}"
128     : "plotloadavg.cgi?system=$system{name}&tiny=1";
129
130   $data .=  '<br>' .  
131     a {href => 
132       "plot.cgi?type=loadavg&system=$system{name}&scaling=Hour&points=24"
133      }, img {
134        src    => $image,
135        border => 0,
136      };
137    
138   $data .= '</strike>' if $system{active} eq 'false';
139     
140   $load{uptime} ||= 'Unknown';
141
142   display td {class => 'dataCentered'}, "$data ",
143     font {class => 'dim' }, "<br>Up: $load{uptime}";
144 } # for
145
146 while ($i % $perRow != 0) {
147    $i++;
148    display td {class => 'data'}, '&nbsp;';
149 } # while
150
151 display end_Tr;
152
153 display end_table;
154
155 footing;
156
157 =pod
158
159 =head1 CONFIGURATION AND ENVIRONMENT
160
161 DEBUG: If set then $debug is set to this level.
162
163 VERBOSE: If set then $verbose is set to this level.
164
165 TRACE: If set then $trace is set to this level.
166
167 =head1 DEPENDENCIES
168
169 =head2 Perl Modules
170
171 L<CGI|CGI.html>
172
173 L<CGI::Carp|CGI::Carp>
174
175 L<FindBin>
176
177 L<Getopt::Long|Getopt::Long>
178
179 =head2 ClearSCM Perl Modules
180
181 =begin man 
182
183  Clearadm
184  ClearadmWeb
185  Display
186  Utils
187
188 =end man
189
190 =begin html
191
192 <blockquote>
193 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
194 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
195 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
196 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
197 </blockquote>
198
199 =end html
200
201 =head1 BUGS AND LIMITATIONS
202
203 There are no known bugs in this script
204
205 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
206
207 =head1 LICENSE AND COPYRIGHT
208
209 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
210
211 =cut