Skip to content

Commit 7eb5ada

Browse files
author
Yutaro Iiyama
committed
Merge remote branch 'origin/production' into production
2 parents f5c5453 + 1753447 commit 7eb5ada

6 files changed

Lines changed: 232 additions & 71 deletions

File tree

web/html/dynamo/dynamo/css/csv.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ html *
22
{
33
font-family: Sans-Serif !important;
44
}
5-
5+
#main{
6+
postion: relative;
7+
}
68
#tableBox {
79
height: 1000px;
810

911
}
10-
12+
#download {
13+
position: absolute;
14+
right:10px;
15+
top: 30px;
16+
}
1117
#graphModal{
1218
width:100%
1319
}

web/html/dynamo/dynamo/css/dealermon.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ body {
7777
height: 840px;
7878
}
7979

80+
#instructionbox {
81+
position: absolute;
82+
left: 58%;
83+
;
84+
height:10px;
85+
86+
87+
88+
}
89+
8090
#GaugeBox {
8191
width: 100%;
8292
height: 220px;

web/html/dynamo/dynamo/dealermon/main.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,46 @@
3737
$type_name = 'Compare';
3838
$elem = array('id' => $type_id, 'name' => $type_name);
3939
$data[] = $elem;
40+
$type_id = 4;
41+
$type_name = 'Tape';
42+
$elem = array('id' => $type_id, 'name' => $type_name);
43+
$data[] = $elem;
4044

4145
echo json_encode($data);
4246
}
4347

4448

4549
// Dynamo is default
4650
$service_id = 1;
51+
$rrdfile = array('total.rrd');
4752
$rrdpaths = array('./monitoring/');
4853
$overviewpaths = array('monitoring/overview.txt');
4954
$summarypaths = array('./monitoring');
5055

5156
if ((isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] == 2)){
5257
$service_id = 2;
58+
$rrdfile = array('total_disk.rrd');
5359
$rrdpaths = array('./monitoring_phedex/');
5460
$overviewpaths = array("monitoring_phedex/overview.txt");
5561
$summarypaths[0] = './monitoring_phedex';
5662
}
5763

5864
if ((isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] == 3)){
5965
$service_id = 3;
66+
$rrdfile = array('total.rrd','total_disk.rrd');
6067
$rrdpaths = array('./monitoring_phedex/');
61-
$overviewpaths = array('monitoring_phedex/overview.txt','monitoring/overview.txt');
68+
$overviewpaths = array('monitoring/overview.txt','monitoring_phedex/overview.txt');
6269
$summarypaths[] = './monitoring_phedex';
6370
}
6471

72+
if ((isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] == 4)){
73+
$service_id = 4;
74+
$rrdfile = array('total_tape.rrd');
75+
$rrdpaths = array('./monitoring_phedex/');
76+
$overviewpaths = array("monitoring_phedex/overview.txt");
77+
$summarypaths[0] = './monitoring_phedex';
78+
}
79+
6580

6681
$rrdcolumns = array('copied', 'total');
6782

@@ -125,9 +140,9 @@ function single_rrd_to_array($rrd,$rrdpath){
125140
$Summary = array();
126141

127142
for($i = 0; $i < count($summarypaths); $i++){
128-
$Summary[] = single_rrd_to_array('total.rrd',$summarypaths[$i]);
129-
}
130-
143+
$Summary[] = single_rrd_to_array($rrdfile[$i],$summarypaths[$i]);
144+
}
145+
131146
echo json_encode($Summary);
132147

133148
}

web/html/dynamo/dynamo/dealermon/sites.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ function escapeJavaScriptText($string)
3131
$serviceId = 2;
3232
}
3333

