Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
8d7c30fd
Commit
8d7c30fd
authored
Apr 25, 2016
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add methods to get idledata and rusage data for a node. This is mostly
derived from the PHP code.
parent
064a5f78
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
2 deletions
+60
-2
db/Node.pm.in
db/Node.pm.in
+60
-2
No files found.
db/Node.pm.in
View file @
8d7c30fd
...
...
@@ -2152,6 +2152,14 @@ sub SetEventState($$)
"state_timestamp" => time()});
}
sub ResetStartStatus($)
{
my ($self) = @_;
$self->{"DBROW"}->{'
startstatus
'} = '
none
';
return $self->Update({"startstatus" => '
none
'});
}
#
# Create new vnodes. The argument is a reference; to a a hash of options to
# be used when creating the new node(s). A list of the node names is
...
...
@@ -3220,14 +3228,15 @@ sub GetStatus($)
my $node_id = $self->node_id();
my $query_result =
DBQueryWarn("select status,status_timestamp from node_status ".
DBQueryWarn("select status,unix_timestamp(status_timestamp) ".
" from node_status ".
"where node_id='
$
node_id
'");
return undef
if (! (defined($query_result) && $query_result->numrows));
my ($status,$stamp) = $query_result->fetchrow_array();
$self->{"DBROW"}->{'
node_status
'} = $status;
return $status;
return
(
$status
,$stamp)
;
}
#
...
...
@@ -4219,5 +4228,54 @@ sub UEConfig($) {
return
0
;
}
#
#
Return
the
idle
data
(
idletime
,
staleness
)
for
a
node
.
#
sub
IdleData
($)
{
my
($
self
)
=
@
_
;
my
$
node_id
=
$
self
->
node_id
();
my
$
clause
=
"greatest(last_tty_act,last_net_act,last_cpu_act,last_ext_act)"
;
my
$
query_result
=
DBQueryWarn
(
"select (unix_timestamp(now()) - "
.
" unix_timestamp($clause)), "
.
" (unix_timestamp(now()) - "
.
" unix_timestamp(last_report)) "
.
" from node_activity "
.
"where node_id='$node_id' and "
.
" UNIX_TIMESTAMP(last_report)!=0"
);
return
()
if
(
! ($query_result && $query_result->numrows));
my
($
idle_time
,$
staleness
)
=
$
query_result
->
fetchrow_array
();
#
if
it
is
less
than
5
minutes
,
it
is
not
idle
at
all
...
if
($
idle_time
<
300
)
{
$
idle_time
=
0
;
}
my
$
stale
=
($
staleness
>
600
?
1
:
0
);
return
($
idle_time
,
$
staleness
,
$
stale
);
}
sub
RusageData
($)
{
my
($
self
)
=
@
_
;
my
$
node_id
=
$
self
->
node_id
();
my
$
query_result
=
DBQueryWarn
(
"select *,UNIX_TIMESTAMP(status_timestamp) as tstamp "
.
" from node_rusage "
.
"where node_id='$node_id'"
);
return
undef
if
(
! ($query_result && $query_result->numrows));
my
$
row
=
$
query_result
->
fetchrow_hashref
();
my
$
blob
=
{
"timestamp"
=>
$
row
->{
"tstamp"
},
"load"
=>
{
"60"
=>
$
row
->{
"load_1min"
},
"300"
=>
$
row
->{
"load_5min"
},
"900"
=>
$
row
->{
"load_15min"
}}};
return
$
blob
;
}
#
_Always_
make
sure
that
this
1
is
at
the
end
of
the
file
...
1
;
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