############################################ #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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。