Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
977031a8
Commit
977031a8
authored
Oct 20, 2005
by
Leigh B. Stoller
Browse files
Send email on error ...
parent
32f29761
Changes
1
Hide whitespace changes
Inline
Side-by-side
event/linktest/linktest_control.in
View file @
977031a8
...
...
@@ -23,17 +23,21 @@ sub usage()
"
-k - Kill a currently running linktest.
\n
"
.
"
-t - Specify timeout in seconds.
\n
"
.
"
-o - Specify output file for linktest results.
\n
"
.
"
-m - Send email to swapper if linktest fails.
\n
"
.
"
-d - Turn on debugging output.
\n
");
exit
(
-
1
);
}
my
$optlist
=
"
dkl:o:t:
";
my
$optlist
=
"
dkl:o:t:
m
";
my
$debug
=
0
;
my
$cancel
=
0
;
my
$sendmail
=
0
;
my
$timeout
;
my
$level
;
my
$output
;
my
$expstate
;
my
$dbuid
;
my
$user_name
;
my
$user_email
;
my
$child_pid
;
# Child run_linktest process.
#
...
...
@@ -42,6 +46,7 @@ my $child_pid; # Child run_linktest process.
my
$TB
=
"
@prefix
@
";
my
$TBOPS
=
"
@TBOPSEMAIL
@
";
my
$CONTROL
=
"
@USERNODE
@
";
my
$TBBASE
=
"
@TBBASE
@
";
my
$SSH
=
"
$TB
/bin/sshtb
";
#
...
...
@@ -76,6 +81,9 @@ if (! getopts($optlist, \%options)) {
if
(
defined
(
$options
{"
d
"}))
{
$debug
=
1
;
}
if
(
defined
(
$options
{"
m
"}))
{
$sendmail
=
1
;
}
if
(
defined
(
$options
{"
k
"}))
{
$cancel
=
1
;
}
...
...
@@ -150,6 +158,14 @@ if (! UNIX2DBUID($UID, \$dbuid)) {
"
You do not exist in the Emulab Database!
\n
");
}
#
# Get email info for user.
#
if
(
!
UserDBInfo
(
$dbuid
,
\
$user_name
,
\
$user_email
))
{
die
("
*** $0:
\n
"
.
"
Cannot determine your name and email address.
\n
");
}
#
# Check permission. Only people with permission to destroy the experiment
# can do this.
...
...
@@ -241,6 +257,20 @@ sub handler($)
"
Linktest has been canceled on experiment
$pid
/
$eid
!
\n
")
}
sub
notify
()
{
my
$lev
=
(
defined
(
$level
)
?
$level
:
$linktest_level
);
SENDMAIL
("
$user_name
<
$user_email
>
",
"
Linktest Failure:
$pid
/
$eid
",
"
Failure in linktest (level
$lev
);
"
.
"
returned non-zero status.
\n
"
.
"
Activity log file at:
\n\n
"
.
"
$TBBASE
/spewlogfile.php3?pid=
${pid}
&eid=
${eid}
\n
",
"
$user_name
<
$user_email
>
",
"
Cc:
$TBOPS
");
}
#
# Fork a child to run the actual linktest script. The parent just waits
# for child to exit, or to be signaled to terminate the child.
...
...
@@ -269,6 +299,8 @@ if ($child_pid) {
waitpid
(
$child_pid
,
0
);
my
$exitval
=
$?
>>
8
;
cleanup
();
notify
()
if
(
$exitval
&&
$sendmail
);
exit
(
$exitval
);
}
...
...
Write
Preview
Supports
Markdown
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