I was hoping to play and learn with a task in powershell that at least sounded pretty easy in my head, I guess it is pretty easy stuff but I’m obviously doing something very wrong. After a couple of hours of trial and error I’m pretty sure I’m approaching this the wrong way.
I recently installed a tool to get some statistics/values from our storage system.
The tool produces a bunch of csv files (attached one of them)
I started with just trying to play with the first four columns: Timestamp, MDisk, Read operations (IO/s),Write operations (IO/s)
I’m trying to calculate the average read and write IOPS per MDisk.
Wit the code I got now, it actually outputs a view I was kind of happy with, at least for a start.
Problem is that the final $object only has one (the last) mdisk and its values in it.
I kind of understand that I’m doing something stupid with the foreach statement that’s causing this, and I’ve tried a couple of things like initializing an empty array to be able to use +=$object.
My hope is to be able to use these csv files to parse the data in a nice way in the future, but as I got stuck right at the beginning of playing and started to get disgruntled I was hoping someone could guide me in the right direction.
With your calls to Select-Object -Property MDisk -Unique, and later Where-Object MDisk -eq $mdisk, you were basically recreating the functionality of Group-Object in a less efficient way.
Thanks Dave, I’m gonna go with your last suggestion, haven’t used Group-Object alot.
I know there a lot of ways of doing this stuff in PS, but would you (or anyone else) say this is decent approach or are there any other (better) ways?
Thinking that next step somehow should be to include the Storage Pools.
For example mdisk0-5 are in one Pool, so maybe create another object that just sums some of the values of those mdisks, that should be easy, let’s see how that goes
I’ll keep this post updated if that’s okay.
Also, any feedback/suggestions on how to go forward with this, other angles or code cleanup are always appreciated.