Moin,
ich versuche das vb script (welches funktioniert) in au3 zu übersetzen.
Spoiler anzeigen
Code
'------------------------------------------------------------------------------
' IIS v6 Check state of an application pool
' =========================================
'
' Author: Vincent BESANCON (vincent.besancon@faurecia.com)
' Usage:
' check_iis_apppool_state.vbs <pool_name>
' <pool_name> - The name of the application pool.
'
' It returns:
' - OK if state is running.
' - CRITICAL if state is stopped.
' - WARNING if state is stopping or starting.
' - UNKNOWN for all the others (app pool not found, etc...).
'
' Nagios Agent configuration (NSC.INI):
' check_iis_apppool_state=cscript.exe //nologo //T:60 scripts\check_iis_apppool_state.vbs $ARG1$
'------------------------------------------------------------------------------
'
' Args
strArgAppPool = Wscript.Arguments.Unnamed.Item(0)
' Establish the connection to the WMI provider
Set oWMIService = GetObject("winmgmts:root\microsoftiisv2")
' Search the AppPool passed as argument in the list of application pools
Set strQueryAppPools = oWMIService.ExecQuery("Select * from IIsApplicationPoolSetting where Name='W3SVC/AppPools/" & strArgAppPool & "'")
' Enumerate the pools
noError = False
For Each oAppPool in strQueryAppPools
noError = True
' Create nice messages for pool states
Select Case oAppPool.AppPoolState
Case 1
poolState = "Starting"
outputStatus = "WARNING: "
outputCode = 1
Case 2
poolState = "Running"
outputStatus = "OK: "
outputCode = 0
Case 3
poolState = "Stopping"
outputStatus = "WARNING: "
outputCode = 1
Case 4
poolState = "Stopped"
outputStatus = "CRITICAL: "
outputCode = 2
Case else
poolState = "unknown"
outputStatus = "UNKNOWN: "
outputCode = 3
End Select
' Create a clear name for the pool (remove the leading info)
poolName = Replace(oAppPool.Name, "W3SVC/AppPools/", "")
' Output
Wscript.Echo outputStatus & poolName & ", State: " & poolState
Next
' Error handling
If Not noError Then
' Error message
Wscript.echo "UNKNOWN: Error during the WMI query for app pool " & strArgAppPool & " !"
' Exit & return code
WScript.Quit(3)
Else
' Clean exit
WScript.Quit(outputCode)
End If
Alles anzeigen
au3:
AutoIt
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=au3.exe
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\microsoftiisv2")
If Not IsObj($objWMIService) Then
MsgBox(16, "Error", "$objWMIService is not an object.")
Exit
EndIf
$colItems = $objWMIService.ExecQuery ("Select * from IIsApplicationPoolSetting where Name='W3SVC/AppPools/4b3fc250b9b544ab8b1ee2e585328429'")
_ArrayDisplay($colItems)
For $colItem In $colItems
msgbox(0,"",$colItem.AppPoolState)
Next
Alles anzeigen
egal wie ichs mache, das script beendet sich einfach ohne ergebnisse, ich habe statt localhost auch schon den computernamen genutzt, ändert leider nichts. jemand ne idee?
handelt sich um den iis7 auf win 2008 r2
grüße