TCFLEE
Contributor
Contributor

Unitinfo of Datastore cluster is out of space

Hi,

I am trying to retrieve the alarm triggers settings in my ESXi 5.0 cluster from the VC. I perform that by reading the PerfCounterID and then use QueryPerfCounter to get the name and unit information. Everything looks good except for the Datastore cluster is out of space and Datastore usage on disk alarms.

(get-alarmdefinition "datastore cluster is out of space").extensiondata.info.expression.expression[0].metric.counterid

     returns 240

(get-view (get-view serviceinstance).content.perfmanager).queryperfcounter(240)[0].nameinfo.label

     returns Space actually used

(get-view (get-view serviceinstance).content.perfmanager).queryperfcounter(240)[0].unitinfo.label

     returns KB

From vSphere Client GUI, it shows

     Datastore Disk Usage (%)

What sould I do to retrieve the correct trigger setting of each alarm?

Thanks,

Terence

0 Kudos
4 Replies
LucD
Leadership
Leadership

I suspect the vSphere client makes that calculation under the hood.

From the total amount of space (Capacity) and the used space it shouldn't be hard to calculate the percentage free space.

Afaik there is no percent free space metric for datastores.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

TCFLEE
Contributor
Contributor

Hi LucD,

Thanks for your reply. But (get-alarmdefinition "Datastore cluster is out of space").extensiondata.info.expression.expression returns

Operator        : isAbove
Type            : StoragePod
Metric          : VMware.Vim.PerfMetricId
Yellow          : 7500
YellowInterval  :
Red             : 8500
RedInterval     :
DynamicType     :
DynamicProperty :

The yellow and red numbers are percentages.

(get-alarmdefinition "Datastore cluster is out of space").extensiondata.info.expression.expression[0].metric | fl

CounterId       : 240
Instance        :
DynamicType     :
DynamicProperty :

Do you see the same in your environment?

Thanks,

Terence

0 Kudos
LucD
Leadership
Leadership

I see the same, and that metric is in fact disk.used.latest (note that the MetricId is not fixed, it can be different in different vSphere environments).

You can check like this

$alarm = Get-AlarmDefinition -Name "Datastore cluster is out of space" -Server $defaultviserver
$metricId = $alarm.ExtensionData.info.expression.expression[0].metric
$perfMgr
= Get-View (Get-View ServiceInstance -Server $defaultviserver).Content.PerfManager -Server $defaultviserver
$metric
= $perfMgr.PerfCounter | where {$_.Key -eq $metricId.CounterId} $metric | Select Key,
 
@{N="Name" ;E={$_.GroupInfo.key + "." + $_.NameInfo.Key + "." + $_.RollupType}},
  @{N="Unit";E={$_.UnitInfo.Key}}  

I suspect that the AlarmManager, most probably based on the SystemName property (alarm.StoragePodOutOfSpace), knows what to do and converts the metric from KB to %.

I don't seem to find any confirmation on my assumption in the documentation though.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

TCFLEE
Contributor
Contributor

Hi LucD,

That is very helpful.

Thanks,

Terence

0 Kudos