# PRTG DBLog # # Simple PRTG Sensor to count amount of database transaction logs of all Databases # Does not work with Circular Logging # Requires configuration für database path # http://www.paessler.com/manuals/prtg/additional_sensor_types.htm # http://www.paessler.com/manuals/prtg/exe_script_advanced_sensor.htm # # 32bit PowerShell !!! # Set-ExecutionPolicy -ExecutionPolicy remotesigned # # 20120110 Ver1.0 Initial Version based on a exmetric # # Open: test-connection # write-host "Start PRTG Sensor" [string]$exchangeuri = "http://nawex001.netatwork.de/PowerShell" [string]$message ="Start:" $error.clear() write-host "Parametercheck: Total argument" + $args.count if (!(Get-Command "Get-OrganizationConfig" -errorAction SilentlyContinue)) { $error.removerange(0,1) # remove last error write-host " Creating Exchange Remote Session" $session = new-pssession ` -ConfigurationName "Microsoft.Exchange" ` -ConnectionUri $exchangeuri ` -Authentication Kerberos write-host " Import Exchange Remote Session Commandlets" import-pssession -Session $session -AllowClobber | out-null } Set-AdServerSettings -ViewEntireForest $true $dblist = Get-mailboxdatabase | select name,Servername,LogFolderpath,LogFilePrefix $result="`r`n" foreach ($db in $dblist){# write-host "Processing Database:"$db.name write-host "Pinging Server:" $db.servername if (Test-Connection -Quiet -Computername $db.servername) { $UNClogpath = ("\\"+$db.servername+"\"+ $db.LogFolderPath.tostring().replace(":","$"))+"\"+ $db.LogFilePrefix+"*.log" write-host " UNClogpath:" + $UNClogpath $filecount = (get-item -path $UNClogpath).count write-host " filecount :" + $filecount $result+=" `r`n" $result+=" "+$db.name+"`r`n" $result+=" "+$filecount+"`r`n" $result+=" MB`r`n" $result+=" Absolute`r`n" $result+=" `r`n" } else { Write-host "Server not reachable using ICMP" } $result+=" "+$message+"`r`n" $result+="" remove-pssession -session $session write-host "End: ExitCode "$error.count Write-host "Sending Result to output pipeline" $result if ($error) { #write-host "Found Errors" EXIT 1 }