Med kunstig intelligens skaber HP’s nye OmniBook X 14 en unik og skræddersyet brugeroplevelse målrettet dem, der ønsker høj ydeevne og intelligente funktioner
24. juli 2024
Slettet bruger
03. marts 2006 - 10:50#1
Det bliver nok af omveje med mindre du kan finde noget COM som kan lave et Ping. Men en, bevars lav praktisk løsning kunne være:
1) Start ping komando og redirect (pipe) resultatet til en fil. 2) Læs filen og reager på hvad du nu måtte ønske.
' -- Define variables Dim wshShell Dim objFileSystem Dim strPingDest(1, *) ‘-* must equal the full amount of servers you want to ping Dim objLogFile Dim strLogData Dim fOpenLog Dim objMOMEvent Dim intCounter Dim intStart Dim intEnd
' -- Create a Shell object Set wshShell = CreateObject("WScript.Shell")
' -- Create a FileSystemObject Set objFileSystem = CreateObject("Scripting.FileSystemObject")
' -- Define ping destination strPingDest(0, 0) = "Enter IP Address Here" strPingDest(0, 1) = "Enter IP Address Here" strPingDest(0, 2) = "Enter IP Address Here" strPingDest(0, 3) = "Enter IP Address Here" strPingDest(0, 4) = "Enter IP Address Here" strPingDest(0, 5) = "Enter IP Address Here" strPingDest(0, 6) = "Enter IP Address Here" strPingDest(0, 7) = "Enter IP Address Here" strPingDest(0, 8) = "Enter IP Address Here" strPingDest(0, 9) = "Enter IP Address Here" strPingDest(0, 10) = "Enter IP Address Here"
strPingDest(1, 0) = "Enter Device Name Here" strPingDest(1, 1) = "Enter Device Name Here" strPingDest(1, 2) = "Enter Device Name Here" strPingDest(1, 3) = "Enter Device Name Here" strPingDest(1, 4) = "Enter Device Name Here" strPingDest(1, 5) = "Enter Device Name Here" strPingDest(1, 6) = "Enter Device Name Here" strPingDest(1, 7) = "Enter Device Name Here" strPingDest(1, 8) = "Enter Device Name Here" strPingDest(1, 9) = "Enter Device Name Here" strPingDest(1, 10) = "Enter Device Name Here" ‘The above listed can be extended past just ten items if you wish, just make sure to change any array information
intCounter = 0 ‘ – For intCounter must equal 0 to Maximum Number of Devices you are pinging For intCounter = 0 to * ‘-* must equal the full amount of servers you want to ping ' -- Define log file location objLogFile = "C:\Pinglogs\PingLog(" + strPingDest(1, intCounter) + ")[" & cStr(intCounter) & "].txt"
‘The above command will create the pinglogs that generate the error read by MOM. You must change the * to the total amount of servers you are attempting to ping, otherwise it will create quite a few errors in MOM for script failure.
' -- Run the ping and pipe output to the log file wshShell.Run "cmd.exe /c ping " & strPingDest(0, intCounter) & " -n 2 > " & objLogFile,,true
' -- Open log file and read line 5 Set fOpenLog = objFileSystem.OpenTextFile(objLogFile, 1) fOpenLog.ReadLine fOpenLog.ReadLine fOpenLog.ReadLine fOpenLog.ReadLine strLogData = fOpenLog.ReadLine fOpenLog.Close
' -- Generate alert if the 5th line is Request timed out. Select Case strLogData Case "Request timed out." & vbCR
' -- Create error event to be submitted to MOM server (Ping Test failed) Set objMOMEvent = ScriptContext.CreateEvent() objMOMEvent.EventSource = "MOM Ping Monitor Tool" objMOMEvent.EventNumber = 10002 objMOMEvent.EventType = 1 objMOMEvent.Message = "Ping Test to " & strPingDest(1, intCounter) & "(" & strPingDest(0, intCounter) & ") failed. Please investigate."
'-- Submit Created Error Event to MOM data stream ScriptContext.Submit(objMOMEvent)
Case Else
'-- Create information event and submit to MOM data stream for tracking purposes Set objMOMEvent = ScriptContext.CreateEvent() objMOMEvent.EventSource = "MOM Ping Monitor Tool" objMOMEvent.EventNumber = 10001 objMOMEvent.EventType = 4 objMOMEvent.Message = "Ping Test to " & strPingDest(1, intCounter) & "(" & strPingDest(0, intCounter) & ") succeeded. No action necessary."
'-- Submit Created Error Event to MOM data stream ScriptContext.Submit(objMOMEvent)
End Select Next 'intCounter
' -- Reset all variables Set wshShell = Nothing Set objFileSystem = Nothing 'Set strPingDest = Nothing Set intCounter = Nothing Set objLogFile = Nothing Set fOpenLog = Nothing Set strLogData = Nothing Set objMOMEvent = Nothing
Tjah her har du en der kan lave en til MOM, nu ved jeg ikke hvor skarp du er til scripting men den kan forholdsvist nemt laves om til at lade være med at lave en event i MOM datastrømmen...
Håber du ka det til noget... det er forresten en gut på MOMCommunity der har lavet det... kunne godt være smart lige at nævne.. :d
rs.MoveNext LOOP RS.Close conn.Close Set conn = nothing Set SQLstmt = nothing
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.