Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
emulab-devel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brecht Vermeulen
emulab-devel
Commits
ad9a6494
Commit
ad9a6494
authored
13 years ago
by
Jonathon Duerig
Browse files
Options
Downloads
Patches
Plain Diff
Added timetest.pl as an example for using hooks.
parent
b0178846
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tmcd/common/hook-examples/timetest.ns
+11
-0
11 additions, 0 deletions
tmcd/common/hook-examples/timetest.ns
tmcd/common/hook-examples/timetest.pl
+44
-0
44 additions, 0 deletions
tmcd/common/hook-examples/timetest.pl
with
55 additions
and
0 deletions
tmcd/common/hook-examples/timetest.ns
0 → 100644
+
11
−
0
View file @
ad9a6494
set ns [new Simulator]
source tb_compat.tcl
set NodeA [$ns node]
tb-set-node-os $NodeA FEDORA10-STD
tb-add-node-service-hook "rc.isup" -script "/proj/tbres/duerig/timetest.pl" -op boot -whence every -env boot -point post -fatal 0
# Go!
$ns run
This diff is collapsed.
Click to expand it.
tmcd/common/hook-examples/timetest.pl
0 → 100755
+
44
−
0
View file @
ad9a6494
#!/usr/bin/perl
use
strict
;
use
warnings
;
my
$debug
=
0
;
if
(
@ARGV
>=
1
&&
$ARGV
[
0
]
eq
'
-d
')
{
$debug
=
1
;
shift
@ARGV
;
}
#die "Usage: $0 -d TOLERANCE boot\n" unless @ARGV == 1;
my
$TOLERANCE
=
0.5
;
if
(
scalar
(
@ARGV
)
>
1
)
{
$TOLERANCE
=
$ARGV
[
0
];
}
my
$NTP_SERVER
=
"
ops.emulab.net
";
my
$offset
;
my
$output
=
'';
open
NTP
,
"
/usr/sbin/ntpdate -q ops.emulab.net |
";
while
(
<
NTP
>
)
{
$output
.=
$_
;
next
unless
/.+?: [a-z]+ time server .+? offset ([-+.\d]+) sec/
;
$offset
=
$
1
;
}
unless
(
defined
$offset
)
{
print
STDERR
"
*** ERROR: Unable to get offset from ntpdata
\n
";
print
STDERR
"
NOTE: ntpdate output
\n
";
print
STDERR
$output
;
exit
2
;
}
if
(
abs
(
$offset
)
>
$TOLERANCE
)
{
print
STDERR
"
*** ERROR: offset of
$offset
greater than
$TOLERANCE
\n
";
print
"
FAILED: offset of
$offset
greater than
$TOLERANCE
\n
";
exit
1
;
}
else
{
print
"
PASSED: offset of
$offset
within tolerance of
$TOLERANCE
\n
";
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment