>Recently, I have created a thread about the fact that the .NET Framework does not allow to read NAS drive properties as this is not a Windows drive. After that, in order for our monitoring to detect if 90% of available space has been reached, we relied on a monitoring team, which has roles of doing things like that at the enterprise level. However, before, when we were on a 100% Windows infrastructure, we were able to do it by ourselves.
>
>Yesterday, someone suggested to use the DIR command and parse the output to collect the number of free bytes. So, this is good. I cannot obtain the 90% ratio but I can verify that we have a minimum amount of free bytes before sending an alert. Would there by another DOS command that would give me the total available space of the disk?
A NAS or other storage appliance:
- may have multiple volumes defined, not all of which are presented via SMB/CIFS or otherwise accessible from Windows
- may have unused space with no volumes defined
- you may not have permission to access all of the volumes
- on volumes you are allowed to access, disk quotas may be in force
- the NAS as a whole may use dedupe and/or compression, so even if you had full access to all defined volumes, the numbers you would see would only be estimates
In general the only way you can get meaningful device-wide free space status is through the device's management interface.
In the
special case where:
- you know there is no unused space on the device
- the device uses neither deduplication nor compression
- you have full (no quotas) access to all defined volumes
then, if you enumerate all the volumes you *may* get a reasonable status for the whole device.
If you just want to make sure your application isn't going to run out of free space, then you really only care about the volume(s) to which you have been granted access. If these are mounted on your local computer as SMB/CIFS volumes, then they should respond to DOS, Win32 or .Net calls to get information about them. Googling I find
http://msdn.microsoft.com/en-us/library/system.io.driveinfo%28v=vs.110%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1 . The .TotalSize, .TotalFreeSpace and (especially) .AvailableFreeSpace properties should give you what you need.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up