Value Template calculation for disk free SNMP (Windows)

Hey guys,

I’ve seen one other thread talking about this. But its not working for me correctly.

I’m trying to get a free space calculation for all my windows server disks.

So far I have;

  - platform: snmp
    host: exchange
    name: "Exchange C Free"
    baseoid: 1.3.6.1.2.1.25.2.3.1.5.1
    unit_of_measurement: GB
    accept_errors: true
    value_template: "{{ (1967925760000 - value | int * 4096) / 1073741824 }}"

Which gives me

I should have 11GB free

I actually have no idea how they got the numbers for this or what this value template is actually doing TBH LOL

Any help would be appreciated :slight_smile:

The OID is for the total size of the disk

Ok,

I pretty much got this now lol

“{{ (127775277056 - value | int * 4096) / 1073741824 | round(1) }}”

So total disk space - used disk space provided by SNMP | do something that converts bytes to GB LOL

But, my rounding doesn’t seem to work. I guess Im missing something there?

Yep. You are rounding the number 1073741824. Put some parentheses around it:

"{{ ((127775277056 - value | int * 4096) / 1073741824) | round(1) }}"

Awesome, thanks mate. Appreciate that

I seem to have it working now. I have 11.2GB

What I don’t get, is what metric this is? SNMP says it should be bytes. But these figures are way too small when I look at a raw sensor

Exchange Used C 28361875

Exchange Total C 31311871

Does HA not display the whole thing?

image

If you look up the oid description they are “storage units”. Whatever that is.

When you formatting the disk, I.e in 4k Units(4096), or 1024, or 512Bytes
So actually the “template/formula” is not accurate, as the " 127775277056 " is bytes and reported Total
Disk-size 31311781 X 4096 = 128 253 423 616
Disk-use 28361875 X 4096 = 116 170 240 000
So in the end it’s 11.253 (11.3 ) but do to the " 127775277056 " i guess it only show 11.2

Ahh… reading some SNMP doco, it talks about storage allocation units… But no idea what that is LOL

https://oidref.com/1.3.6.1.2.1.25.2.3.1

So thank you so much for that. I still don’t really understand what 31311781 is called though? What is that

your sensor reports Total 31311781 Units on the Disk, and 28361875 Units used
1 Unit = 4096 Bytes

Smallest unit on a Disk( HD CD SSD) can contain 512Bytes(Called a Sector), been like that since the 70-80th when IBM took the lead of the HD Standardization

Now a days is the default When you format a Disk in i.e Windows " 4K unit" 4096Bytes ( a multiply of 512 )
1 Unit can only held information from 1 file
so if you have 1000 files that are only i.e 472 Bytes large each, each files will take up 4096 Bytes of space, if the disk is formatted with large 4096 Units … im sure you have seen this in windows ( File-Size vs File-size on disk )
This means i.e that those files total size are 1000x472 = 472.000 B
But on the Disk the they will occupy total of 1000x4096= 4 096 000 B … 10 times more(waste of space)

in early Days, But actually still ( as nothing has change on this parts ), there will beside waste “optimization of space”, also be a “performance” issue to take into consideration, beside “fault-tolerance” , when formatting a disk, as now you can format with 512 , Multiply to i.e 64K or 2MB , whatever supported for various supported OS/File-Systems
units

Right, so its a unit of based on cluster size. So when using this always check your cluster size to make sure your sum is going to be correct.

Awesome! thank you for that, its really helped :slight_smile:

With this info Ive got SNMP to show the free size for all my important workloads.