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 foreach ($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};
192 display td {class => $class},
195 "plot.cgi?type=loadavg&system=$system{name}&scaling=Hour&points=24"
197 src => "plotloadavg.cgi?system=$system{name}&tiny=1",
205 display p {class => 'center'}, a {
206 href => 'processsystem.cgi?action=Add',
207 }, 'New system', img {
217 usage => sub { Usage },
218 verbose => sub { set_verbose },
219 debug => sub { set_debug },
220 ) or Usage 'Invalid parameter';
223 verbose "$FindBin::Script v$VERSION";
225 $clearadm = Clearadm->new;
229 display h1 {class => 'center'}, $subtitle;
237 =head1 CONFIGURATION AND ENVIRONMENT
239 DEBUG: If set then $debug is set to this level.
241 VERBOSE: If set then $verbose is set to this level.
243 TRACE: If set then $trace is set to this level.
251 L<CGI::Carp|CGI::Carp>
255 L<Getopt::Long|Getopt::Long>
257 =head2 ClearSCM Perl Modules
271 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
272 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
273 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
274 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
279 =head1 BUGS AND LIMITATIONS
281 There are no known bugs in this script
283 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
285 =head1 LICENSE AND COPYRIGHT
287 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.