MAL - Memória Auxiliar do Lutieri

quarta-feira, novembro 11, 2009

some vbscript for Nagios checks

Detect if media is connected to a interface:



aStatusStr = Split("Disconnected,Connecting,Connected,Disconnecting," _
& "Hardware not present,Hardware disabled,Hardware malfunction," _
& "Media disconnected,Authenticating,Authentication succeeded," _
& "Authentication failed,Invalid address,Credentials required", ",")

strComputer = "."
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\cimv2")

Set cItems = oWMI.ExecQuery("Select * from Win32_NetworkAdapter"_
& " where AdapterTypeID = 0") ' 0 = Ethernet 802.3

For Each oItem in cItems
''if Instr(oItem.NetConnectionID, "LAN") > 0 then

if oItem.NetConnectionID <> "" then

output = output & oItem.NetConnectionID & ": "_
& aStatusStr(oItem.NetConnectionStatus) & " * "

End if
''End if
Next

Wsh.echo output
WScript.Quit(0)
''' Source: http://msdn.microsoft.com/en-us/library/aa394216%28VS.85%29.aspx




Detect which node is the Active and Passive in a Windows Cluster environment:



set WshShell = CreateObject( "WScript.Shell" )

Set objNet = CreateObject("WScript.NetWork")

Dim strComputerName
strComputerName = objNet.ComputerName


sExe = "cluster resource ""cluster ip address"""
with CreateObject("WScript.Shell")
with .Exec(sExe)
with .StdOut
do until .AtEndofStream
s = s & Replace(.ReadLine, vbcr, "") _
& vbNewLine
Loop
end with ' StdOut
end with ' Exec
end with ' Shell

'wsh.echo s
Result = InStr(1, s, strComputerName, VBTEXTCOMPARE)


if Result <> 0 then
WScript.echo strComputerName & " is the ACTIVE"
Else
WScript.echo strComputerName & " is the PASSIVE"
end if

WScript.Quit(0)

Marcadores: ,

0 Comentários:

Postar um comentário

<< Home



Chat with Lutieri G. B.

Subscribe in a reader