Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
e324aa26
Commit
e324aa26
authored
Feb 09, 2017
by
Gary Wong
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate time series data of future node usage.
parent
fe20880b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
2 deletions
+76
-2
db/Reservation.pm.in
db/Reservation.pm.in
+54
-0
utils/predict.in
utils/predict.in
+22
-2
No files found.
db/Reservation.pm.in
View file @
e324aa26
...
...
@@ -742,6 +742,60 @@ sub FreeCount($$;$) {
return $answer;
}
#
# Generate a time series of counts of nodes of a given type.
sub Forecast($$;$) {
my ($class, $type, $projlist) = @_;
my $reservations = LookupAll( $class, $type );
my @forecast = ();
my @answer = ();
my $t = time();
IsFeasible( $class, $reservations, undef, undef, undef, undef, \@forecast );
foreach my $f ( @forecast ) {
my $unavailable = 0;
my $held = 0;
my $free = $f->{'
free
'};
foreach my $pid ( keys( %{$f->{'
used
'}} ) ) {
$unavailable += $f->{'
used
'}->{$pid};
}
foreach my $pid ( keys( %{$f->{'
reserved
'}} ) ) {
my $r = $f->{'
reserved
'}->{$pid};
my $u = $f->{'
used
'}->{$pid};
if( $r > $u ) {
if( grep( $_ eq $pid, @$projlist ) ) {
$held += $r - $u;
} else {
$unavailable += $r - $u;
}
}
}
my %r = (
t => $f->{'
t
'},
unavailable => $unavailable,
held => $held,
free => $free
);
if( $r{'
t
'} < $t ) {
# event in the past; overwrite initial result in list but do
# not append
$r{'
t
'} = $t;
$answer[ 0 ] = \%r;
} else {
push( @answer, \%r );
}
}
return @answer;
}
sub ExptTypes($) {
my ($exptidx) = @_;
...
...
utils/predict.in
View file @
e324aa26
...
...
@@ -46,8 +46,11 @@ sub usage()
{
print
STDERR
"
Usage: predict [-p] [-u] [-t time] type
\n
";
print
STDERR
"
predict -c type [pid...]
\n
";
print
STDERR
"
predict -l type [pid...]
\n
";
print
STDERR
"
-h This message
\n
";
print
STDERR
"
-c Give an oversimplified free node count
\n
";
print
STDERR
"
-l Give a list of node allocation status counts
"
.
"
over time
\n
";
print
STDERR
"
-p Identify by pid only, not pid/eid
\n
";
print
STDERR
"
-t Give time/date for prediction (defaults to now)
\n
";
print
STDERR
"
-u Interpret/display all times in UTC
\n
";
...
...
@@ -55,11 +58,12 @@ sub usage()
exit
(
-
1
);
}
my
$optlist
=
"
cdhpt:
";
my
$optlist
=
"
cdh
l
pt:
";
my
$debug
=
0
;
my
$time
=
time
;
# default to now
my
$pidonly
=
0
;
my
$countonly
=
0
;
my
$timeseries
=
0
;
my
$type
;
sub
fatal
($)
...
...
@@ -116,7 +120,10 @@ if (defined($options{"t"})) {
if
(
defined
(
$options
{"
c
"}))
{
$countonly
=
1
;
}
usage
()
if
(
$countonly
?
@ARGV
<
1
:
@ARGV
!=
1
);
if
(
defined
(
$options
{"
l
"}))
{
$timeseries
=
1
;
}
usage
()
if
(
(
$countonly
||
$timeseries
)
?
@ARGV
<
1
:
@ARGV
!=
1
);
$type
=
shift
(
@ARGV
);
unless
(
$type
=~
/^[-\w]+$/
)
{
fatal
(
"
Invalid node type.
"
);
...
...
@@ -128,6 +135,19 @@ if( $countonly ) {
exit
(
0
);
}
if
(
$timeseries
)
{
print
"
Time Unavailable Held Free
\n
";
print
"
---------- ----- ---- ----
\n
";
foreach
my
$rec
(
Reservation
->
Forecast
(
$type
,
\
@ARGV
)
)
{
printf
(
"
%s %5d %5d %5d
\n
",
strftime
(
"
%Y-%m-%d %H:%M
",
localtime
(
$rec
->
{'
t
'}
)
),
$rec
->
{'
unavailable
'},
$rec
->
{'
held
'},
$rec
->
{'
free
'}
);
}
exit
(
0
);
}
my
$reservations
=
Reservation
->
LookupAll
(
$type
);
my
@timeline
=
();
my
$free
=
0
;
...
...
Gary Wong
@gtw
mentioned in issue
#132 (closed)
·
Feb 09, 2017
mentioned in issue
#132 (closed)
mentioned in issue #132
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment