blob: 9cdd7ed7165c45be564f035fee727a9160e6f019 [file] [log] [blame]
Scott Baker771819b2014-03-19 22:10:17 -07001// ----------------------------------------------------------------------------
2// node count and average cpu utilization
3
Scott Baker9b1f2a02015-01-13 09:46:52 -08004function updateMiniDashStatistic(meter, buttonSelector) {
5 var url="/stats/?model_name=" + admin_object_name + "&pk=" + admin_object_id + "&meter=" + meter + "&controller_name=" + admin_object_controller;
Scott Bakera0ffec52015-01-13 01:06:34 -08006 console.log("fetching stats url " + url);
Scott Baker771819b2014-03-19 22:10:17 -07007 $.ajax({
Scott Baker61aefcf2014-04-25 15:21:18 -07008 url: url,
Scott Baker771819b2014-03-19 22:10:17 -07009 dataType : 'json',
10 type : 'GET',
Scott Bakerb23dd1d2014-06-09 16:03:35 -070011 success: function(newData) {
Scott Bakera0ffec52015-01-13 01:06:34 -080012 console.log(newData);
Scott Baker9b1f2a02015-01-13 09:46:52 -080013 if (newData.stat_list.length > 0) {
14 value = newData.stat_list.slice(-1)[0].value;
15 console.log(value);
16 $(buttonSelector).text(Math.round(value)).show();
17 } else {
18 $(buttonSelector).text("no data").show();
19 }
20 setTimeout(function() { updateMiniDashStatistic(meter, buttonSelector); }, 30000);
Scott Bakerb23dd1d2014-06-09 16:03:35 -070021 },
22 error: function() {
Scott Baker771819b2014-03-19 22:10:17 -070023 }
24});
Scott Baker771819b2014-03-19 22:10:17 -070025}
26
Scott Bakerca2e22d2014-05-23 18:26:06 -070027$( document ).ready(function() {
Scott Bakera0ffec52015-01-13 01:06:34 -080028 if (admin_object_name == "Sliver" && admin_object_id != undefined) {
Scott Baker9b1f2a02015-01-13 09:46:52 -080029 updateMiniDashStatistic("cpu", "#miniDashCPU");
30 updateMiniDashStatistic("network.outgoing.bytes", "#miniDashBandwidthIn");
31 updateMiniDashStatistic("network.incoming.bytes", "#miniDashBandwidthOut");
Scott Bakera0ffec52015-01-13 01:06:34 -080032 }
33});
Scott Baker771819b2014-03-19 22:10:17 -070034