我需要监控服务是否达到了80%-90%的容量,它会发出警告。我似乎不能让它工作。
REM dir c:\|find /i "bytes free" >> CDrive.txt
for /f %%c in (C.txt) do (
set %%c=104847433728
if %%c LSS 127578980352 (
echo Drive is not yet full.
) elseif %%c GEQ 127578980352 (
if %%c LSS 143526352896
echo Send WARNING!
if %%c LEQ 159473725441
echo Send CRITICAL!
)
)endlocal
暂停
发布于 2015-07-06 19:08:01
假设dir /-c C:\ |findstr "bytes.free"的输出如下:
18 Dir(s) 997019979776 bytes free
-- ------ ------------
^ ^ ^ 3rd token
^ ^ 2nd token
^ 1st token那么下一个代码片段就可以工作了,尽管我在您的逻辑中有一些不清楚的地方(即%%c GTR 159473725441案例):
@ECHO OFF
SETLOCAL enableextensions
for /f "tokens=3" %%c in ('dir /-c C:\ ^|findstr "bytes.free"') do (
set "_sizeC=%%c"
if %%c LSS 127578980352 (
echo Drive is not yet full.
) else (
if %%c LSS 143526352896 (
echo Send WARNING!
) else if %%c LEQ 159473725441 echo Send CRITICAL!
)
)
echo _sizeC=%_sizeC%https://stackoverflow.com/questions/31241527
复制相似问题