F5 LTM sonuçlarının bir metin dosyasını alan ve bunu aranabilir bir diziye koyan bir dize yazmaya çalışıyorum, böylece sonuçları dünden bugüne kadar karşılaştırabilirim.Liste nesnelerinin Powershell dizisi
Bu, dosyanın bir örneğidir;
MemberCount : 2
Name : /Common/blah1
Availability : AVAILABILITY_STATUS_GREEN
Enabled : ENABLED_STATUS_ENABLED
Status : The pool is available
MemberCount : 2
Name : /Common/blah2
Availability : AVAILABILITY_STATUS_GREEN
Enabled : ENABLED_STATUS_ENABLED
Status : The pool is available
yüzden ideal ben Adı benzersiz alanı ve liste bu yüzden dünden bugüne durumundaki değişiklikleri karşılaştırabilirsiniz tür yapmak istiyorum.
İşte sonuçları e-postayla göndermek için üzerinde çalıştığım koddur, ancak yalnızca e-postada nesne değişikliklerini almayı tercih ettiğim satırdaki satır farkı sağlar.
Add-PSSnapIn iControlSnapIn
$f5_hosts = '192.168.x.x', '192.168.x.x'
$uid = 'xx'
$pwd ='xx'
foreach($f5_host in $f5_hosts){
$f5_host_out = $(get-date -f yyyyMMdd)+"_"+$f5_host+".txt"
$f5_host_out_yesterday = $((get-date).AddDays(-1).ToString('yyyyMMdd'))+"_"+$f5_host+".txt"
#Check login details and generate LTM output file for $f5_host
Initialize-F5.iControl -HostName $f5_host -Username $uid -password $pwd
Get-F5.LTMPool | out-file $f5_host_out
#// Check if EMP file for yesterday exists and send results else send error
if (Test-Path $f5_host_out_yesterday){
$f5_host_Result = compare-object -ReferenceObject (Get-Content $f5_host_out) -DifferenceObject (Get-Content $f5_host_out_yesterday)
$f5_host_out_yesterday+": file is Present!"
$Text_Body = $f5_host+": difference `r`n"
$Text_Body += ($f5_host_Result | out-string)
Send-MailMessage -to [email protected]cq.com.au -from [email protected] -subject $f5_host+": F5 Daily LTM Check" -body $Text_Body -smtpserver mailrelay.racqgroup.local
}else{
$f5_host_out_yesterday+": is not file is Present!"
Send-MailMessage -to [email protected] -from [email protected] -subject $f5_host+": Check failed" -body "Yesterday's file is not present" -smtpserver mailrelay.racqgroup.local
}
}
#Limit File retention to 30days.
$limit = (Get-Date).AddDays(-30)
#Get script location
$path = Get-Location
# Delete files older than the $limit.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force
Bu yüzden bir e-postada böyle bir şey görmek istiyorum sadece edecek bir çıktı olarak
Difference From yesterday to today
Yesterday
MemberCount : 2
Name : /Common/blah1
Availability : AVAILABILITY_STATUS_GREEN
Enabled : ENABLED_STATUS_ENABLED
Status : The pool is available
Today
MemberCount : 2
Name : /Common/blah1
Availability : AVAILABILITY_STATUS_RED
Enabled : ENABLED_STATUS_ENABLED
Status : The pool is available
Lütfen, F5 kodunuz için giriş bilgilerini gerçekten orada komut dosyasına dahil etmediğinizi söyleyin. – TheMadTechnician
Hayır hiç de değil. Bu bir Test VM'sidir. F5 üretiminin tek faktörlü girişleri vardır. – Sapage
Tamam, sadece emin olmak gerekirse, F5 girişinizi şimdi değiştirmeniz gerekiyorsa :) – TheMadTechnician