34-
if ((isset($_REQUEST['serviceId']) && $_REQUEST['serviceId'] == 3)){
34+
if ((isset($_REQUEST['serviceId']) && ($_REQUEST['serviceId'] == 3 || $_REQUEST['serviceId'] == 4))){
3535
$csvpath[] = "/var/www/html/dynamo/dynamo/dealermon/monitoring/" . $site . "/filelist.txt";
3636
$csvpath[] = "/var/www/html/dynamo/dynamo/dealermon/monitoring_phedex/" . $site . "/filelist.txt";
3737
$rrdpaths[] = "/var/www/html/dynamo/dynamo/dealermon/monitoring/";
3838
$rrdpaths[] = "/var/www/html/dynamo/dynamo/dealermon/monitoring_phedex/";
3939
$serviceId = 3;
40+
if ($_REQUEST['serviceId'] == 4){
41+
$serviceId = 4;
42+
}
4043
}
4144

4245

web/html/dynamo/dynamo/js/csv.js

Lines changed: 87 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function initPage(serviceId, site){
2121

2222
var ajaxInput_sitecsvs = {
2323
'url': 'http://dynamo.mit.edu/dynamo/dealermon/sites.php',
24-
'data': {'getSiteCSVs': 1, 'serviceId': serviceId, 'site': site},
24+
'data': {'getSiteCSVs': 1, 'serviceId': serviceId, 'site': site, 'norm': 1},
2525
'success': function (data) {
26-
26+
writeDownload(data, site, serviceId);
2727
makeTable(data, site, serviceId);
2828

2929
},
@@ -35,6 +35,46 @@ function initPage(serviceId, site){
3535

3636
}
3737

38+
function writeDownload(data, site, serviceId){
39+
var list_stuck = [];
40+
for(i = 0; i!= data.length; i++){
41+
var replica = data[i];
42+
if (replica[4] == 0){
43+
continue;
44+
}
45+
list_stuck.push([replica[1],"/" + replica[0].slice(1).replace('+','/').replace('+','/')]);
46+
47+
}
48+
49+
var csvContent = "";
50+
list_stuck.forEach(function(infoArray, index){
51+
52+
dataString = infoArray.join(",");
53+
csvContent += index < list_stuck.length ? dataString+ "\n" : dataString;
54+
55+
});
56+
var blob = new Blob(["\ufeff", csvContent]);
57+
var downloadLink = document.createElement("a");
58+
var url = URL.createObjectURL(blob);
59+
downloadLink.href = url;
60+
var d = new Date();
61+
var month = d.getMonth() + 1;
62+
downloadLink.download = site + "_stucktransfers(" + month +"-"+d.getDate()+"-"+d.getFullYear()+ ").csv";
63+
64+
var encodedURI = encodeURI(csvContent);
65+
var download_button = document.getElementById("download");
66+
download_button.onclick = function() {
67+
downloadLink.click();
68+
setTimeout(function(){
69+
URL.revokeObjectURL(url);
70+
}, 100);
71+
};
72+
73+
}
74+
75+
76+
77+
3878

3979
//Creates HTML table with the information from Site CSV: links to PhEDEx API and progress graph
4080
function makeTable(data, site, serviceId){
@@ -45,15 +85,16 @@ function makeTable(data, site, serviceId){
4585

4686
for(var i in data){
4787

48-
var replicaname = data[i][0];
88+
var replicaname = data[i][0].replace("+","/");
4989
var id = data[i][1];
5090
var total = Math.round(10000*(data[i][2]/Math.pow(10,12)))/10000;
5191
var copied = Math.round(10000*(data[i][3]/Math.pow(10,12)))/10000;
5292
var isstuck = false;
5393
var DorP = replicaname.split("_")[0].charAt(0);
5494
var DorPcolor = "#2C8CFF";
5595
var color = "white";
56-
replicaname = replicaname.slice(1);
96+
replicaname = replicaname.slice(1);
97+
replicaname = '/' + replicaname.replace("+","/");
5798
if (DorP == "P"){
5899
DorPcolor = "#07EF00";
59100
DorP = "O";
@@ -65,7 +106,7 @@ function makeTable(data, site, serviceId){
65106
}
66107
nreplicas +=1;
67108

68-
replicaTable += "<tr><td>" + id.link('https://cmsweb.cern.ch/phedex/datasvc/perl/prod/blockarrive?to_node=' + site +'&block=/' + replicaname.replace("+","/").replace("+","/") +"%23*") + "</td><td bgcolor=" + DorPcolor+ ">" + DorP + "</td><td bgcolor=" + color + " id='textButton"+replicaname+"' style='cursor: pointer'>" + replicaname + "</td><td>" + copied + "</td><td>" + total + "</td></tr>";
109+
replicaTable += "<tr><td>" + id.link('https://cmsweb.cern.ch/phedex/datasvc/perl/prod/blockarrive?to_node=' + site +'&block=' + replicaname.replace("+","/") +"%23*") + "</td><td bgcolor=" + DorPcolor+ ">" + DorP + "</td><td bgcolor=" + color + " id='textButton"+replicaname+"' style='cursor: pointer'>" + replicaname + "</td><td>" + copied + "</td><td>" + total + "</td></tr>";
69110
replicanames.push(replicaname);
70111

71112
}
@@ -76,56 +117,61 @@ function makeTable(data, site, serviceId){
76117
}
77118

78119
function makeGraphTrace(data, site, replicaname){
120+
79121

80122

81123
var traces_sites = [];
82-
124+
83125

84126
for(var k in data){
85-
86-
for(var i in data[k]){
87-
var obj = data[k][i];
88-
var sitename = obj.site;
89-
/*
90-
if (site != sitename)
91-
continue;
92-
*/
93-
for(var j in obj["data"]){
94-
var replica = obj["data"][j];
95-
var replicatograph = replica.replica.substring(replica.replica.indexOf("_") + 1);
96-
/*
97-
if (replicatograph != replicaname){
98-
continue;
99-
}
100-
*/
101-
102-
traces_sites.push(makeTrace(replica.replica,time_converted,replica.ratio,'dot',1.6,false, "#ff6666"));
103-
}
127+
try{
128+
var obj = data[k];
129+
var sitename = obj.site;
130+
var replica = obj.data[0];
131+
var time_converted = replica["time"].map(timeConverter);
132+
traces_sites.push(makeTrace(replica.replica,time_converted,replica.ratio,'dot',1.6,false, "#ff6666"));
133+
}
134+
catch (e){
104135
}
105-
}
136+
137+
}
138+
139+
106140

107141
return traces_sites;
108142
}
109143

110144
function makeGraph(replicaname, serviceId, site){
111-
112-
window.alert(site);
113-
114145
var traces_sites = [];
115-
var echoo = "";
146+
116147
var ajaxInput_grapher = {
117-
'url': 'http://dynamo.mit.edu/dynamo/dealermon/sites.php',
118-
'data': {'getSiteRRDs': 1, 'serviceId': serviceId, 'site': site, 'replicaname': replicaname},
148+
'url': 'sites.php',
149+
'data': {'getSiteRRDs': 1, 'serviceId': serviceId, 'site': site, 'replicaname': replicaname, 'norm': 1},
119150
'success': function (data) {
120-
echoo = "Hi";
121151
traces_sites = makeGraphTrace(data,site,replicaname);
122152
},
123153
'dataType': 'json',
154+
'error': function (jqXHR, exception) {
155+
if (jqXHR.status === 0) {
156+
alert('Not connect.\n Verify Network.');
157+
} else if (jqXHR.status == 404) {
158+
alert('Requested page not found. [404]');
159+
} else if (jqXHR.status == 500) {
160+
alert('Internal Server Error [500].');
161+
} else if (exception === 'parsererror') {
162+
alert('Requested JSON parse failed.');
163+
} else if (exception === 'timeout') {
164+
alert('Time out error.');
165+
} else if (exception === 'abort') {
166+
alert('Ajax request aborted.');
167+
} else {
168+
alert('Uncaught Error.\n' + jqXHR.responseText);
169+
}
170+
},
124171
'async': false
125172
};
126173

127174
$.ajax(ajaxInput_grapher);
128-
window.alert(echoo);
129175

130176
var layout_sites = {
131177
title: replicaname,
@@ -166,7 +212,7 @@ function makeGraph(replicaname, serviceId, site){
166212
}
167213
};
168214

169-
215+
// window.alert("DID WE MAKE IT?");
170216
Plotly.newPlot("graphModal1", traces_sites, layout_sites);
171217

172218
}
@@ -192,7 +238,7 @@ window.onload = function(){
192238
var modal = document.getElementById('graphModal');
193239
var span = document.getElementsByClassName("close")[0];
194240

195-
var site = url.substring(url.indexOf("=")+1,url.lastIndexOf("&"));
241+
var site = url.substring(url.indexOf("=")+1,url.indexOf("&"));
196242
var serviceId = url.charAt(url.length-1);
197243
var btns =[];
198244

@@ -205,15 +251,16 @@ window.onload = function(){
205251
modal.style.display = "none";
206252
}
207253
};
254+
208255
for(var i =0; i<replicanames.length; i++)(function(i){
209256

210257
btns.push(document.getElementById("textButton" + replicanames[i]));
211258
var replicaname = replicanames[i];
259+
// window.alert(replicaname);
212260

213-
btns[i].onclick = function() {
214-
215-
makeGraph(replicaname,serviceId,site)
216-
modal.style.display = "block";
261+
btns[i].onclick = function() {
262+
makeGraph(replicaname,serviceId,site)
263+
modal.style.display = "block";
217264
};
218265

219266
})(i);

0 commit comments

Comments
 (0)