Disk Free Space Alert

M

maitakeboy

I've gotten burned twice, now, by not having any automatic alert that informs
me when my file server space is getting low. I can't seem to find anything
built-in to Windows to do this. What is the suggested way to configure
automatic alerts when a logical drive is running out of space?
 
P

Pegasus \(MVP\)

maitakeboy said:
I've gotten burned twice, now, by not having any automatic alert that
informs
me when my file server space is getting low. I can't seem to find anything
built-in to Windows to do this. What is the suggested way to configure
automatic alerts when a logical drive is running out of space?

Get the Task Scheduler on the server to run this batch file
once every day:
$@echo off >nullfile.txt
$set Drive=C:
$set Limit=1000
$for /F "tokens=7" %%a in ('fsutil volume diskfree %Drive% ^| find /i "# of
free"') do set free=%%a
$set free=%free:~0,-6%
$if %free% LSS %Limit% net send YourPCName "Warning: Free space on
%ComputerName% is less than %Limit% MBytes"

Note:
- You must remove all $ characters. Their only purpose is to mark
the beginning of each line.
- The Messenger service must run on your own PC.
- Set Limit=2000 if you mean 2000 MBytes (=2 GBytes)
 
M

maitakeboy

Pegasus,

Thanks for your reply! What exactly are you setting when you set the Set
Limit? Is that the remaining free space? Can you do a percentage?
 
S

Sid Elbow

Pegasus said:
Get the Task Scheduler on the server to run this batch file
once every day:
$@echo off >nullfile.txt
$set Drive=C:
$set Limit=1000
$for /F "tokens=7" %%a in ('fsutil volume diskfree %Drive% ^| find /i "# of
free"') do set free=%%a
$set free=%free:~0,-6%
$if %free% LSS %Limit% net send YourPCName "Warning: Free space on
%ComputerName% is less than %Limit% MBytes"

Note:
- You must remove all $ characters. Their only purpose is to mark
the beginning of each line.
- The Messenger service must run on your own PC.
- Set Limit=2000 if you mean 2000 MBytes (=2 GBytes)

Neat ... I still think you should change your name to bat-man.
 
P

Pegasus \(MVP\)

If you want a percentage then you can run this batch file:
$@echo off
$goto Start
$-----------------------------------------------------------------------------
$This batch file will check the amount of free disk space on the
$nominated drive. If it is less than the specified percentage
$then it will generate a pop-up warning on the specified computer.
$
$You must set three parameters below the ":Start" label:
$set Drive=C: (or any other drive)
$set Limit=20 (the percentage figure below which a warning will be
issued.
$set Dest=Pegasus (the name of the machine that will receive the warning)
$
$Note: On the %Dest% machine, the "Messenger" service must be running.
$
$19.1.2008 FNL
$-----------------------------------------------------------------------------
$:Start
$set Drive=C:
$set Limit=20
$set Dest=Pegasus
$
$fsutil fsinfo ntfsinfo %Drive% > nul
$if ErrorLevel 1 (
$ fsutil fsinfo ntfsinfo %Drive%
$ echo Press the Space Bar to close this window.
$ pause > nul
$ goto :eof
$)
$
$for /F "tokens=7" %%a in ('fsutil volume diskfree %Drive% ^| find /i "# of
free"') do set free=%%a
$for /F "tokens=6" %%a in ('fsutil volume diskfree %Drive% ^| find /i "# of
byte"') do set total=%%a
$set free=%free:~0,-6%
$if "%free%"=="" set free=0
$set total=%total:~0,-6%
$set /a percent=%free% * 100 / %total%
$echo Free space on drive %Drive% is %percent%%% of capacity
$if %percent% LSS %Limit% net send %Dest% "Warning: Free space on drive
%Drive% on %ComputerName% is %Percent%%% of capacity."

- You must remove all $ characters. Their only purpose is to mark
the beginning of each line.
- The Messenger service must run on your own PC.
- Set Limit=20 if you mean 20% of capacity
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top