5 =head1 NAME $RCSfile: systems.cgi,v $
15 Andrew DeFaria <Andrew@ClearSCM.com>
23 Mon Oct 25 11:10:47 PDT 2008
27 $Date: 2011/02/14 14:54:59 $
33 Usage systems.cgi: [-u|sage] [-ve|rbose] [-d|ebug]
36 -u|sage: Displays usage
38 -d|ebug: Output debug messages
42 This script displays all known systems
51 use CGI qw(:standard :cgi-lib *table start_Tr end_Tr start_td end_td);
52 use CGI::Carp 'fatalsToBrowser';
54 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
61 my $VERSION = '$Revision: 1.15 $';
62 ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
64 my $subtitle = 'Systems Status: All Systems';
68 sub DisplaySystems() {
69 display start_table {cellspacing => 1, class => 'main'};
72 display th {class => 'labelCentered'}, 'Action';
73 display th {class => 'labelCentered'}, 'Name';
74 display th {class => 'labelCentered'}, 'Alias';
75 display th {class => 'labelCentered'}, 'Admin';
76 display th {class => 'labelCentered'}, 'Type';
77 display th {class => 'labelCentered'}, 'Last Contacted';
78 display th {class => 'labelCentered'}, 'Current load';
79 display th {class => 'labelCentered'}, 'Threshold';
80 display th {class => 'labelCentered'}, 'Load Avg';
83 for ($clearadm->FindSystem) {
86 $system{alias} = setField $system{alias}, 'N/A';
87 $system{region} = setField $system{region}, 'N/A';
89 my $admin = ($system{email})
90 ? a {href => "mailto:$system{email}"}, $system{admin}
93 my $alias = ($system{alias} !~ 'N/A')
95 href => "systemdetails.cgi?system=$system{name}"
99 my %load = $clearadm->GetLatestLoadavg ($system{name});
101 $load{loadavg} ||= 0;
102 $load{timestamp} ||= 'unknown';
104 my $class = $load{loadavg} < $system{loadavgThreshold}
107 my $classRight = $load{loadavg} < $system{loadavgThreshold}
110 my $classRightTop = $load{loadavg} < $system{loadavgThreshold}
112 : 'dataRightAlertTop';
115 display start_td {class => 'data'};
117 my $areYouSure = 'Are you sure you want to delete this system?\n'
118 . 'Doing so will remove all records related to '
120 . '\nincluding filesystem records and history as well as '
121 . 'loadavg history.';
125 action => "processsystem.cgi",
131 value => $system{name},
141 onclick => "return AreYouSure ('$areYouSure');"
152 disabled => 'disabled',
153 checked => $system{active} eq 'true' ? 1 : 0,
156 if ($system{notification}) {
157 display a {href => "alertlog.cgi?system=$system{name}"}, img {
161 title => 'This system has alerts',
168 display td {class => $class},
169 a {href => "systemdetails.cgi?system=$system{name}"}, $system{name};
170 display td {class => $class}, $alias;
171 display td {class => $class}, $admin;
172 display td {class => $class}, $system{type};
174 my $lastheardfromClass = 'dataCentered';
175 my $lastheardfromData = $system{lastheardfrom};
177 unless ($clearadm->SystemAlive(%system)) {
178 $lastheardfromClass = 'dataCenteredAlert';
179 $lastheardfromData = a {
180 href => "alertlog.cgi?system=$system{name}",
182 title => "Have not heard from $system{name} for a while"
183 }, $system{lastheardfrom};
184 $system{notification} = 'Heartbeat';
187 display td {class => $lastheardfromClass}, "$lastheardfromData ",
188 font {class => 'dim' }, "<br>Up: $load{uptime}";
189 display td {class => $classRightTop}, "$load{loadavg} ",
190 font {class => 'dim' }, "<br>$load{timestamp}";
191 display td {class => $classRightTop}, $system{loadavgThreshold};
193 my $image = $system{loadavgsmall}
194 ? "data:image/png;base64,$system{loadavgsmall}"
195 : "plotloadavg.cgi?system=$system{name}&tiny=1";
197 display td {class => $class},
200 "plot.cgi?type=loadavg&system=$system{name}&scaling=Hour&points=24"
210 display p {class => 'center'}, a {
211 href => 'processsystem.cgi?action=Add',
212 }, 'New system', img {
222 usage => sub { Usage },
223 verbose => sub { set_verbose },
224 debug => sub { set_debug },
225 ) or Usage 'Invalid parameter';
228 verbose "$FindBin::Script v$VERSION";
230 $clearadm = Clearadm->new;
234 display h1 {class => 'center'}, $subtitle;
242 =head1 CONFIGURATION AND ENVIRONMENT
244 DEBUG: If set then $debug is set to this level.
246 VERBOSE: If set then $verbose is set to this level.
248 TRACE: If set then $trace is set to this level.
256 L<CGI::Carp|CGI::Carp>
260 L<Getopt::Long|Getopt::Long>
262 =head2 ClearSCM Perl Modules
276 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
277 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
278 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
279 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
284 =head1 BUGS AND LIMITATIONS
286 There are no known bugs in this script
288 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
290 =head1 LICENSE AND COPYRIGHT
292 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.