The statistics are only accesible if you are logged in and to put all that in your own page is not inmmediate.

If you can make an app that takes a screenshot of your sunstone screen and serves it to the public that could be one easy way.

Second dirty way would be to try deploy a second sunstone server whose dashboard and layout are hacked in a way that it only shows the statistics (hiding the menu, top/bottom bars). I never tried to deploy a second server for the same install of ONE, but I think it should be possible. Hacking would be done in layout.js and dashboard-tab.js files mostly. You can hack sunstone-server.rb so that login happens automaticly with the credentials you want and perform relogin if session exprires.

And programatically, it is not so straightforward. Dashboard statistics are build by processing and regrouping the data that comes when the list of Hosts, VMs... is fetched. This is done in monitoring.js which groups and plots the information according to configurations defined in the SunstoneMonitoringConfig object.

So this approach would be a bit of a hell if you're not familiar with the code:

1 - add a custom route to the sunstone server that generates the stats page you want to show.

get '/stats' do
  #perhaps turn session expiration of here
  erb :stats, :layout => false
end

The generated html should contain the <div>s where you would like to paint the things. You can try copying that from dashboard-tab.js.

2 - Include opennenbula.js, monitoring.js and all the jquery* vendor libraries. Create a new stats.js file. After you login in sunstone, you can directly go to http://sunstone-ip:port/stats Your stats.js will need to make use of OpenNebula.Host.list(params) and similar to get a list of resources. In the params you need to include a callback function.

3 - your stats JS should include the SunstoneMonitoringConfig['HOST'] You can copy it from hosts-tab.js. The only part I think you need to edit is the plot() function inside it, which indicates where the plots are going to be painted ("container").

4 - Within the callback function for Host.list() you should call

    SunstoneMonitoring.monitor('HOST', host_list)

(see updateHostsView() in hosts-tab.js, which is the callback for Host.list())

5 - If the steps above are ok then the pies and diagrams for hosts should be painted in your stats page in the divs that you placed. If you want VMs stats, you need to get the VMs list, the SunstoneMonitoringConfig['VM'] object and repeat the process.

I keep wondering if maybe I missed an easy brighter way to do this. I'll write back if it cames to my mind.

--
Hector Sanjuan
OpenNebula Developer

En Wed, 05 Sep 2012 17:33:14 +0200, Sándor Guba <gubasa...@gmail.com> escribió:

Hi,

I would like to share the diagrams and statistics from sunstone
(dashboard host panel) on a public webpage. Is there an easy way to do
this?

Thank you for your answears!
_______________________________________________
Users mailing list
Users@lists.opennebula.org
http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
_______________________________________________
Users mailing list
Users@lists.opennebula.org
http://lists.opennebula.org/listinfo.cgi/users-opennebula.org

Reply via email to