Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
centreon:scripts-windows [2023/07/05 12:42] – créée michel | centreon:scripts-windows [2024/12/27 06:28] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
==== check_file.vbs ==== | ==== check_file.vbs ==== | ||
< | < | ||
- | ' | ||
- | ' | ||
' Check files under a given path | ' Check files under a given path | ||
' ============================== | ' ============================== | ||
Ligne 2218: | Ligne 2216: | ||
# attention une charge trop importante peu faire planter la machine. | # attention une charge trop importante peu faire planter la machine. | ||
# à vos risques est périle. | # à vos risques est périle. | ||
+ | </ | ||
+ | ==== remote_ping.bat ==== | ||
+ | < | ||
+ | @ECHO OFF | ||
+ | SETLOCAL | ||
+ | |||
+ | REM ####### ENSURE ALL REQUIRED INFO IS PRESENT --UNIX VAR--###### | ||
+ | @ECHO %1%2%3%4%5%6|FIND " | ||
+ | IF NOT ERRORLEVEL 1 GOTO MSEOF | ||
+ | |||
+ | REM ####### ENSURE ALL REQUIRED INFO IS PRESENT --WIN VAR--###### | ||
+ | IF " | ||
+ | IF " | ||
+ | IF " | ||
+ | IF " | ||
+ | IF " | ||
+ | IF " | ||
+ | |||
+ | REM PAUSE | ||
+ | |||
+ | @ECHO %4 |FIND " | ||
+ | IF NOT ERRORLEVEL 1 GOTO MSEOF | ||
+ | @ECHO %6 |FIND " | ||
+ | IF NOT ERRORLEVEL 1 GOTO MSEOF | ||
+ | |||
+ | REM ####### ASSIGN EACH TO A VARIABLE TO REFERENCE IT LATER..###### | ||
+ | SET IP=%1 | ||
+ | SET PKT=%2 | ||
+ | SET WRTA=%3 | ||
+ | SET WPL=%4 | ||
+ | SET CRTA=%5 | ||
+ | SET CPL=%6 | ||
+ | |||
+ | REM ######## CAPTURE FRESH DATA TO A FILE ####### | ||
+ | REM 20120920 TO AVOID COLLISIONS DURING CONCURRENT CALLS CREATE A SEMI-RANDOM FILE NAME | ||
+ | SET RANDOMFILENAME=%RANDOM%-%1-TMP | ||
+ | @ECHO -> | ||
+ | |||
+ | PING %IP% -n %PKT% >> | ||
+ | |||
+ | REM ######## PICKOUT THE DATA WE NEED FROM THE FILE ####### | ||
+ | FOR /F " | ||
+ | |||
+ | IF ERRORLEVEL 1 GOTO TIMEOUT | ||
+ | FOR /F " | ||
+ | |||
+ | |||
+ | REM PAUSE | ||
+ | DEL /Q %RANDOMFILENAME% | ||
+ | |||
+ | |||
+ | REM ######## TRIM THE VARIABLES...#### | ||
+ | SET AVG=%AVG: | ||
+ | SET AVG=%AVG: | ||
+ | |||
+ | :TIMEOUT | ||
+ | SET LST=%LST: | ||
+ | SET LST=%LST: | ||
+ | |||
+ | |||
+ | REM ######## NOW THE FUN STUFF, COMPARE THE WARNING, CRITICAL VALUES..#### | ||
+ | |||
+ | IF %LST% GEQ %CPL% GOTO CPL-2 | ||
+ | IF %AVG% GEQ %CRTA% GOTO CRTA-2 | ||
+ | IF %LST% GEQ %WPL% GOTO WPL-1 | ||
+ | IF %AVG% GEQ %WRTA% GOTO WRTA-1 | ||
+ | |||
+ | REM PAUSE | ||
+ | |||
+ | GOTO OK-0 | ||
+ | |||
+ | :CPL-2 | ||
+ | @ECHO REMOTE CONNECTION TO %IP% IS DOWN: LOSS=%LST%%% (%PKT% PKTS)^|rta=%CRTA%; | ||
+ | REM GOTO EOF | ||
+ | @EXIT 2 | ||
+ | |||
+ | :CRTA-2 | ||
+ | @ECHO REMOTE CONNECTION TO %IP% IS DOWN: LOSS=%LST%%%, | ||
+ | REM GOTO EOF | ||
+ | @EXIT 2 | ||
+ | |||
+ | :WPL-1 | ||
+ | @ECHO REMOTE CONNECTION TO %IP% IS SLOW: LOSS=%LST%%%, | ||
+ | REM GOTO EOF | ||
+ | @EXIT 1 | ||
+ | |||
+ | :WRTA-1 | ||
+ | @ECHO REMOTE CONNECTION TO %IP% IS SLOW: LOSS=%LST%%%, | ||
+ | REM GOTO EOF | ||
+ | @EXIT 1 | ||
+ | |||
+ | :OK-0 | ||
+ | @ECHO REMOTE CONNECTION TO %IP% IS UP: LOSS=%LST%%%, | ||
+ | REM GOTO EOF | ||
+ | @EXIT 0 | ||
+ | |||
+ | :MSEOF | ||
+ | @ECHO USAGE: | ||
+ | @ECHO EXAMPLE: / | ||
+ | @ECHO : PING_REMOTE 192.168.0.1 5 200,1 400,10 (FROM A LOCAL WIN WKS WHERE PING_REMOTE.BAT RESIDES) | ||
+ | @ECHO : (WPL\CPL ARE IN PERCENT, WITHOUT THE " | ||
+ | |||
+ | REM GOTO EOF | ||
+ | @EXIT 0 | ||
+ | |||
+ | :EOF | ||
+ | </ | ||
+ | ==== Exchange ==== | ||
+ | - Exchange-serverCertificate | ||
+ | < | ||
+ | # Exchange 2013 Server Certificat | ||
+ | # | ||
+ | |||
+ | |||
+ | $status = 0 | ||
+ | $descr="" | ||
+ | $date= Get-Date | ||
+ | add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn | ||
+ | |||
+ | |||
+ | $GetCrt = Get-ExchangeCertificate | Where-Object {$_.Status -ne " | ||
+ | foreach ( $item in $GetCrt ){ | ||
+ | $status = 2 | ||
+ | #$NameCrt = $item.DnsNameList | ||
+ | $NameCrt = $item.Subject | ||
+ | $NameCrt2 = $NameCrt.Punycode | ||
+ | $DateCrt = $item.NotAfter | ||
+ | $ValidCrt = $item.Status | ||
+ | $descr = " | ||
+ | if ($DateCrt -lt $date ){ | ||
+ | $status = 1 | ||
+ | } | ||
+ | } | ||
+ | |||
+ | switch ($status) | ||
+ | { | ||
+ | 0 {"OK: Tous les certificats sont valides." | ||
+ | 1 {" | ||
+ | 2 {" | ||
+ | } | ||
+ | |||
+ | exit $status | ||
+ | </ | ||
+ | - Exchange-serverComponentHealth | ||
+ | < | ||
+ | # Exchange 2013 Server Component Health Check | ||
+ | # | ||
+ | |||
+ | Param( | ||
+ | [string]$ExchServ | ||
+ | ) | ||
+ | |||
+ | $status = 0 | ||
+ | |||
+ | add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn | ||
+ | |||
+ | |||
+ | # | ||
+ | $SSE2 = Get-ServerComponentState -Identity $ExchServ | Where-Object { $_.State -ne " | ||
+ | Get-ServerComponentState -Identity $ExchServ | Where-Object { $_.State -ne " | ||
+ | $SSE223 = $SSE2.State | ||
+ | $ImptpsCSV = Import-Csv -Path C: | ||
+ | if ( $SSE223 -eq " | ||
+ | # At least one health check is inactive | ||
+ | $status=2 | ||
+ | foreach ( $Srvc in $ImptpsCSV ){ | ||
+ | $Name = $Srvc.Component} | ||
+ | $desc = "$Name checks is KO" | ||
+ | } | ||
+ | if ($status -eq " | ||
+ | Write-Host " | ||
+ | } elseif ($status -eq " | ||
+ | Write-Host "All Service Active for $ExchServ" | ||
+ | | ||
+ | |||
+ | |||
+ | exit $status | ||
+ | </ | ||
+ | - Exchange-serverDB | ||
+ | < | ||
+ | # Exchange 2013 Server DB | ||
+ | # | ||
+ | |||
+ | <#Param( | ||
+ | [string]$ServerExch | ||
+ | ) | ||
+ | #> | ||
+ | |||
+ | $status = 0 | ||
+ | $descr = "" | ||
+ | add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn | ||
+ | |||
+ | $GetDB = Get-MailboxDatabase | Where-Object {$_.IsValid -ne " | ||
+ | foreach ( $item in $GetDB ){ | ||
+ | $status = 2 | ||
+ | $ID = $Item.Name | ||
+ | $descr = " | ||
+ | } | ||
+ | |||
+ | if ( $status -ne 0 ) { | ||
+ | Write-Host " | ||
+ | } | ||
+ | else { | ||
+ | Write-Host "OK: Toutes les bases sont valides." | ||
+ | } | ||
+ | |||
+ | exit $status | ||
+ | </ | ||
+ | - Exchange-serverPoolIIS | ||
+ | < | ||
+ | # Exchange 2013 Server Pool IIS | ||
+ | # | ||
+ | |||
+ | Param( | ||
+ | [string]$ExchServ | ||
+ | ) | ||
+ | |||
+ | $status = 0 | ||
+ | add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn | ||
+ | |||
+ | |||
+ | Invoke-Command -ComputerName $ExchServ -ScriptBlock { | ||
+ | $POOL = Get-WebAppPoolState | select ItemXPath, | ||
+ | Clear-Content c: | ||
+ | if ( $POOL -ne $Null ){ | ||
+ | Add-Content -Path c: | ||
+ | foreach ( $item in $POOL ) { | ||
+ | $item1 = $item.ItemXPath | ||
+ | $Name = ($item1.split("'" | ||
+ | Add-Content -Path c: | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $PoolLog = Get-Content -Path " | ||
+ | if ( $PoolLog -ne $Null ) { | ||
+ | $status =2 | ||
+ | Write-Host " | ||
+ | } | ||
+ | else { | ||
+ | Write-Host "OK: Pas de Pool problematique sur le serveur $ExchServ" | ||
+ | } | ||
+ | |||
+ | exit $status | ||
</ | </ |