monitor hpc by node
diff --git a/xos/core/xoslib/dashboards/xosHpcUrls.html b/xos/core/xoslib/dashboards/xosHpcUrls.html
new file mode 100644
index 0000000..4bfa263
--- /dev/null
+++ b/xos/core/xoslib/dashboards/xosHpcUrls.html
@@ -0,0 +1,32 @@
+<script src="{{ STATIC_URL }}/js/vendor/underscore-min.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.syphon.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.wreqr.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.babysitter.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.marionette.js"></script>
+
+<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
+<link rel="stylesheet" type="text/css" href="{% static 'css/xosTenantDashboard.css' %}" media="all" >
+<link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminSite.css' %}" media="all" >
+
+<script src="{{ STATIC_URL }}/js/xoslib/xos-util.js"></script>
+<script src="{{ STATIC_URL }}/js/xoslib/xos-defaults.js"></script>
+<script src="{{ STATIC_URL }}/js/xoslib/xos-validators.js"></script>
+<script src="{{ STATIC_URL }}/js/xoslib/xos-backbone.js"></script>
+<script src="{{ STATIC_URL }}/js/xoslib/xosHelper.js"></script>
+<script src="{{ STATIC_URL }}/js/xosHpcUrls.js"></script>
+
+<div id="xos-hpc-view-panel"> <!-- contentPanel"> -->
+<div id="contentTitle">
+</div>
+
+<div id="contentInner">
+
+Node: <select id="xos-hpc-node-select"></select>
+
+<div id="xos-hpc-urls"></div>
+
+</div> <!-- end contentInner -->
+</div> <!-- end contentPanel -->
+
+{% include 'xosAdmin.html' %}
diff --git a/xos/core/xoslib/static/js/xosHpcUrls.js b/xos/core/xoslib/static/js/xosHpcUrls.js
new file mode 100644
index 0000000..3a8cfe0
--- /dev/null
+++ b/xos/core/xoslib/static/js/xosHpcUrls.js
@@ -0,0 +1,91 @@
+SC_HPC_FETCH = 3600;
+
+var hpc_data = null;
+
+function updateHpcUrlTable() {
+ hpcnode = null;
+ selected_node_name = $("#xos-hpc-node-select").val();
+
+ for (index in hpc_data) {
+ if (hpc_data[index].name == selected_node_name) {
+ hpcnode = hpc_data[index];
+ };
+ }
+
+ if (hpcnode == null) {
+ $("#xos-hpc-urls").html("select a node");
+ return;
+ }
+
+ $('#xos-hpc-urls').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamic_hpc_urls"></table>' );
+ var actualEntries = [];
+
+ if (parseInt(hpcnode["watcher.HPC-fetch.time"])> SC_HPC_FETCH) {
+ $("#xos-hpc-urls").html("stale");
+ return;
+ }
+
+ urls = hpcnode["watcher.HPC-fetch.urls"];
+
+ for (index in urls) {
+ url = urls[index];
+ bytes_downloaded=url[2];
+ total_time = url[3];
+ if (total_time > 0) {
+ KBps = Math.round(bytes_downloaded/total_time/1024.0);
+ } else {
+ KBps = 0;
+ }
+ actualEntries.push( [url[0], url[1], bytes_downloaded, total_time, KBps] );
+ }
+
+ oTable = $('#dynamic_hpc_urls').dataTable( {
+ "bJQueryUI": true,
+ "aaData": actualEntries ,
+ "bStateSave": true,
+ "bFilter": false,
+ "bPaginate": false,
+ "aoColumns": [
+ { "sTitle": "Url", },
+ { "sTitle": "Status" },
+ { "sTitle": "Bytes_Downloaded" },
+ { "sTitle": "Total_Time" },
+ { "sTitle": "KBps" },
+ ]
+ } );
+}
+
+function updateNodeList() {
+ selected_node_name = $("#xos-hpc-node-select").val();
+
+ options = [];
+ for (index in hpc_data) {
+ node = hpc_data[index];
+ if (node.name == selected_node_name) {
+ options.push("<option value=\"" + node.name + "\" selected>" + node.name + "</option>");
+ } else {
+ options.push("<option value=\"" + node.name + "\">" + node.name + "</option>");
+ }
+ }
+
+ $("#xos-hpc-node-select").html(options);
+}
+
+function updateHpcView(data) {
+ data = data[0];
+ hpc_data = data.attributes.hpc;
+ updateNodeList();
+ updateHpcUrlTable();
+}
+
+$(document).ready(function(){
+ xos.hpcview.on("change", function() { console.log("change"); updateHpcView(xos.hpcview.models); });
+ xos.hpcview.on("remove", function() { console.log("sort"); updateHpcView(xos.hpcview.models); });
+ xos.hpcview.on("sort", function() { console.log("sort"); updateHpcView(xos.hpcview.models); });
+
+ $("#xos-hpc-node-select").click( function() { updateHpcUrlTable(); } );
+
+ xos.hpcview.startPolling();
+});
+
+
diff --git a/xos/observers/hpc/hpc_watcher.py b/xos/observers/hpc/hpc_watcher.py
index 2af9d00..e3a316f 100644
--- a/xos/observers/hpc/hpc_watcher.py
+++ b/xos/observers/hpc/hpc_watcher.py
@@ -282,6 +282,7 @@
return
except Exception, e:
+ #traceback.print_exc()
job["status"] = "Exception: %s" % str(e)
return
@@ -371,9 +372,10 @@
raise ValueError("Couldn't find network %s" % str(network_name))
- def set_status(self, sliver, service, kind, msg):
+ def set_status(self, sliver, service, kind, msg, check_error=True):
#print sliver.node.name, kind, msg
- sliver.has_error = (msg!="success")
+ if check_error:
+ sliver.has_error = (msg!="success")
sliver_type = ContentType.objects.get_for_model(sliver)
@@ -529,19 +531,22 @@
result = self.fetch_queue.get_result()
sliver = result["sliver"]
if (result["status"] == "success"):
- sliver.url_status.append( (result["url"], "success", result["bytes_downloaded"], result["total_time"]) )
+ sliver.url_status.append( (result["domain"] + result["url"], "success", result["bytes_downloaded"], result["total_time"]) )
if (result["status"]!="success") and (not sliver.has_error):
self.set_status(sliver, service, "watcher.HPC-fetch", result["status"])
for sliver in slivers:
- self.set_status(sliver, service, "watcher.HPC-fetch-urls", json.dumps(sliver.url_status))
+ self.set_status(sliver, service, "watcher.HPC-fetch-urls", json.dumps(sliver.url_status), check_error=False)
if not sliver.has_error:
self.set_status(sliver, service, "watcher.HPC-fetch", "success")
def run_once(self):
for hpcService in HpcService.objects.all():
for slice in self.get_service_slices(hpcService, "hpc"):
- self.fetch_hpc(hpcService, slice.slivers.all())
+ try:
+ self.fetch_hpc(hpcService, slice.slivers.all())
+ except:
+ traceback.print_exc()
def run(self):
while True: