您好,登錄后才能下訂單哦!
############################################ #Author:Lixiaosong #Email;lixiaosong8706@gmail.com #For:監控無線AP運行狀態 #Version:1.0 2015年6月1日 ############################################ $aps=0,1,2,3,4,5,6,7,12,13,14,15 $aplist = @() foreach($ap in $aps){ $secpasswd = ConvertTo-SecureString "password" -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential ("admin", $secpasswd) New-SSHSession -ComputerName 192.168.0.1 -Credential $creds -AcceptKey $SSHStream = New-SSHShellStream -Index 0 Start-Sleep 2 $SSHStream.Write("sys`n") $SSHStream.Write("wlan`n") $SSHStream.Write("display ap-performance-statistic id $ap `n") Start-Sleep 2 $apclient=$SSHStream.Read() $cpu=(($apclient |findstr.exe "CPU")[0]).replace(" CPU use rate: ","") $memory=(($apclient |findstr.exe "Memory")[0]).replace(" Memory use rate: ","") $temperature=(($apclient |findstr.exe "Temperature").replace(" Temperature: ","")).replace(" ??","")+"℃" $users=($apclient |findstr.exe "Online").replace(" Online user number: ","" ) $portrate=(($apclient |findstr.exe "rate")[4]).replace(" Up port rate: ","" ) Remove-SSHSession -Index 0 echo $ap $apclient $apobject=New-object psobject $apobject | Add-Member -membertype noteproperty -Name APID -value $ap $apobject | Add-Member -membertype noteproperty -Name 用戶數 -Value $users $apobject | Add-Member -membertype noteproperty -Name CPU使用率 -value $cpu $apobject | Add-Member -membertype noteproperty -Name 內存使用率 -Value $memory $apobject | Add-Member -membertype noteproperty -Name 運行溫度 -value $temperature $apobject | Add-Member -membertype noteproperty -Name 端口速率 -Value $portrate $aplist+=$apobject } $EmailbodyHTML=$aplist| sort-object 用戶數 | ConvertTo-Html | Out-String $password = convertto-securestring "password" -asplaintext -force $cred=new-object -typename System.Management.Automation.PSCredential -argumentlist noreply@126.com,$password Send-Mailmessage -from noreply@qq.com -credential $cred -to user@qq.com -Bodyashtml $EmailbodyHTML -Subject "無線AP負載通知" -port 587 -UseSsl -smtpserver smtp.exmail.qq.com -Encoding ([System.Text.Encoding]::UTF8)
郵件監控效果:
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。