Created
December 30, 2011 05:45
-
-
Save auxesis/1538119 to your computer and use it in GitHub Desktop.
Munge it, baby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'fastercsv' | |
unless ARGV[0] && ARGV[1] | |
puts "Usage: #{$0} <ARRAY_NAME> <POOL_ID>" | |
puts "Example: #{$0} VSP 0" | |
exit 1 | |
end | |
array_name = ARGV[0] | |
pool_id = ARGV[1].to_i | |
hicommand = `/srv/hitachi/devicemanager/cli/HiCommandCLI.sh -f csv GetStorageArray subtarget=pool` | |
options = {:headers => true, :converters => :numeric, :header_converters => lambda {|h| h}} | |
data = FasterCSV.new(hicommand, options).map {|r| r.to_hash} | |
data.each do |row| | |
if row["StorageArray.name"] =~ /^#{array_name}/ && row["StorageArray.Pool.poolID"] == pool_id | |
puts "Array: #{row["StorageArray.name"]}" | |
puts "Pool ID: #{row["StorageArray.Pool.poolID"]}" | |
puts "Usage: #{row["StorageArray.Pool.usageRate"]}" | |
puts "Free KB: #{row["StorageArray.Pool.freeCapacityInKB"]}" | |
puts "Total KB: #{row["StorageArray.Pool.capacityInKB"]}" | |
exit 0 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment