Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 批脚本监控系统_File_Batch File - Fatal编程技术网

File 批脚本监控系统

File 批脚本监控系统,file,batch-file,File,Batch File,我需要监控服务是否达到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 (

我需要监控服务是否达到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!

)

)
端部


暂停假设
dir/-c:\\\124; findstr“bytes.free”
的输出如下:

   18 Dir(s)    997019979776 bytes free
   -- ------    ------------
   ^  ^         ^ 3rd token
   ^  ^ 2nd token
   ^ 1st token
然后,下一个代码片段可以工作,尽管您的逻辑中有一些我不清楚的地方(即
%%c GTR 159473725441
案例):


可能是因为你使用了像elseif这样的非法语句?批处理中没有
elseif
@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%