Quantcast
Viewing latest article 6
Browse Latest Browse All 87

Compare file size vs hard disk space.

I need to create a sensor that compares if the free disk space is twice the size of a file. I have tried using WMI but I can only see either the disk space or the file size, and I don't know how to perform a mathematical operation for this purpose. I have also tried using a custom EXE/Script sensor with the following code:

On Error Resume Next

Set objFSO = CreateObject("Scripting.FileSystemObject")

'Obtener la información del archivo Arballon_d.mdf
Set objFile = objFSO.GetFile("F:\SQL2K14\Arballon_D.mdf")
dblFileSize = objFile.Size / 1073741824 'Convertir bytes a gigabytes

'Obtener la información del disco F:
Set objDrive = objFSO.GetDrive("F:")
dblFreeSpace = objDrive.FreeSpace / 1073741824 'Convertir bytes a gigabytes

'Comparar el espacio libre con el tamaño del archivo
If dblFreeSpace >= (dblFileSize * 2.5) Then
    WScript.Echo "1"
Else
    WScript.Echo "0" 
End If

"Where the value 1 would be correct and the value 0 would be an error." - but I get an error because the predefined channels are Downtime and Execution Time, and I cannot customize them since version 17.


Viewing latest article 6
Browse Latest Browse All 87

Trending Articles