Ich habe nochmal meine Pingfunktionen überarbeitet.
Was meint ihr dazu?
Spoiler anzeigen
Func _pingdown($srv)
Local $Timer = TimerInit()
Do
$ping = Ping($srv, 250)
Until Not $ping or TimerDiff($Timer)>300000
If Not $ping Then
_FileWriteLog($Log, $txt6 & $srv & $txt7 & @CRLF)
Else
_FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
EndIf
EndFunc ;==>_pingdown
[/autoit] [autoit][/autoit] [autoit]Func _pingup($srv)
Local $Timer = TimerInit()
Do
$ping = Ping($srv, 250)
Until $ping or TimerDiff($Timer)>300000
If $ping Then
_FileWriteLog($Log, $txt6 & $srv & $txt8 & @CRLF)
Else
_FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
EndIf
EndFunc ;==>_pingup
[/autoit]Hier nochmal komplett
Spoiler anzeigen
#cs ---------------------------------------------------------------------
AutoIt Version: 3.2.10.0
Author: Andreas Heß
Copyright: Andreas Heß
Script Function: Reboot mehrerer Server.
Script Version: 1.9
Script Date: 02.12.2008
#ce ---------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]#NoTrayIcon
#include <Date.au3>
#include <File.au3>
;------------------------------------------------------------------------
;---------------------------- WICHTIGER - HINWEIS------------------------
;------------------------------------------------------------------------
;------------- Bereich in dem geändert werden darf - Anfang -------------
;------------------------------------------------------------------------
$Domaene = "localdomain.de" ;Domäne
$Benutzer = "serviceuser" ;ServiceUser
$Kennwort = "servicepw" ;Kennwort des ServiceUsers
$Passwort = "manuell" ;Kennwort für manuellen Start
$timeout = "10" ;Zeit bis zum Neustart in Sekunden
Global $aSrv[20] = ["test01","test02","test03","test04","","","","","","","","","","","","","","","",""]
[/autoit] [autoit][/autoit] [autoit];------------------------------------------------------------------------
;-------------- Bereich in dem geändert werden darf - Ende --------------
;------------------------------------------------------------------------
;---------------------------- WICHTIGER - HINWEIS -----------------------
;------------------------------------------------------------------------
;------------------------------------------------------------------------
;------------------ Variablen zum Reboot und zum Abbruch ----------------
;------------------------------------------------------------------------
$reboot = @SystemDir & '\shutdown.exe -r -f -d p:1:1 -c "Sonderwartung" -t ' & $timeout & " -m \\"
$cancel = @SystemDir & "\shutdown.exe -a -m \\"
;------------------------------------------------------------------------
;------------------------- Variablen für Logdatei -----------------------
;------------------------------------------------------------------------
$Log = @ScriptDir & "\logs\Rebootlog vom " & _NowDate() & ".txt"
If Not FileExists(@ScriptDir & "\logs\") Then DirCreate(@ScriptDir & "\logs\")
$txt1 = "Automatischer Reboot "
$txt2 = "Manueller Reboot "
$txt3 = " wurde ausgelöst "
$txt4 = " wurde abgebrochen "
$txt5 = "von " & @UserName
$txt6 = "Serverstatus "
$txt7 = " ist OFFLINE "
$txt8 = " ist ONLINE "
$txt9 = " ist UNBEKANNT "
;------------------------------------------------------------------------
;------------------------------- Checkpoint 1 ---------------------------
;------------------------------------------------------------------------
$sec_1 = @UserName
$manuell = 0
If $sec_1 = $Benutzer Then
RunAsSet($Benutzer, $Domaene, $Kennwort)
For $i = 0 To 19
If $aSrv[$i] <> "" Then _reboot($aSrv[$i])
Next
For $i = 0 To 19
If $aSrv[$i] <> "" Then _pingdown($aSrv[$i])
Next
For $i = 0 To 19
If $aSrv[$i] <> "" Then _pingup($aSrv[$i])
Next
RunAsSet()
Else
;------------------------------------------------------------------------
;------------------------------- Checkpoint 2 ---------------------------
;------------------------------------------------------------------------
$sec_2 = InputBox("Warnung -- Warnung", "Reboot erfordert Passwort.", "", "*", 250, 50)
$manuell = 1
If $sec_2 = $Passwort Then
RunAsSet($Benutzer, $Domaene, $Kennwort)
For $i = 0 To 19
If $aSrv[$i] <> "" Then _reboot($aSrv[$i])
Next
If MsgBox(4, "Cancel Reboot", "Soll der Reboot abgebrochen werden?", $timeout) = 6 Then
For $i = 0 To 19
If $aSrv[$i] <> "" Then _cancel($aSrv[$i])
Next
Exit
EndIf
For $i = 0 To 19
If $aSrv[$i] <> "" Then _pingdown($aSrv[$i])
Next
For $i = 0 To 19
If $aSrv[$i] <> "" Then _pingup($aSrv[$i])
Next
RunAsSet()
EndIf
EndIf
;------------------------------------------------------------------------
;---------------------- Abschnitt Funktionen - Beginn -------------------
;------------------------------------------------------------------------
Func _pingdown($srv)
Local $Timer = TimerInit()
Do
$ping = Ping($srv, 250)
Until Not $ping or TimerDiff($Timer)>300000
If Not $ping Then
_FileWriteLog($Log, $txt6 & $srv & $txt7 & @CRLF)
Else
_FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
EndIf
EndFunc ;==>_pingdown
[/autoit] [autoit][/autoit] [autoit]Func _pingup($srv)
Local $Timer = TimerInit()
Do
$ping = Ping($srv, 250)
Until $ping or TimerDiff($Timer)>300000
If $ping Then
_FileWriteLog($Log, $txt6 & $srv & $txt8 & @CRLF)
Else
_FileWriteLog($Log, $txt6 & $srv & $txt9 & @CRLF)
EndIf
EndFunc ;==>_pingup
[/autoit] [autoit][/autoit] [autoit]Func _reboot($srv)
If $manuell = 1 Then
Run($reboot & $srv, "", @SW_HIDE)
_FileWriteLog($Log, $txt2 & $srv & $txt3 & $txt5 & @CRLF)
Else
Run($reboot & $srv, "", @SW_HIDE)
_FileWriteLog($Log, $txt1 & $srv & $txt3 & $txt5 & @CRLF)
EndIf
EndFunc ;==>_reboot
Func _cancel($srv)
Run($cancel & $srv, "", @SW_HIDE)
_FileWriteLog($Log, $txt2 & $srv & $txt4 & $txt5 & @CRLF)
EndFunc ;==>_cancel
;------------------------------------------------------------------------
;----------------------- Abschnitt Funktionen - Ende --------------------
;------------------------------------------------------------------------
LG
Schnuecks