alanrenouf / vCheck-vSphere

vCheck Daily Report for vSphere
MIT License
733 stars 325 forks source link

New Plugin $Display type: Graph #145

Closed Sneddo closed 9 years ago

Sneddo commented 10 years ago

This one is a long way off, but I think we should aim to support graphs as an output now that the resource code is pretty much done. Probably a 7.x release goal, but logging to get ideas flowing.

Will need to investigate different graphing APIs.

From memory Google has one that you can specify the graph parameters via URL, and we can download the resulting image to include in the report, or include in img tags.

alanrenouf commented 10 years ago

I try to stay away from anything that can not be reached locally, I like for this script to be downloaded and used without a bunch of pre-reqs or having to have access to the internet etc, I like this idea but finding a way to do it in HTML or Javascript or some kind of HTML5 I think would be the best answer here.

Sneddo commented 10 years ago

Yeah, I'd ideally like to stay away from Javascript and HTML5 as well, purely for the sake of email reports and the terrible support in Outlook. Possibly adding these in for richer standalone reports, so make it modular as possible.

Of course, it appears the the .NET framework may come to the rescue here withe the System.Windows.Forms.DataVisualization class: http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.chart(v=vs.110).aspx

alanrenouf commented 10 years ago

That could work, generate the form on the server, save it as an image, base64 encode it and re-include it back in the HTML..... Ooooo Nice.

http://blogs.technet.com/b/richard_macdonald/archive/2009/04/28/3231887.aspx

Sneddo commented 10 years ago

That's the plan... and actually looks reasonably simple (famous last words!)

Sneddo commented 10 years ago

...I'll just leave this here...

Current work in progress. http://tinyurl.com/kdrz4fy

smasterson commented 10 years ago

Where's the Like button :-)

alanrenouf commented 10 years ago

Like? Where is the love button? What solution is this with? Any pre-reqs needed?

Sneddo commented 10 years ago

It's using the .Net data visualisation class.

I've created a helper function for use in plugins to create a chart object which is returned as the plugin detail (or as you see in the example, you can pass an array of charts object). Then just change the $display variable to "chart". A new display handler has been created to generate the chart, which is passed to the resource handling code to be included in the report.

The whole amount of plugins code to generate those graphs? About 4-6 lines from memory :)

I'll push some code to my repo today or tomorrow, I think this will need a bit of testing before we push it to the main repo, though with no plugins using charts it may not matter (yet).

Sneddo commented 10 years ago

So I've just pushed the code to my "charting" branch: https://github.com/Sneddo/vCheck-vSphere/tree/charting

Basically there are three changed files - vCheck.ps1, a demo plugin "Test Chart.ps1", and the VMware style (to include setting chart colour palette)

Still a couple of things left to do:

Sneddo commented 10 years ago

Submitted pull #206 with the start of this. Really need some daring testers to play with it and break it :)

Sneddo commented 9 years ago

At this point, the code is in vCheck. Will close off this issue and any bug reports or feature requests can be raised as new issues.

alanrenouf commented 9 years ago

Did you have a sample plugin for this? I cant find "Test Chart.ps1" anywhere?

alanrenouf commented 9 years ago

Dont worry, worked it out