달력

3

« 2024/3 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
명령줄 Command Line 창에서 netstat 명령 실행 후 결과에 대한 행 수를 계산할 경우 사용할 수 있는 스크립트입니다. 저의 경우, SCOM을 통해 특정 IP로 연결되는 연결 수를 성능 그래프화하기 위해 사용하였습니다.
VBS VBScript ReadLine netstat SCOM System Center 2012 Operations Manager

아래의 예는 netstat -ano | findstr "123.123.123.123" 실행 후 라인 수를 리턴하는 예제입니다.

Dim strCmd : strCmd = "cmd /c netstat -ano | findstr "&chr(34)&"123.123.123.123"&chr(34)
Dim objShell : Set objShell = WScript.CreateObject("WScript.Shell")
Dim objExecObject
Set objExecObject = objShell.Exec(strCmd)

Do While Not objExecObject.StdOut.AtEndOfStream
objExecObject.StdOut.ReadAll()
valLine = objExecObject.StdOut.Line - 1
Loop

WScript.Echo valLine
 
:
Posted by 커널64