달력

1

« 2025/1 »

  • 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

Netstat -an | findstr "ESTABLISHED"해서 ESTABLISHED 세션 수 성능 수집

Rule > New > Probe based > Script(performance)

Object, Counter, Instance 적당한 값
Value: $Data/Property[@Name='ESTABLISHED Count']$

---------------------------------------------------------------------------------------------------------------

ESTABLISHED.vbs


Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile (".\ESTABLISHED.BAT", 8, True)

objTextFile.WriteLine("netstat -an -p tcp | findstr ESTABLISHED")
objTextFile.Close
Set objTextFile  = nothing

Set shellobj=WScript.CreateObject("WScript.Shell")
Set execObj=shellobj.Exec(".\ESTABLISHED.BAT")
OutData=execObj.StdOut.ReadAll()
val=execObj.StdOut.Line - 3

Set aFile = objFSO.GetFile(".\ESTABLISHED.BAT")
aFile.Delete
Set aFile = nothing
Set execObj = nothing

Call oBag.AddValue("ESTABLISHED Count",val)
Call oAPI.Return(oBag)

:
Posted by 커널64