X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=clearadm%2Flib%2FClearadmWeb.pm;h=e5848b009bc978923cc8ce66b44a22aee1ea7fe3;hb=76c07022f4483f42bebeef85d94460b1f39f1fe0;hp=d44947386d9b5b8f0f64b9a194282d339edcc422;hpb=81cbd130706633b1c19ff59371c2ef61d80c562b;p=clearscm.git
diff --git a/clearadm/lib/ClearadmWeb.pm b/clearadm/lib/ClearadmWeb.pm
index d449473..e5848b0 100644
--- a/clearadm/lib/ClearadmWeb.pm
+++ b/clearadm/lib/ClearadmWeb.pm
@@ -47,8 +47,8 @@ use strict;
use base 'Exporter';
-use CGI qw (
- :standard
+use CGI qw(
+ :standard
start_a
end_a
start_div
@@ -73,6 +73,8 @@ use FindBin;
use lib "$FindBin::Bin/../../lib";
use Clearadm;
+use Clearcase::Vobs;
+use Clearcase::Views;
use DateUtils;
use Display;
use Utils;
@@ -82,8 +84,8 @@ my $clearadm = Clearadm->new;
our $APPNAME= 'Clearadm';
our $VERSION = '$Revision: 1.46 $';
($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
-
-our @EXPORT = qw (
+
+our @EXPORT = qw(
autoScale
displayError
displayAlert
@@ -109,7 +111,9 @@ our @EXPORT = qw (
makeFilesystemDropdown
makeIntervalDropdown
makeNotificationDropdown
+ makeStoragePoolDropdown
makeSystemDropdown
+ makeTagsDropdown
makeTimeDropdown
makeTaskDropdown
setField
@@ -121,25 +125,28 @@ our @PREDEFINED_ALERTS = (
);
our @PREDEFINED_NOTIFICATIONS = (
+ 'Clearcase Storage',
+ 'Heartbeat',
'Loadavg',
'Filesystem',
'Scrub',
- 'Heartbeat',
'System checkin',
'Update systems',
);
our @PREDEFINED_TASKS = (
- 'Loadavg',
+ 'Clearcase Storage',
'Filesystem',
+ 'Loadavg',
'Scrub',
'System checkin',
'Update systems',
);
our @PREDEFINED_SCHEDULES = (
- 'Loadavg',
+ 'Clearcase Storage',
'Filesystem',
+ 'Loadavg',
'Scrub',
'Update systems',
);
@@ -158,236 +165,286 @@ our @PREDEFINED_MULTIPLIERS = (
'Days',
);
-sub dbug ($) {
+sub dbug($) {
my ($msg) = @_;
-
+
display font ({-class => 'error'}, '
DEBUG: '). $msg;
-
+
return;
} # dbug
-sub displayError ($) {
+sub displayError($) {
my ($msg) = @_;
-
+
display font ({-class => 'error'}, 'Error: ') . $msg;
-
+
return
} # displayError;
-sub setField ($;$) {
+sub setField($;$) {
my ($field, $label) = @_;
-
+
$label ||= 'Unknown';
my $undef = font {-class => 'unknown'}, $label;
-
+
return defined $field ? $field : $undef;
} # setField
-sub setFields ($%) {
+sub setFields($%) {
my ($label, %rec) = @_;
-
+
$rec{$_} = setField ($rec{$_}, $label)
- foreach keys %rec;
-
+ for keys %rec;
+
return %rec;
} # setFields;
-sub dumpVars (%) {
+sub dumpVars(%) {
my (%vars) = @_;
-
- foreach (keys %vars) {
+
+ for (keys %vars) {
dbug "$_: $vars{$_}";
- } # foreach
-
+ } # for
+
return;
} # dumpVars
-sub graphError ($) {
+sub graphError($) {
my ($msg) = @_;
-
+
use GD;
-
+
# Make the image fit the message. It seems that characters are ~ 7px wide.
my $imageLength = length ($msg) * 7;
-
+
my $errorImage = GD::Image->new ($imageLength, 20);
# Allocate some colors
my $white = $errorImage->colorAllocate (255, 255, 255);
my $red = $errorImage->colorAllocate (255, 0, 0);
-
+
# Allow the text to shine through
$errorImage->transparent($white);
$errorImage->interlaced('true');
- # Now put out the message
+ # Now put out the message
$errorImage->string (gdMediumBoldFont, 0, 0, $msg, $red);
# And return it
print "Content-type: image/png\n\n";
print $errorImage->png;
-
+
# Since we've "returned" the error in the form of an image, there's nothing
# left for us to do so we can exit
exit;
} # graphError
-sub autoScale ($) {
+sub autoScale($) {
my ($amount) = @_;
-
+
my $kbyte = 1024;
my $meg = (1024 * $kbyte);
my $gig = (1024 * $meg);
-
+
my $size = $amount > $gig
? sprintf ('%.2f Gig', $amount / $gig)
: $amount > $meg
? sprintf ('%.2f Meg', $amount / $meg)
: sprintf ('%.2f Kbyte', $amount / $kbyte);
-
- return $size;
+
+ return $size;
} # autoScale
-sub _makeAlertlogSelection ($$) {
+sub _makeAlertlogSelection($$) {
my ($name, $default) = @_;
-
+
$default ||= 'All';
my %values;
$values{All} = 'All';
-
+
$values{$$_{$name}} = $$_{$name}
- foreach ($clearadm->FindAlertlog);
+ for ($clearadm->FindAlertlog);
my $dropdown = popup_menu {
name => $name,
class => 'dropdown',
values => [sort keys %values],
default => $default,
- };
-
+ };
+
return $dropdown;
} # _makeAlertlogSelection
-sub _makeRunlogSelection ($$) {
+sub _makeRunlogSelection($$) {
my ($name, $default) = @_;
-
+
$default ||= 'All';
my @values = sort $clearadm->GetUniqueList ('runlog', $name);
-
+
unshift @values, 'All';
-
+
my %values;
-
- foreach (@values) {
+
+ for (@values) {
unless ($_ eq '') {
$values{$_} = $_;
} else {
$values{NULL} = '';
- } #if
- } # foreach
-
+ } #if
+ } # for
+
my $dropdown = popup_menu {
name => $name,
class => 'dropdown',
values => \@values,
default => $default,
labels => \%values,
- };
-
+ };
+
return $dropdown;
} # _makeRunlogSelection
-sub _makeRunlogSelectionNumeric ($$) {
+sub _makeRunlogSelectionNumeric($$) {
my ($name, $default) = @_;
-
+
$default ||= 'All';
my @values = sort {$a <=> $b} $clearadm->GetUniqueList ('runlog', $name);
-
+
unshift @values, 'All';
-
+
my $dropdown = popup_menu {
name => $name,
class => 'dropdown',
values => [@values],
default => $default,
- };
-
+ };
+
return $dropdown;
} # _makeRunlogSelection
-sub makeAlertDropdown (;$$) {
+sub makeAlertDropdown(;$$) {
my ($label, $default) = @_;
-
+
$label ||= '';
my @values;
- push @values, $$_{name}
- foreach ($clearadm->FindAlert);
-
+ push @values, $$_{name} for ($clearadm->FindAlert);
+
my $dropdown = "$label ";
$dropdown .= popup_menu {
name => 'alert',
class => 'dropdown',
values => [sort @values],
default => $default,
- };
-
+ };
+
return $dropdown;
} # makeAlertDropdown
-sub makeMultiplierDropdown (;$$) {
+sub makeMultiplierDropdown(;$$) {
my ($label, $default) = @_;
-
+
$label ||= '';
-
+
my $dropdown = "$label ";
$dropdown .= popup_menu {
name => 'multiplier',
class => 'dropdown',
values => [sort @PREDEFINED_MULTIPLIERS],
default => $default,
- };
+ };
return $dropdown;
} # makeMultiplierDropdown
-sub makeNoMoreThanDropdown (;$$) {
+sub makeNoMoreThanDropdown(;$$) {
my ($label, $default) = @_;
-
+
$label ||= '';
-
+
my $dropdown = "$label ";
$dropdown .= popup_menu {
name => 'nomorethan',
class => 'dropdown',
values => [sort @PREDEFINED_NOTMORETHAN],
default => $default,
- };
+ };
return $dropdown;
} # makeNoMorThanDropdown
-
-sub makeFilesystemDropdown ($;$$$) {
+
+sub makeTagsDropdown($$) {
+ my ($type, $tag) = @_;
+
+ my $dropdown = ucfirst $type . ' ';
+
+ if ($type eq 'vob') {
+ my $vobs = Clearcase::Vobs->new;
+
+ $dropdown .= popup_menu {
+ name => 'tag',
+ class => 'dropdown',
+ values => [sort $vobs->vobs],
+ default => $tag,
+ };
+ } else {
+ my $views = Clearcase::Views->new;
+
+ $dropdown .= popup_menu {
+ name => 'tag',
+ class => 'dropdown',
+ values => [sort $views->views],
+ default => $tag,
+ };
+ } # if
+
+ return span {id => $type}, $dropdown;
+} # makeTagsDropdown
+
+sub makeStoragePoolDropdown($$) {
+ my ($type, $tag) = @_;
+
+ my @values;
+
+ my $dropdown = 'Storage pool ';
+
+ if ($type eq 'vob') {
+ push @values, qw(admin db cleartext derivedobj source total);
+ } else {
+ push @values, qw(admin db private total);
+ } # if
+
+ $dropdown .= popup_menu {
+ name => 'storage',
+ class => 'dropdown',
+ values => \@values,
+ default => $tag,
+ };
+
+ return span {id => $type}, $dropdown;
+} # makeStoragePoolsDropdown
+
+sub makeFilesystemDropdown($;$$$) {
my ($system, $label, $default, $onchange) = @_;
$label ||= '';
-
+
my %filesystems;
-
- foreach ($clearadm->FindFilesystem ($system)) {
+
+ for ($clearadm->FindFilesystem ($system)) {
my %filesystem = %{$_};
-
+
my $value = "$filesystem{filesystem} ($filesystem{mount})";
$filesystems{$filesystem{filesystem}} = $value;
- } # foreach
-
+ } # for
+
my $dropdown .= "$label ";
$dropdown .= popup_menu {
name => 'filesystem',
@@ -397,15 +454,15 @@ sub makeFilesystemDropdown ($;$$$) {
onChange => ($onchange) ? $onchange : '',
default => $default,
};
-
- return span {id => 'filesystems'}, $dropdown;
+
+ return span {id => 'filesystems'}, $dropdown;
} # makeFilesystemDropdown
-sub makeIntervalDropdown (;$$$) {
+sub makeIntervalDropdown(;$$$) {
my ($label, $default, $onchange) = @_;
-
+
$label ||= '';
-
+
my @intervals = (
'Minute',
'Hour',
@@ -413,9 +470,8 @@ sub makeIntervalDropdown (;$$$) {
'Month',
);
- $default = ucfirst lc $default
- if $default;
-
+ $default = ucfirst lc $default if $default;
+
my $dropdown = "$label ";
$dropdown .= popup_menu {
name => 'scaling',
@@ -425,66 +481,66 @@ sub makeIntervalDropdown (;$$$) {
default => $default,
onchange => $onchange,
};
-
- return span {id => 'scaling'}, $dropdown;
+
+ return span {id => 'scaling'}, $dropdown;
} # makeIntervalDropdown;
-sub makeNotificationDropdown (;$$) {
+sub makeNotificationDropdown(;$$) {
my ($label, $default) = @_;
-
+
$label ||= '';
my @values;
-
- push @values, $$_{name}
- foreach ($clearadm->FindNotification);
-
+
+ push @values, $$_{name}
+ for ($clearadm->FindNotification);
+
my $dropdown = "$label ";
$dropdown .= popup_menu {
name => 'notification',
class => 'dropdown',
values => [sort @values],
default => $default,
- };
-
+ };
+
return $dropdown;
} # makeNotificationDropdown
-sub makeRestartableDropdown (;$$) {
+sub makeRestartableDropdown(;$$) {
my ($label, $default) = @_;
-
+
$label ||= '';
my @values = (
'true',
'false',
);
-
+
my $dropdown = "$label ";
$dropdown .= popup_menu {
name => 'restartable',
class => 'dropdown',
values => [@values],
default => $default,
- };
-
+ };
+
return $dropdown;
} # makeRestartableDropdown
-sub makeSystemDropdown (;$$$%) {
+sub makeSystemDropdown(;$$$%) {
my ($label, $default, $onchange, %systems) = @_;
$label ||= '';
-
- foreach ($clearadm->FindSystem) {
+
+ for ($clearadm->FindSystem) {
my %system = %{$_};
-
+
my $value = $system{name};
$value .= $system{alias} ? " ($system{alias})" : '';
$systems{$system{name}} = $value;
- } # foreach
-
+ } # for
+
my $systemDropdown .= "$label ";
$systemDropdown .= popup_menu {
name => 'system',
@@ -494,32 +550,32 @@ sub makeSystemDropdown (;$$$%) {
onchange => ($onchange) ? $onchange : '',
default => $default,
};
-
+
return span {id => 'systems'}, $systemDropdown;
} # makeSystemDropdown
-sub makeTaskDropdown (;$$) {
+sub makeTaskDropdown(;$$) {
my ($label, $default) = @_;
-
+
$label ||= '';
my @values;
push @values, $$_{name}
- foreach ($clearadm->FindTask);
-
+ for ($clearadm->FindTask);
+
my $taskDropdown = "$label ";
$taskDropdown .= popup_menu {
name => 'task',
class => 'dropdown',
values => [sort @values],
default => $default,
- };
-
+ };
+
return $taskDropdown;
} # makeTaskDropdown
-sub makeTimeDropdown ($$$;$$$$$) {
+sub makeTimeDropdown($$$;$$$$$) {
my (
$table,
$elementID,
@@ -532,27 +588,27 @@ sub makeTimeDropdown ($$$;$$$$$) {
) = @_;
$label ||= '';
-
+
my @times;
-
+
$name ||= lc $label;
-
+
push @times, 'Earliest';
if ($table =~ /loadavg/i) {
push @times, $$_{timestamp}
- foreach ($clearadm->GetLoadavg ($system, undef, undef, undef, $interval));
+ for ($clearadm->GetLoadavg ($system, undef, undef, undef, $interval));
} elsif ($table =~ /filesystem/i) {
push @times, $$_{timestamp}
- foreach ($clearadm->GetFS ($system, $filesystem, undef, undef, undef, $interval));
- } # if
+ for ($clearadm->GetFS ($system, $filesystem, undef, undef, undef, $interval));
+ } # if
push @times, 'Latest';
-
+
unless ($default) {
$default = $name eq 'start' ? 'Earliest' : 'Latest';
} # unless
-
+
my $timeDropdown = "$label ";
$timeDropdown .= span {id => $elementID}, popup_menu {
name => $name,
@@ -560,11 +616,11 @@ sub makeTimeDropdown ($$$;$$$$$) {
values => [@times],
default => $default,
};
-
- return $timeDropdown;
+
+ return $timeDropdown;
} # makeTimeDropdown
-sub heading (;$$) {
+sub heading(;$$) {
my ($title, $type) = @_;
if ($title) {
@@ -572,131 +628,94 @@ sub heading (;$$) {
} else {
$title = $APPNAME;
} # if
-
+
display header;
display start_html {
- -title => $title,
- -author => 'Andrew DeFaria ',
- -meta => {
- keywords => 'ClearSCM Clearadm',
+ -title => $title,
+ -author => 'Andrew DeFaria ',
+ -meta => {
+ keywords => 'ClearSCM Clearadm',
copyright => 'Copyright (c) ClearSCM, Inc. 2010, All rights reserved',
- },
- -script => [{
- -language => 'JavaScript',
- -src => 'clearadm.js',
- }],
- -style => ['clearadm.css', 'clearmenu.css'],
+ },
+ -script => [{
+ -language => 'JavaScript',
+ -src => 'clearadm.js',
+ }],
+ -style => ['clearadm.css', 'clearmenu.css'],
}, $title;
return if $type;
-
+
my $ieTableWrapStart = '';
my $ieTableWrapEnd = '';
-
+
# Menubar
display div {id=>'mastheadlogo'}, h1 {class => 'title'}, $APPNAME;
display start_div {class => 'menu'};
-
+
# Home
display ul li a {href => '/clearadm'}, 'Home';
-
+
my @allSystems = $clearadm->FindSystem;
-
+
# Systems
display start_ul;
display start_li;
display a {href => 'systems.cgi'}, "Systems$ieTableWrapStart";
display start_ul;
- foreach (@allSystems) {
+ for (sort @allSystems) {
my %system = %{$_};
my $sysName = ucfirst $system{name};
$sysName .= " ($system{alias})"
if $system{alias};
-
+
display li a {
href => "systemdetails.cgi?system=$system{name}"
}, ucfirst " $sysName";
- } # foreach
+ } # for
display end_ul;
display $ieTableWrapEnd;
display end_li;
display end_li;
display end_ul;
-
+
# Filesystems
display start_ul;
display start_li;
display a {href => 'filesystems.cgi'}, "Filesystems$ieTableWrapStart";
display start_ul;
- foreach (@allSystems) {
+ for (@allSystems) {
my %system = %{$_};
my $sysName = ucfirst $system{name};
$sysName .= " ($system{alias})"
if $system{alias};
-
+
display li a {
href => "filesystems.cgi?system=$system{name}"
}, ucfirst " $sysName";
- } # foreach
+ } # for
display end_ul;
display $ieTableWrapEnd;
display end_li;
display end_ul;
-
- # Servers
- display start_ul;
- display start_li;
- display a {href => '#'}, "Servers$ieTableWrapStart";
- display start_ul {class => 'skinny'};
- display start_li;
- display start_a {href => 'vobs.cgi'};
- display "VOB»$ieTableWrapStart";
- display start_ul;
- display li a {href => "systemdetails.cgi?system=jupiter"}, ' Jupiter (defaria.com)';
- display end_ul;
- display $ieTableWrapEnd;
- display end_li;
-
- display start_li;
- display start_a {href => 'views.cgi'};
- display "View»$ieTableWrapStart";
- display start_ul;
- display li a {href => "systemdetails.cgi?system=earth"}, ' Earth';
- display li a {href => "systemdetails.cgi?system=mars"}, ' Mars';
- display end_ul;
- display $ieTableWrapEnd;
- display end_ul;
- display $ieTableWrapEnd;
- display end_li;
- display end_ul;
-
+
# Vobs
display start_ul;
display start_li;
- display a {href => 'vobs.cgi'}, "VOBs$ieTableWrapStart";
- display start_ul;
- display li a {href => '#'}, ' /vobs/clearscm';
- display li a {href => '#'}, ' /vobs/clearadm';
- display li a {href => '#'}, ' /vobs/test';
- display li a {href => '#'}, ' /vobs/test2';
- display end_ul;
+ display a {href => 'vobservers.cgi'}, " VOBs$ieTableWrapStart";
display $ieTableWrapEnd;
display end_li;
- display end_ul;
-
+ display end_ul;
+
# Views
display start_ul;
display start_li;
- display a {href => 'views.cgi'}, "Views$ieTableWrapStart";
- display start_ul;
- display li a {href => 'viewager.cgi'}, ' View Ager';
- display li a {href => '#'}, ' Releast View';
- display end_ul;
+ display a {href => 'viewager.cgi'}, "Views$ieTableWrapStart";
display $ieTableWrapEnd;
display end_li;
- display end_ul;
+ display end_ul;
# Configure
display start_ul;
@@ -710,8 +729,8 @@ sub heading (;$$) {
display end_ul;
display $ieTableWrapEnd;
display end_li;
- display end_ul;
-
+ display end_ul;
+
# Logs
display start_ul;
display start_li;
@@ -722,8 +741,8 @@ sub heading (;$$) {
display end_ul;
display $ieTableWrapEnd;
display end_li;
- display end_ul;
-
+ display end_ul;
+
# Help
display start_ul;
display start_li;
@@ -735,15 +754,15 @@ sub heading (;$$) {
display end_li;
display end_ul;
display end_div;
-
+
display start_div {class => 'page'};
-
+
return;
} # heading
-sub displayAlert (;$) {
+sub displayAlert(;$) {
my ($alert) = @_;
-
+
display start_table {cellspacing => 1};
display start_Tr;
@@ -753,15 +772,15 @@ sub displayAlert (;$) {
display th {class => 'labelCentered'}, 'Who';
display th {class => 'labelCentered'}, 'Category';
display end_Tr;
-
- foreach ($clearadm->FindAlert ($alert)) {
+
+ for ($clearadm->FindAlert ($alert)) {
my %alert = %{$_};
-
+
$alert{who} = setField $alert{who}, 'System Administrator';
-
+
display start_Tr;
my $areYouSure = "Are you sure you want to delete the $alert{name} alert?";
-
+
my $actions = start_form {
method => 'post',
action => 'processalert.cgi',
@@ -782,7 +801,7 @@ sub displayAlert (;$) {
alt => 'Delete',
value => 'Delete',
title => 'Cannot delete predefined alert',
- };
+ };
$actions .= input {
name => 'edit',
disabled => 'true',
@@ -812,10 +831,10 @@ sub displayAlert (;$) {
};
} # if
- display end_form;
+ display end_form;
my $who = $alert{who};
-
+
if ($who =~ /^([a-zA-Z0-9._-]+)@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})$/) {
$who = a {href => "mailto:$1\@$2"}, $who;
} # if
@@ -827,10 +846,10 @@ sub displayAlert (;$) {
display td {class => 'data'},
(InArray $alert{name}, @PREDEFINED_ALERTS) ? 'Predefined' : 'User Defined';
display end_Tr;
- } # foreach
+ } # for
+
+ display end_table;
- display end_table;
-
display p {class => 'center'}, a {
href => 'processalert.cgi?action=Add',
}, 'New alert ', img {
@@ -841,20 +860,20 @@ sub displayAlert (;$) {
return;
} # DisplayAlerts
-sub displayAlertlog (%) {
+sub displayAlertlog(%) {
my (%opts) = @_;
-
+
my $optsChanged;
-
+
unless (($opts{oldalert} and $opts{alert} and
$opts{oldalert} eq $opts{alert}) and
($opts{oldsystem} and $opts{system} and
$opts{oldsystem} eq $opts{system}) and
($opts{oldnotification} and $opts{notification} and
$opts{oldnotification} eq $opts{notification})) {
- $optsChanged = 1;
+ $optsChanged = 1;
} # unless
-
+
my $condition;
unless ($opts{id}) {
@@ -881,7 +900,7 @@ sub displayAlertlog (%) {
$opts{start} = 0;
} # if
- my $next = $opts{start} + $opts{page} < $total
+ my $next = $opts{start} + $opts{page} < $total
? $opts{start} + $opts{page}
: $opts{start};
my $prev = $opts{start} - $opts{page} >= 0
@@ -896,14 +915,14 @@ sub displayAlertlog (%) {
$opts .= " of $total";
display start_form {
- method => 'post',
+ method => 'post',
action => 'alertlog.cgi'
};
# Hidden fields to pass along
display input {name => 'prev', type => 'hidden', value => $prev};
display input {name => 'next', type => 'hidden', value => $next};
-
+
display input {
name => 'oldalert',
type => 'hidden',
@@ -942,7 +961,7 @@ sub displayAlertlog (%) {
disabled => 'disabled',
};
} # unless
-
+
$caption .= td {align => 'center'}, $opts;
unless ($opts{id}) {
@@ -1013,12 +1032,12 @@ sub displayAlertlog (%) {
type => 'button',
value => 'Clear All Events',
onclick => "return AreYouSure('Are you sure you want to delete all alerts?');",
- };
+ };
display end_Tr;
-
+
my $i = $opts{start};
- foreach ($clearadm->FindAlertlog (
+ for ($clearadm->FindAlertlog (
$opts{alert},
$opts{system},
$opts{notification},
@@ -1026,10 +1045,10 @@ sub displayAlertlog (%) {
$opts{page},
)) {
my %alertlog = setFields 'N/A', %{$_};
-
+
display start_Tr;
my %system = $clearadm->GetSystem ($alertlog{system});
-
+
display td {class => 'dataCentered'}, ++$i;
display td {class => 'dataCentered'}, a {
href => "deletealertlog.cgi?alertlogid=$alertlog{id}"
@@ -1055,20 +1074,20 @@ sub displayAlertlog (%) {
}, $alertlog{runlog};
display td {class => 'data'}, $alertlog{message};
display end_Tr;
- } # foreach
+ } # for
display end_form;
- display end_table;
-
+ display end_table;
+
return;
} # displayAlertlog
-sub displayFilesystem ($) {
+sub displayFilesystem($) {
my ($systemName) = @_;
display start_table {cellspacing => 1, width => '98%'};
-
+
display start_Tr;
display th {class => 'labelCentered'}, 'Action';
display th {class => 'labelCentered'}, 'Name';
@@ -1082,17 +1101,17 @@ sub displayFilesystem ($) {
display th {class => 'labelCentered'}, 'Threshold';
display th {class => 'labelCentered'}, 'Usage';
display end_Tr;
-
- foreach ($clearadm->FindSystem ($systemName)) {
+
+ for (sort { $a->{mount} cmp $b->{mount} } $clearadm->FindSystem ($systemName)) {
my %system = %{$_};
-
+
%system = setFields ('N/A', %system);
my $admin = ($system{email} !~ 'N/A')
? a {-href => "mailto:$system{email}"}, $system{admin}
: $system{admin};
-
- foreach ($clearadm->FindFilesystem ($system{name})) {
+
+ for ($clearadm->FindFilesystem ($system{name})) {
my %filesystem = %{$_};
my %fs = $clearadm->GetLatestFS ($system{name}, $filesystem{filesystem});
@@ -1101,9 +1120,9 @@ sub displayFilesystem ($) {
my $used = autoScale $fs{used};
my $free = autoScale $fs{free};
- # TODO: Note that this percentages does not agree with df output. I'm not
+ # TODO: Note that this percentages does not agree with df output. I'm not
# sure why.
- my $usedPct = $fs{size} == 0 ? 0
+ my $usedPct = $fs{size} == 0 ? 0
: sprintf ('%.0f',
(($fs{reserve} + $fs{used}) / $fs{size} * 100));
@@ -1112,19 +1131,19 @@ sub displayFilesystem ($) {
href => "systemdetails.cgi?system=$system{name}"
}, $system{alias}
: $system{alias};
-
- my $class = $usedPct < $filesystem{threshold}
+
+ my $class = $usedPct < $filesystem{threshold}
? 'data'
: 'dataAlert';
- my $classRight = $usedPct < $filesystem{threshold}
+ my $classRight = $usedPct < $filesystem{threshold}
? 'dataRight'
: 'dataRightAlert';
- my $classCentered = $usedPct < $filesystem{threshold}
+ my $classCentered = $usedPct < $filesystem{threshold}
? 'dataCentered'
: 'dataCenteredAlert';
my $classRightTop = $usedPct < $filesystem{threshold}
? 'dataRightTop'
- : 'dataRightAlertTop';
+ : 'dataRightAlertTop';
display start_Tr;
display start_td {class => 'dataCentered'};
@@ -1138,7 +1157,7 @@ sub displayFilesystem ($) {
method => 'post',
action => "processfilesystem.cgi",
};
-
+
display input {
type => 'hidden',
name => 'system',
@@ -1149,7 +1168,7 @@ sub displayFilesystem ($) {
name => 'filesystem',
value => $filesystem{filesystem},
};
-
+
display input {
name => 'delete',
type => 'image',
@@ -1167,20 +1186,20 @@ sub displayFilesystem ($) {
value => 'Edit',
title => 'Edit',
};
-
+
if ($filesystem{notification}) {
display a {
href => "alertlog.cgi?system=$filesystem{system}"}, img {
src => 'alert.png',
border => 0,
alt => 'Alert!',
- title => 'This filesystem has alerts',
+ title => 'This filesystem has alerts',
};
- } # if
-
+ } # if
+
display end_form;
-
- display end_td;
+
+ display end_td;
display td {class => $class},
a {-href => "systemdetails.cgi?system=$system{name}"}, $system{name};
display td {class => $class}, $alias;
@@ -1189,30 +1208,34 @@ sub displayFilesystem ($) {
display td {class => $class}, $filesystem{mount};
display td {class => $class}, $filesystem{fstype};
display td {class => $classCentered}, $filesystem{filesystemHist};
- display td {class => $classRightTop}, "$used ($usedPct%)
",
+ display td {class => $classRightTop}, "$used ($usedPct%)
",
font {class => 'unknown'}, "$fs{timestamp}";
display td {class => $classRightTop}, "$filesystem{threshold}%";
+
+ my $image = $filesystem{fssmall}
+ ? "data:image/png;base64,$filesystem{fssmall}"
+ : "plotfs.cgi?system=$system{name}&filesystem=$filesystem{filesystem}&tiny=1";
+
display td {class => $class},
- a {href =>
+ a {href =>
"plot.cgi?type=filesystem&system=$system{name}"
. "&filesystem=$filesystem{filesystem}&scaling=Day&points=7"
}, img {
- src => "plotfs.cgi?system=$system{name}"
- . "&filesystem=$filesystem{filesystem}&tiny=1",
+ src => $image,
border => 0,
};
display end_Tr;
- } # foreach
- } # foreach
+ } # for
+ } # for
display end_table;
-
+
return;
} # displayFilesystem
-sub displayNotification (;$) {
+sub displayNotification(;$) {
my ($notification) = @_;
-
+
display start_table {cellspacing => 1};
display start_Tr;
@@ -1223,14 +1246,14 @@ sub displayNotification (;$) {
display th {class => 'labelCentered'}, 'Not More Than';
display th {class => 'labelCentered'}, 'Category';
display end_Tr;
-
- foreach ($clearadm->FindNotification ($notification)) {
+
+ for ($clearadm->FindNotification ($notification)) {
my %notification= setFields 'N/A', %{$_};
-
+
display start_Tr;
my $areYouSure = "Are you sure you want to delete the $notification{name} "
. 'notification?';
-
+
my $actions = start_form {
method => 'post',
action => 'processnotification.cgi',
@@ -1241,7 +1264,7 @@ sub displayNotification (;$) {
type => 'hidden',
value => $notification{name},
};
-
+
if (InArray $notification{name}, @PREDEFINED_NOTIFICATIONS) {
$actions .= input {
name => 'delete',
@@ -1251,7 +1274,7 @@ sub displayNotification (;$) {
alt => 'Delete',
value => 'Delete',
title => 'Cannot delete predefined notification',
- };
+ };
$actions .= input {
name => 'edit',
disabled => 'true',
@@ -1280,8 +1303,8 @@ sub displayNotification (;$) {
title => 'Edit',
};
} # if
-
- display end_form;
+
+ display end_form;
display td {class => 'dataCentered'}, $actions;
display td {class => 'data'}, $notification{name};
@@ -1291,15 +1314,15 @@ sub displayNotification (;$) {
display td {class => 'data'}, $notification{cond};
display td {class => 'data'}, $notification{nomorethan};
display td {class => 'data'},
- (InArray $notification{name}, @PREDEFINED_NOTIFICATIONS)
+ (InArray $notification{name}, @PREDEFINED_NOTIFICATIONS)
? 'Predefined'
: 'User Defined';
-
+
display end_Tr;
- } # foreach
+ } # for
display end_table;
-
+
display p {class => 'center'}, a {
href => 'processnotification.cgi?action=Add',
}, 'New notification', img {
@@ -1310,42 +1333,41 @@ sub displayNotification (;$) {
return;
} # displayNotification
-sub displayRunlog (%) {
+sub displayRunlog(%) {
my (%opts) = @_;
-
+
my $optsChanged;
-
- unless (($opts{oldtask} and $opts{task} or
- $opts{oldtask} eq $opts{task}) and
- ($opts{oldsystem} and $opts{system} or
- $opts{oldsystem} eq $opts{system}) and
- ($opts{oldnot} and $opts{not} or
- $opts{oldnot} eq $opts{not}) and
- ($opts{oldstatus} and $opts{status} or
- $opts{oldstatus} eq $opts{status})) {
- $optsChanged = 1;
- } # unless
-
- my $condition;
+
+ for (qw(task system not status)) {
+ my $old = "old$_";
+ if (($opts{$old} and $opts{$_}) and ($opts{$old} ne $opts{$_})) {
+ $optsChanged = 1;
+ last;
+ } # if
+ } # for
+
+ my $condition = '';
unless ($opts{id}) {
- $condition = "task like '%";
- $condition .= $opts{task} ? $opts{task} : '';
- $condition .= "%'";
-
- if ($opts{system}) {
+ if ($opts{task} !~ /all/i) {
+ $condition = "task like '%";
+ $condition .= $opts{task} ? $opts{task} : '';
+ $condition .= "%'";
+ } # if
+
+ if ($opts{system} !~ /all/i) {
if ($opts{system} eq '') {
$condition .= ' and system is null';
undef $opts{system}
} elsif ($opts{system} ne 'All') {
- $condition .= " and system like '%$opts{system}%'";;
+ $condition .= " and system like '%$opts{system}%'";;
} # if
} # if
- if (defined $opts{status}) {
+ if ($opts{status} !~ /all/i) {
$condition .= ' and ';
unless ($opts{not}) {
- $condition .= "status=$opts{status}";
+ $condition .= "status=$opts{status}";
} else {
$condition .= "status<>$opts{status}";
} # unless
@@ -1353,13 +1375,13 @@ sub displayRunlog (%) {
} # unless
my $total = $clearadm->Count ('runlog', $condition);
-
+
$opts{start} = $opts{'nextArrow.x'} ? $opts{next} : $opts{prev};
$opts{start} ||= 0;
$opts{start} = 0
if $optsChanged;
-
- my $next = $opts{start} + $opts{page} < $total
+
+ my $next = $opts{start} + $opts{page} < $total
? $opts{start} + $opts{page}
: $opts{start};
my $prev = $opts{start} - $opts{page} >= 0
@@ -1374,7 +1396,7 @@ sub displayRunlog (%) {
$opts .= " of $total";
display start_form {
- method => 'post',
+ method => 'post',
action => 'runlog.cgi'
};
@@ -1408,7 +1430,7 @@ sub displayRunlog (%) {
disabled => 'disabled',
};
} # unless
-
+
$caption .= td {align => 'center'}, $opts;
unless ($opts{id}) {
@@ -1444,12 +1466,12 @@ sub displayRunlog (%) {
display th {class => 'labelCentered'}, 'Status';
display th {class => 'labelCentered'}, 'Message';
display end_Tr;
-
+
display start_Tr;
$opts{not} ||= 'false';
display start_form {
- method => 'post',
+ method => 'post',
action => 'runlog.cgi'
};
display td {
@@ -1482,21 +1504,21 @@ sub displayRunlog (%) {
type => 'submit',
value => 'Update',
};
-
+
display end_form;
display end_Tr;
my $i = $opts{start};
my $status;
-
- if (defined $opts{status}) {
+
+ if ($opts{status}) {
if ($opts{status} !~ /all/i) {
$status = $opts{not} ne 'true' ? $opts{status} : "!$opts{status}";
} # if
} # if
-
- foreach ($clearadm->FindRunlog (
+
+ for ($clearadm->FindRunlog (
$opts{task},
$opts{system},
$status,
@@ -1505,8 +1527,8 @@ sub displayRunlog (%) {
$opts{page},
)) {
my %runlog = setFields 'N/A', %{$_};
-
- my $class = $runlog{status} == 0
+
+ my $class = $runlog{status} == 0
? 'data'
: 'dataAlert';
my $classCentered = $runlog{status} == 0
@@ -1515,14 +1537,14 @@ sub displayRunlog (%) {
my $classRight = $runlog{status} == 0
? 'dataRight'
: 'dataAlertRight';
-
+
display start_Tr;
display td {class => 'dataCentered'}, ++$i;
display td {class => 'dataCentered'}, $runlog{id};
display td {class => 'data'}, a {
href => "tasks.cgi?task=$runlog{task}"
}, $runlog{task};
- display td {class => 'data'}, $runlog{system} eq 'Localhost'
+ display td {class => 'data'}, $runlog{system} eq 'localhost'
? $runlog{system}
: a {
href => "systemdetails.cgi?system=$runlog{system}"
@@ -1530,20 +1552,20 @@ sub displayRunlog (%) {
display td {class => 'dataCentered'}, $runlog{started};
display td {class => 'dataCentered'}, $runlog{ended};
display td {class => $classRight}, $runlog{status};
-
+
my $message = $runlog{message};
$message =~ s/\r\n/
/g;
-
+
display td {class => $class, width => '50%'}, $message;
display end_Tr;
- } # foreach
+ } # for
display end_table;
-
+
return;
} # displayRunlog
-sub displaySchedule () {
+sub displaySchedule() {
display start_table {cellspacing => 1};
display start_Tr;
@@ -1555,14 +1577,14 @@ sub displaySchedule () {
display th {class => 'labelCentered'}, 'Frequency';
display th {class => 'labelCentered'}, 'Category';
display end_Tr;
-
- foreach ($clearadm->FindSchedule) {
+
+ for ($clearadm->FindSchedule) {
my %schedule = setFields 'N/A', %{$_};
-
+
display start_Tr;
my $areYouSure = "Are you sure you want to delete the $schedule{name} "
. "schedule?";
-
+
my $actions = start_form {
method => 'post',
action => 'processschedule.cgi',
@@ -1573,7 +1595,7 @@ sub displaySchedule () {
type => 'hidden',
value => $schedule{name},
};
-
+
if (InArray $schedule{name}, @PREDEFINED_SCHEDULES) {
$actions .= input {
name => 'delete',
@@ -1583,7 +1605,7 @@ sub displaySchedule () {
alt => 'Delete',
value => 'Delete',
title => 'Cannot delete predefined schedule',
- };
+ };
$actions .= input {
name => 'edit',
disabled => 'true',
@@ -1612,9 +1634,9 @@ sub displaySchedule () {
title => 'Edit',
};
} # if
-
- display end_form;
-
+
+ display end_form;
+
display td {class => 'dataCentered'}, $actions;
display td {class => 'dataCentered'}, checkbox {
disabled => 'disabled',
@@ -1629,15 +1651,15 @@ sub displaySchedule () {
}, $schedule{notification};
display td {class => 'data'}, $schedule{frequency};
display td {class => 'data'},
- (InArray $schedule{name}, @PREDEFINED_SCHEDULES)
- ? 'Predefined'
- : 'User Defined';
-
+ (InArray $schedule{name}, @PREDEFINED_SCHEDULES)
+ ? 'Predefined'
+ : 'User Defined';
+
display end_Tr;
- } # foreach
+ } # for
display end_table;
-
+
display p {class => 'center'}, a {
href => 'processschedule.cgi?action=Add',
}, 'New schedule', img {
@@ -1648,19 +1670,19 @@ sub displaySchedule () {
return;
} # displaySchedule
-sub displaySystem ($) {
+sub displaySystem($) {
my ($systemName) = @_;
-
+
my %system = $clearadm->GetSystem ($systemName);
-
+
unless (%system) {
displayError "Nothing known about system $systemName";
return;
} # unless
-
+
my $lastheardfromClass = 'dataCentered';
my $lastheardfromData = $system{lastheardfrom};
-
+
my %load = $clearadm->GetLatestLoadavg ($systemName);
unless ($clearadm->SystemAlive (%system)) {
@@ -1676,18 +1698,18 @@ sub displaySystem ($) {
my $admin = ($system{email})
? a {-href => "mailto:$system{email}"}, $system{admin}
: $system{admin};
-
+
$system{alias} = setField $system{alias}, 'N/A';
$system{region} = setField $system{region}, 'N/A';
display start_table {cellspacing => 1};
-
+
display start_Tr;
my $areYouSure = 'Are you sure you want to delete this system?\n'
. "Doing so will remove all records related to $system{name}"
. '\nincluding filesystem records and history as well as '
. 'loadavg history.';
-
+
my $actions = start_form {
method => 'post',
action => 'processsystem.cgi',
@@ -1698,7 +1720,7 @@ sub displaySystem ($) {
type => 'hidden',
value => $system{name},
};
-
+
$actions .= input {
name => 'delete',
type => 'image',
@@ -1719,18 +1741,18 @@ sub displaySystem ($) {
$actions .= checkbox {
disabled => 'disabled',
checked => $system{active} eq 'true' ? 1 : 0,
- };
-
+ };
+
if ($system{notification}) {
$actions .= a {
href => "alertlog.cgi?system=$system{name}"}, img {
src => 'alert.png',
border => 0,
alt => 'Alert!',
- title => 'This system has alerts',
+ title => 'This system has alerts',
};
} # if
-
+
display th {class => 'label'}, "$actions Name:";
display end_form;
display td {class => 'dataCentered', colspan => 2}, $system{name};
@@ -1741,12 +1763,12 @@ sub displaySystem ($) {
display th {class => 'label', colspan => 2}, 'Type:';
display td {class => 'dataCentered'}, $system{type};
display end_Tr;
-
+
display start_Tr;
display th {class => 'label'}, 'OS Version:';
- display td {class => 'data', colspan => 10}, $system{os};
+ display td {class => 'data', colspan => 10}, $system{os};
display end_Tr;
-
+
display start_Tr;
display th {class => 'label'}, 'Last Contacted:';
display td {
@@ -1762,23 +1784,23 @@ sub displaySystem ($) {
display td {class => 'dataCentered'}, $system{loadavgHist};
display th {class => 'label'}, 'Load Avg:';
display td {class => 'data'},
- a {href =>
+ a {href =>
"plot.cgi?type=loadavg&system=$system{name}&scaling=Hour&points=24"
}, img {
- src => "plotloadavg.cgi?system=$system{name}&tiny=1",
+ src => "data:image/png;base64,$system{loadavgsmall}",
border => 0,
};
-
+
my $description = $system{description};
$description =~ s/\r\n/
/g;
-
+
display start_Tr;
display th {class => 'label'}, 'Description:';
- display td {class => 'data', colSpan => 10}, $description;
+ display td {class => 'data', colSpan => 10}, $description;
display end_Tr;
-
+
display end_table;
-
+
display p {class => 'center'}, a {
href => 'processsystem.cgi?action=Add',
}, 'New system', img {
@@ -1786,11 +1808,11 @@ sub displaySystem ($) {
border => 0,
};
- display h1 {class => 'center'},
+ display h1 {class => 'center'},
'Filesystem Details: ' . ucfirst $system{name};
-
+
display start_table {cellspacing => 1};
-
+
display start_Tr;
display th {class => 'labelCentered'}, 'Action';
display th {class => 'labelCentered'}, 'Filesystem';
@@ -1803,85 +1825,86 @@ sub displaySystem ($) {
display th {class => 'labelCentered'}, 'Threshold';
display th {class => 'labelCentered'}, 'History';
display th {class => 'labelCentered'}, 'Usage';
- display end_Tr;
-
- foreach ($clearadm->FindFilesystem ($system{name})) {
+ display end_Tr;
+
+ for ($clearadm->FindFilesystem ($system{name})) {
my %filesystem = %{$_};
-
+
my %fs = $clearadm->GetLatestFS (
- $filesystem{system},
+ $filesystem{system},
$filesystem{filesystem}
);
-
+
my $size = autoScale $fs{size};
my $used = autoScale $fs{used};
- my $free = autoScale $fs{free};
+ my $free = autoScale $fs{free};
- # TODO: Note that this percentages does not agree with df output. I'm not
+ # TODO: Note that this percentages does not agree with df output. I'm not
# sure why.
- my $usedPct = $fs{size} == 0 ? 0
+ my $usedPct = $fs{size} == 0 ? 0
: sprintf ('%.0f',
(($fs{reserve} + $fs{used}) / $fs{size} * 100));
-
- my $class = $usedPct < $filesystem{threshold}
+
+ my $class = $usedPct < $filesystem{threshold}
? 'data'
: 'dataAlert';
my $classCentered = $class . 'Centered';
my $classRight = $class . 'Right';
-
+
display start_Tr;
- display start_td {class => 'data'};
+ display start_td {class => 'data'};
- my $areYouSure = 'Are you sure you want to delete '
- . "$system{name}:$filesystem{filesystem}?" . '\n'
- . 'Doing so will remove all records related to this\n'
- . 'filesystem and its history.';
+ my $areYouSure = 'Are you sure you want to delete '
+ . "$system{name}:$filesystem{filesystem}?" . '\n'
+ . 'Doing so will remove all records related to this\n'
+ . 'filesystem and its history.';
- display start_form {
- method => 'post',
- action => 'processfilesystem.cgi',
- };
-
- display input {
- type => 'hidden',
- name => 'system',
- value => $system{name},
- };
- display input {
- type => 'hidden',
- name => 'filesystem',
- value => $filesystem{filesystem},
- };
-
- display input {
- name => 'delete',
- type => 'image',
- src => 'delete.png',
- alt => 'Delete',
- value => 'Delete',
- title => 'Delete',
- onclick => "return AreYouSure ('$areYouSure');"
- };
- display input {
- name => 'edit',
- type => 'image',
- src => 'edit.png',
- alt => 'Edit',
- value => 'Edit',
- title => 'Edit',
+ display start_form {
+ method => 'post',
+ action => 'processfilesystem.cgi',
+ };
+
+ display input {
+ type => 'hidden',
+ name => 'system',
+ value => $system{name},
+ };
+ display input {
+ type => 'hidden',
+ name => 'filesystem',
+ value => $filesystem{filesystem},
+ };
+
+ display input {
+ name => 'delete',
+ type => 'image',
+ src => 'delete.png',
+ alt => 'Delete',
+ value => 'Delete',
+ title => 'Delete',
+ onclick => "return AreYouSure ('$areYouSure');"
+ };
+ display input {
+ name => 'edit',
+ type => 'image',
+ src => 'edit.png',
+ alt => 'Edit',
+ value => 'Edit',
+ title => 'Edit',
+ };
+
+ if ($filesystem{notification}) {
+ display a {
+ href => "alertlog.cgi?system=$filesystem{system}"}, img {
+ src => 'alert.png',
+ border => 0,
+ alt => 'Alert!',
+ title => 'This filesystem has alerts',
};
-
- if ($filesystem{notification}) {
- display a {
- href => "alertlog.cgi?system=$filesystem{system}"}, img {
- src => 'alert.png',
- border => 0,
- alt => 'Alert!',
- title => 'This filesystem has alerts',
- };
- } # if
+ } # if
+
+ display end_form;
- display end_form;
display td {class => $class}, $filesystem{filesystem};
display td {class => $classCentered}, $filesystem{fstype};
display td {class => $class}, $filesystem{mount};
@@ -1891,28 +1914,26 @@ sub displaySystem ($) {
display td {class => $classRight}, "$usedPct%";
display td {class => $classRight}, "$filesystem{threshold}%";
display td {class => $classCentered}, $filesystem{filesystemHist};
- display td {class => $classCentered},
- a {href =>
+ display td {class => $classCentered},
+ a {href =>
"plot.cgi?type=filesystem&system=$system{name}"
. "&filesystem=$filesystem{filesystem}"
. "&scaling=Day&points=7"
}, img {
- src => "plotfs.cgi?system=$system{name}&"
- . "filesystem=$filesystem{filesystem}"
- . '&tiny=1',
- border => 0,
+ src => "data:image/png;base64,$filesystem{fssmall}",
+ border => 0,
};
display end_Tr;
- } # foreach
+ } # for
display end_table;
-
+
return;
} # displaySystem
-sub displayTask (;$) {
+sub displayTask(;$) {
my ($task) = @_;
-
+
display start_table {cellspacing => 1, width => '98%'};
display start_Tr;
@@ -1924,16 +1945,16 @@ sub displayTask (;$) {
display th {class => 'labelCentered'}, 'Restartable';
display th {class => 'labelCentered'}, 'Category';
display end_Tr;
-
- foreach ($clearadm->FindTask ($task)) {
+
+ for ($clearadm->FindTask ($task)) {
my %task = %{$_};
-
+
$task{system} = 'All Systems'
unless $task{system};
-
+
display start_Tr;
my $areYouSure = "Are you sure you want to delete the $task{name} task?";
-
+
my $actions = start_form {
method => 'post',
action => 'processtask.cgi',
@@ -1954,7 +1975,7 @@ sub displayTask (;$) {
alt => 'Delete',
value => 'Delete',
title => 'Cannot delete predefined task',
- };
+ };
$actions .= input {
name => 'edit',
disabled => 'true',
@@ -1984,34 +2005,34 @@ sub displayTask (;$) {
};
} # if
- display end_form;
+ display end_form;
display td {class => 'dataCentered'}, $actions;
display td {class => 'data'}, $task{name};
- display td {class => 'data'}, $task{system};
+ display td {class => 'data'}, $task{system};
display td {class => 'data'}, $task{description};
display td {class => 'data'}, $task{command};
display td {class => 'dataCentered'}, $task{restartable};
- display td {class => 'data'},
+ display td {class => 'data'},
(InArray $task{name}, @PREDEFINED_TASKS) ? 'Predefined' : 'User Defined';
display end_Tr;
- } # foreach
+ } # for
+
+ display end_table;
- display end_table;
-
display p {class => 'center'}, a {
href => 'processtask.cgi?action=Add',
}, 'New task', img {
src => 'add.png',
border => 0,
};
-
+
return;
} # DisplayAlerts
-sub editAlert (;$) {
+sub editAlert(;$) {
my ($alert) = @_;
-
+
display start_form (
-method => 'post',
-action => 'processalert.cgi',
@@ -2022,10 +2043,10 @@ sub editAlert (;$) {
if ($alert) {
%alert = $clearadm->GetAlert ($alert);
-
+
return
- unless %alert;
-
+ unless %alert;
+
display input {
name => 'oldname',
type => 'hidden',
@@ -2034,21 +2055,21 @@ sub editAlert (;$) {
} else {
$alert= '';
} # if
-
+
display input {
name => 'action',
type => 'hidden',
value => 'Post',
};
-
+
display start_table {cellspacing => 1};
-
+
display start_Tr;
display th {class => 'labelCentered'}, 'Name';
display th {class => 'labelCentered'}, 'Type';
display th {class => 'labelCentered'}, 'Who';
display end_Tr;
-
+
display start_Tr;
display td {
class => 'data',
@@ -2080,26 +2101,26 @@ sub editAlert (;$) {
};
display end_Tr;
display end_table;
-
+
display '';
display p submit ({value => $alert ? 'Update' : 'Add'}), reset;
display '';
-
+
display end_form;
-
+
return;
} # editAlert
-sub editFilesystem ($$) {
+sub editFilesystem($$) {
my ($system, $filesystem) = @_;
-
+
display start_form (
-method => 'post',
-action => 'processfilesystem.cgi',
);
display start_table {width => '800px', cellspacing => 1};
-
+
display start_Tr;
display th {class => 'labelCentered'}, 'Filesystem';
display th {class => 'labelCentered'}, 'Type';
@@ -2110,11 +2131,11 @@ sub editFilesystem ($$) {
display th {class => 'labelCentered'}, 'Used %';
display th {class => 'labelCentered'}, 'History';
display th {class => 'labelCentered'}, 'Threshold';
- display end_Tr;
-
+ display end_Tr;
+
my %filesystem = $clearadm->GetFilesystem ($system, $filesystem);
my %fs = $clearadm->GetLatestFS ($system, $filesystem);
-
+
display input {
name => 'action',
type => 'hidden',
@@ -2124,13 +2145,13 @@ sub editFilesystem ($$) {
name => 'system',
type => 'hidden',
value => $filesystem{system},
- };
+ };
display input {
name => 'filesystem',
type => 'hidden',
value => $filesystem{filesystem},
- } ;
-
+ } ;
+
my $size = autoScale $fs{size};
my $used = autoScale $fs{used};
my $free = autoScale $fs{free};
@@ -2142,11 +2163,11 @@ sub editFilesystem ($$) {
display td {class => 'dataRight'}, $size;
display td {class => 'dataRight'}, $used;
display td {class => 'dataRight'}, $free;
- # TODO: Note that this percentages does not agree with df output. I'm not
+ # TODO: Note that this percentages does not agree with df output. I'm not
# sure why.
display td {class => 'dataCentered'},
sprintf ('%.0f%%', (($fs{reserve} + $fs{used}) / $fs{size} * 100));
-
+
my $historyDropdown = popup_menu {
name => 'filesystemHist',
class => 'dropdown',
@@ -2166,34 +2187,34 @@ sub editFilesystem ($$) {
],
default => $system ? $filesystem{filesystemHist} : '6 months',
};
-
+
display td {
class => 'dataRight',
- }, $historyDropdown;
-
+ }, $historyDropdown;
+
my $thresholdDropdown = popup_menu {
name => 'threshold',
class => 'dropdown',
values => [1 .. 100],
default => $filesystem{threshold},
- };
+ };
display td {class => 'dataCentered'}, $thresholdDropdown . '%';
display end_Tr;
-
- display end_table;
-
+
+ display end_table;
+
display '';
display p submit ({value => 'Update'}), reset;
display '';
-
+
display end_form;
-
+
return;
} # editFilesytem
-sub editNotification (;$) {
+sub editNotification(;$) {
my ($notification) = @_;
-
+
display start_form (
-method => 'post',
-action => 'processnotification.cgi',
@@ -2204,10 +2225,10 @@ sub editNotification (;$) {
if ($notification) {
%notification = $clearadm->GetNotification ($notification);
-
+
return
- unless %notification;
-
+ unless %notification;
+
display input {
name => 'oldname',
type => 'hidden',
@@ -2216,22 +2237,22 @@ sub editNotification (;$) {
} else {
$notification = '';
} # if
-
+
display input {
name => 'action',
type => 'hidden',
value => 'Post',
};
-
+
display start_table {cellspacing => 1};
-
+
display start_Tr;
display th {class => 'labelCentered'}, 'Name';
display th {class => 'labelCentered'}, 'Alert';
display th {class => 'labelCentered'}, 'Condition';
display th {class => 'labelCentered'}, 'Not More Than';
display end_Tr;
-
+
display start_Tr;
display td {
class => 'data',
@@ -2243,13 +2264,13 @@ sub editNotification (;$) {
type => 'text',
value => $notification ? $notification{name} : '',
};
-
+
display td {
class => 'dataCentered',
- }, makeAlertDropdown undef, $notification{alert}
+ }, makeAlertDropdown undef, $notification{alert}
? $notification{alert}
: 'Email admin';
-
+
display td {
class => 'data',
}, input {
@@ -2263,22 +2284,22 @@ sub editNotification (;$) {
display td {
class => 'dataCentered',
}, makeNoMoreThanDropdown undef, $notification{nomorethan};
-
+
display end_Tr;
display end_table;
-
+
display '';
display p submit ({value => $notification ? 'Update' : 'Add'}), reset;
display '';
-
+
display end_form;
-
+
return;
} # editNotification
-sub editSchedule (;$) {
+sub editSchedule(;$) {
my ($schedule) = @_;
-
+
display start_form (
-method => 'post',
-action => 'processschedule.cgi',
@@ -2289,10 +2310,10 @@ sub editSchedule (;$) {
if ($schedule) {
%schedule = $clearadm->GetSchedule ($schedule);
-
+
return
- unless %schedule;
-
+ unless %schedule;
+
display input {
name => 'oldname',
type => 'hidden',
@@ -2301,15 +2322,15 @@ sub editSchedule (;$) {
} else {
$schedule = '';
} # if
-
+
display input {
name => 'action',
type => 'hidden',
value => 'Post',
};
-
+
display start_table {cellspacing => 1};
-
+
display start_Tr;
display th {class => 'labelCentered'}, 'Active';
display th {class => 'labelCentered'}, 'Name';
@@ -2317,7 +2338,7 @@ sub editSchedule (;$) {
display th {class => 'labelCentered'}, 'Notification';
display th {class => 'labelCentered'}, 'Frequency';
display end_Tr;
-
+
display start_Tr;
display td {
class => 'dataCentered',
@@ -2339,21 +2360,21 @@ sub editSchedule (;$) {
};
display td {
class => 'dataCentered',
- }, makeTaskDropdown undef, $schedule{task};
+ }, makeTaskDropdown undef, $schedule{task};
display td {
class => 'dataCentered',
- }, makeNotificationDropdown undef, $schedule{notification};
-
+ }, makeNotificationDropdown undef, $schedule{notification};
+
my $nbr = 5;
my $multiplier = 'minutes';
-
+
if ($schedule{frequency} =~ /(\d+)\s(\S+)/ ) {
$nbr = $1;
$multiplier = $2;
-
+
$multiplier .= 's' if $nbr == 1;
} # if
-
+
display td {
class => 'data',
}, input {
@@ -2363,25 +2384,25 @@ sub editSchedule (;$) {
size => 1,
type => 'text',
value => $nbr,
- },
+ },
' ',
makeMultiplierDropdown undef, $multiplier;
-
+
display end_Tr;
display end_table;
-
+
display '';
display p submit ({value => $schedule ? 'Update' : 'Add'}), reset;
display '';
-
+
display end_form;
-
+
return;
} # editSchedule
-sub editSystem (;$) {
+sub editSystem(;$) {
my ($system) = @_;
-
+
display start_form (
-method => 'post',
-action => 'processsystem.cgi',
@@ -2389,13 +2410,13 @@ sub editSystem (;$) {
);
my %system;
-
+
if ($system) {
%system = $clearadm->GetSystem ($system);
-
+
return
unless %system;
-
+
display input {
name => 'name',
type => 'hidden',
@@ -2404,15 +2425,15 @@ sub editSystem (;$) {
} else {
$system = '';
} # if
-
+
display input {
name => 'action',
type => 'hidden',
value => 'Post',
};
-
+
display start_table {cellspacing => 1};
-
+
display start_Tr;
display th {class => 'label'}, checkbox ({
name => 'active',
@@ -2420,7 +2441,7 @@ sub editSystem (;$) {
checked => $system{active} eq 'false' ? 0 : 1,
label => '',
}) . ' Name: ';
-
+
if ($system) {
display td {class => 'data'}, $system{name};
} else {
@@ -2434,7 +2455,7 @@ sub editSystem (;$) {
type => 'text',
};
} # if
-
+
display th {class => 'label'}, 'Alias:';
display td {
class => 'data',
@@ -2456,24 +2477,24 @@ sub editSystem (;$) {
name => 'port',
size => 4,
type => 'text',
- value => $system
+ value => $system
? $system{port}
: $Clearadm::CLEAROPTS{CLEARADM_PORT},
};
-
+
my $systemTypeDropdown = popup_menu {
name => 'type',
class => 'dropdown',
values => ['Unix', 'Linux', 'Windows'],
default => $system ? $system{type} : 'Linux',
};
-
+
display th {class => 'label'}, 'Type:';
display td {
class => 'dataRight',
}, $systemTypeDropdown;
display end_Tr;
-
+
display start_Tr;
display th {class => 'label'}, 'Admin:';
display td {
@@ -2507,11 +2528,11 @@ sub editSystem (;$) {
name => 'loadavgThreshold',
size => 3,
type => 'text',
- value => $system
+ value => $system
? $system{loadavgThreshold}
: $Clearadm::CLEAROPTS{CLEARADM_LOADAVG_THRESHOLD},
};
-
+
my $historyDropdown = popup_menu {
name => 'loadavgHist',
class => 'dropdown',
@@ -2531,15 +2552,15 @@ sub editSystem (;$) {
],
default => $system ? $system{loadavgHist} : '6 months',
};
-
+
display th {class => 'label'}, 'History:';
display td {
class => 'dataRight',
- }, $historyDropdown;
-
+ }, $historyDropdown;
+
my $description = $system ? $system{description} : '';
$description =~ s/\r\n/
/g;
-
+
display start_Tr;
display th {class => 'label'}, 'Description:';
display td {
@@ -2554,19 +2575,19 @@ sub editSystem (;$) {
};
display end_Tr;
display end_table;
-
+
display '';
display p submit ({value => $system ? 'Update' : 'Add'}), reset;
display '';
-
+
display end_form;
-
+
return;
} # editSystem
-sub editTask (;$) {
+sub editTask(;$) {
my ($task) = @_;
-
+
display start_form (
-method => 'post',
-action => 'processtask.cgi',
@@ -2577,10 +2598,10 @@ sub editTask (;$) {
if ($task) {
%task = $clearadm->GetTask ($task);
-
+
return
unless %task;
-
+
display input {
name => 'oldname',
type => 'hidden',
@@ -2589,15 +2610,15 @@ sub editTask (;$) {
} else {
$task = '';
} # if
-
+
display input {
name => 'action',
type => 'hidden',
value => 'Post',
};
-
+
display start_table {cellspacing => 1};
-
+
display start_Tr;
display th {class => 'labelCentered'}, 'Name';
display th {class => 'labelCentered'}, 'System';
@@ -2605,7 +2626,7 @@ sub editTask (;$) {
display th {class => 'labelCentered'}, 'Command';
display th {class => 'labelCentered'}, 'Restartable';
display end_Tr;
-
+
display start_Tr;
display td {
class => 'data',
@@ -2619,14 +2640,13 @@ sub editTask (;$) {
};
my $systemDropdown = makeSystemDropdown (
undef,
- $task{system} ? $task{system} : 'All Systems',
+ $task{system} ? $task{system} : 'localhost',
undef, (
- 'All systems' => undef,
- 'Localhost' => 'Localhost',
+ 'localhost' => 'localhost',
),
);
-
- display td {class => 'data'}, $systemDropdown;
+
+ display td {class => 'data'}, $systemDropdown;
display td {
class => 'data',
@@ -2638,7 +2658,7 @@ sub editTask (;$) {
type => 'text',
value => $task ? $task{description} : '',
};
-
+
display td {
class => 'data',
}, input {
@@ -2653,50 +2673,50 @@ sub editTask (;$) {
display td {
class => 'dataCentered',
}, makeRestartableDropdown undef, $task{restartable};
-
+
display end_Tr;
display end_table;
-
+
display '';
display p submit ({value => $task ? 'Update' : 'Add'}), reset;
display '';
-
+
display end_form;
-
+
return;
} # editTask
-sub footing () {
+sub footing() {
my $clearscm = a {-href => 'http://clearscm.com'}, 'ClearSCM, Inc.';
-
+
# Figure out which script by using CLEARADM_BASE.
- my $script = basename (url {-absolute => 1});
+ my $script = basename (url {-absolute => 1});
$script = 'index.cgi'
if $script eq 'clearadm';
my $scriptFullPath = "$Clearadm::CLEAROPTS{CLEARADM_BASE}/$script";
-
- my ($year, $mon, $mday, $hour, $min, $sec) =
+
+ my ($year, $mon, $mday, $hour, $min, $sec) =
ymdhms ((stat ($scriptFullPath))[9]);
my $dateModified = "$mon/$mday/$year @ $hour:$min";
-
+
$script = a {
-href => "http://clearscm.com/php/scm_man.php?file=clearadm/$script"
}, $script;
-
+
display end_div;
-
+
display start_div {-class => 'copyright'};
display "$script: Last modified: $dateModified";
display br "Copyright © $year, $clearscm - All rights reserved";
display end_div;
-
+
print end_html;
-
+
return;
} # footing
-
+
1;
=pod
@@ -2725,13 +2745,13 @@ L
=head2 ClearSCM Perl Modules
-=begin man
+=begin man
Clearadm
DateUtils
Display
Utils
-
+
=end man
=begin html