Commit b3293f40 authored by Leigh Stoller's avatar Leigh Stoller

Add portal urls (and local experiment urls) to the email so we can

easily get to the experiment (or portal status page).
parent c87f4fd3
#!/usr/bin/perl -w
#
# Copyright (c) 2008-2017 University of Utah and the Flux Group.
# Copyright (c) 2008-2018 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
......@@ -127,7 +127,7 @@ open(HOSTS, ">$HOSTFILE")
while (my ($node_id,$IP,$pid,$eid) = $query_result->fetchrow_array()) {
print HOSTS "$IP\n";
$nodes{$IP} = {"node_id" => $node_id};
$nodes{$IP} = {"node_id" => $node_id, "portal_url" => undef};
my $experiment = Experiment->Lookup($pid,$eid);
my $project = Project->Lookup($pid);
......@@ -147,6 +147,10 @@ while (my ($node_id,$IP,$pid,$eid) = $query_result->fetchrow_array()) {
if (defined($geniuser)) {
$email = $geniuser->email();
}
my $portal_url = $slice->GetPortalURL();
if ($portal_url) {
$nodes{$IP}->{"portal_url"} = $portal_url;
}
}
}
else {
......@@ -169,7 +173,7 @@ $query_result =
while (my ($pool_id,$IP,$pid,$eid) = $query_result->fetchrow_array()) {
print HOSTS "$IP\n";
$pools{$IP} = {"pool_id" => $pool_id};
$pools{$IP} = {"pool_id" => $pool_id, "portal_url" => undef};
my $experiment = Experiment->Lookup($pid,$eid);
my $project = Project->Lookup($pid);
......@@ -189,6 +193,10 @@ while (my ($pool_id,$IP,$pid,$eid) = $query_result->fetchrow_array()) {
if (defined($geniuser)) {
$email = $geniuser->email();
}
my $portal_url = $slice->GetPortalURL();
if ($portal_url) {
$nodes{$IP}->{"portal_url"} = $portal_url;
}
}
}
else {
......@@ -211,7 +219,7 @@ RunMedusa("$VNCOPTS -n 5901 $MEDUSAOPTS", 500,
RunMedusa("$VNCOPTS -n 5902 $MEDUSAOPTS", 500,
"Insecure VNC password on port 5902");
unlink($HOSTFILE);
unlink($HOSTFILE) if (!$debug);
exit(0);
#
......@@ -272,9 +280,11 @@ sub RunMedusa($$$)
my $node_id = $nodeinfo->{"node_id"};
my $url = $nodeinfo->{"url"};
my $eid = $nodeinfo->{"eid"};
my $portal_url = $nodeinfo->{"portal_url"};
$warnings .= "Node: $node_id:$1 $2\n";
$warnings .= " $url\n" if (defined($url));
$warnings .= " $portal_url\n" if (defined($portal_url));
if (exists($nodeinfo->{"email"})) {
my $email = $nodeinfo->{"email"};
if (!exists($emails{$email})) {
......@@ -290,9 +300,11 @@ sub RunMedusa($$$)
my $pool_id = $poolinfo->{"pool_id"};
my $url = $poolinfo->{"url"};
my $eid = $poolinfo->{"eid"};
my $portal_url = $poolinfo->{"portal_url"};
$warnings .= "Pool: $pool_id:$1 $2\n";
$warnings .= " $url\n" if (defined($url));
$warnings .= " $portal_url\n" if (defined($portal_url));
if (exists($poolinfo->{"email"})) {
my $email = $poolinfo->{"email"};
if (!exists($emails{$email})) {
......
......@@ -87,8 +87,14 @@ my $runonce = 0;
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TBLOG = "@TBLOGFACIL@";
my $TBBASE = "@TBBASE@";
my $PGENISUPPORT= @PROTOGENI_SUPPORT@;
my $LOGFILE = "$TB/log/cnetwatch.log";
# For Geni slices: do this early so that we talk to the right DB.
use vars qw($GENI_DBNAME);
$GENI_DBNAME = "geni-cm";
#
# E-mail config
#
......@@ -99,12 +105,6 @@ my $MAIL_IV = (10 * 60);
# Do not send more than this many total messages (0 == no limit)
my $MAIL_MAX = 1000;
# XXX testing
if (0) {
$MAIL_IV = 60;
$MAIL_MAX = 10;
}
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
......@@ -146,6 +146,11 @@ $ENV{'WITH_TB_ADMIN_PRIVS'} = 1;
use lib "@prefix@/lib";
use libdb;
use libtestbed;
use Experiment;
if ($PGENISUPPORT) {
require GeniSlice;
require GeniHRN;
}
#
# Read sitevars to establish defaults:
......@@ -231,6 +236,15 @@ if (TBGetSiteVar($svar, \$tmp)) {
}
# XXX testing
if (0) {
$interval = 30;
$alertinterval = (2 * $interval);
$MAIL_IV = 30;
$MAIL_MAX = 10;
$MAX_PPS = 10;
}
#
# Process command line options. Some will override sitevars.
#
......@@ -513,6 +527,11 @@ sub reportevents($)
", bits/sec=$bps (send=$sbps, recv=$rbps)".
" over $sec seconds");
if ($sendmail) {
my $exp = $pcs{$node}{'exp'};
my $expname = $pcs{$node}{'expname'};
my $url = $pcs{$node}{'url'};
my $portalurl = $pcs{$node}{'portalurl'};
if (@mailbody == 0) {
my $pth = $bth = "no limit on";
if ($MAX_PPS) {
......@@ -539,8 +558,13 @@ sub reportevents($)
localtime($ref->{'start'}));
push(@mailbody,
sprintf("%20s %30s %8d %8d %s for %d sec",
$node, $pcs{$node}{'exp'}, $pps,
$node, $expname, $pps,
int($bps/1000000), $stamp, $secs));
push(@mailbody, sprintf("%30s %s", "", $url))
if (defined($url));
push(@mailbody, sprintf("%30s %s", "", $portalurl))
if (defined($portalurl));
push(@maildetails,
sprintf("%20s %8d/%-8d %8d/%-8d %d sec",
$node, $spps, $rpps,
......@@ -631,11 +655,11 @@ sub report($)
"Node", "Experiment", "Tot Pkts", "Unicast", "Multicast", "Tot Bytes";
foreach my $node (@list) {
my $name = $pcs{$node}{'name'};
my $exp = $pcs{$node}{'exp'};
my $expname = $pcs{$node}{'expname'};
my $tot = $ref->{$node}{'totals'};
printf RL "%20s %30s %12d %12d %12d %14d\n",
$name, $exp, $tot->[3], $tot->[1], $tot->[2], $tot->[0];
$name, $expname, $tot->[3], $tot->[1], $tot->[2], $tot->[0];
}
}
......@@ -703,11 +727,24 @@ sub getnodeinfo($)
next;
}
my $exp;
my ($exp,$expname,$url,$portalurl);
if (defined($row{'pid'})) {
$exp = $row{'pid'} . "/" . $row{'eid'};
} else {
$exp = "<NONE>";
$exp = Experiment->Lookup($row{'pid'}, $row{'eid'});
}
if (defined($exp)) {
$expname = $exp->pideid();
if ($exp->geniflags) {
my $slice = GeniSlice->LookupByExperiment($exp);
if (defined($slice)) {
$portalurl = $slice->GetPortalURL();
}
}
my $pid = $exp->pid();
my $eid = $exp->eid();
$url = "$TBBASE/showexp.php3?pid=$pid&eid=$eid";
}
else {
$expname = "<NONE>";
}
# portstats now accepts node:iface, and spits out in that format (-i).
#
......@@ -715,6 +752,9 @@ sub getnodeinfo($)
push(@{$switches{$switch}}, $cnet);
$newpcs{$cnet}{'exp'} = $exp;
$newpcs{$cnet}{'expname'} = $expname;
$newpcs{$cnet}{'url'} = $url;
$newpcs{$cnet}{'portalurl'} = $portalurl;
$newpcs{$cnet}{'state'} = $row{'eventstate'};
$newpcs{$cnet}{'name'} = $pc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment