PureStorage Integration

Ich mutmaße mal, dass es diesbezüglich noch nichts neues gibt.
Daher lasse ich einfach mal dieses quick-and-dirty Powershell-Skript von mir hier. Seht es als PoC an.
Das Skript kann von einem Windows-Agent ausgeführt werden, um die Volumes einer Pure-Appliance abzufragen.

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$username = "MYPUREUSERNAME"
$password = "MYPUREPASSWORD"
$ArrayAddress = "MYPUREHOSTNAME"
$apiversion = "1.15"

$output = "<<<<$ArrayAddress>>>>" + [Environment]::NewLine
[string]$array = "https://$($ArrayAddress)"
$cred = (convertto-json @{
        username=$username
        password=$password})

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$apiret = Invoke-RestMethod -Uri "$array/api/$apiversion/auth/apitoken" -Method Post -Body $cred -ContentType "application/json"
$APIKey = $apiret.api_token
$apitoken = (ConvertTo-Json @{api_token=$APIKey})
$apiret = Invoke-RestMethod -Uri "$array/api/$apiversion/auth/session" -Method Post -Body $apitoken -ContentType "application/json" -SessionVariable websession
$array_volumes = Invoke-RestMethod -Uri "$array/api/$apiversion/volume" -websession $websession -ContentType "application/json"
$output += "<<<df:sep(9)>>>" + [Environment]::NewLine
foreach ($array_volume in $array_volumes) 
{
$volume_name = $array_volume.name
$array_volumestat = Invoke-RestMethod -Uri "$array/api/$apiversion/volume/$($volume_name)?space=true" -websession $websession -ContentType "application/json" 
$array_volperf = Invoke-RestMethod -Uri "$array/api/$apiversion/volume/$($volume_name)?action=monitor" -websession $websession -ContentType "application/json"
$volume_serial = $array_volume.serial 
$volume_created = $array_volume.created 
$volume_total = $array_volumestat.total 
$volume_snapshot = $array_volumestat.snapshots 
$volume_volumes = $array_volumestat.volumes
$volume_size = $array_volumestat.size
$volume_shared = $array_volumestat.shared_space
$volume_thinprov = $array_volumestat.thin_provisioning
$volume_datareduc = $array_volumestat.data_reduction
$volume_totalreduc = $array_volumestat.total_reduction
$volume_wps = $array_volperf.writes_per_sec
$volume_rps = $array_volperf.reads_per_sec
$volume_ips = $array_volperf.input_per_sec
$volume_ops = $array_volperf.output_per_sec
$volume_upwo = $array_volperf.usec_per_write_op
$volume_upro = $array_volperf.usec_per_read_op

$volume_free = $volume_size - $volume_total
$volume_total_percent = [math]::Ceiling($volume_total / $volume_size * 100)

$output += $volume_name + "`t" + "LUN" + "`t" + $volume_size + "`t" + $volume_total + "`t" + $volume_free + "`t" +$volume_total_percent + "%`t" + $volume_name  + [Environment]::NewLine

}
$output += "<<<<>>>>"
Write-Host $output

Kann am Ende dann so oder so ähnlich aussehen:

Achja:
Errorhandling und Cleancode sind meinem Skript noch ein Fremdwort :wink:

1 Like