Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
faq:measure_availability [2014/09/23 20:54] – hessfaq:measure_availability [2026/10/20 12:34] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-==== How can I measure the availability of my routers? ==== 
- 
-Of course you can setup a Network Monitoring Tool (NMS) such as Zabbix.  
-An easier and faster way is to run the following PowerShell script: 
- 
-$hosts += "IP or DynDNS Name of my Routers" 
-$fname = "results.csv" 
-while($true) { 
-    $date = Get-Date -format G 
-    $newtime = Get-Date -format t 
-    # if ( $newtime -gt $time ) { 
-    if ( $true ) { 
-        $time = $newtime 
-        if ($hosts -isnot [system.array]) { 
-            $hosts = Get-Content $hosts 
-        } 
-        $hosts | Foreach-Object {  
-            $pinghost = $_ 
-            $psObject = $null 
-            $psObject = New-Object psobject 
-            Add-Member -InputObject $psobject -MemberType NoteProperty -Name "Date" -Value $date 
-            Add-Member -InputObject $psobject -MemberType NoteProperty -Name "Host" -Value $pinghost 
-            $status = Test-Connection –count 1 $pinghost  -ErrorAction SilentlyContinue 
-            if ($status.statuscode -eq 0) { 
-                $psobject | Add-Member -MemberType NoteProperty -Name "IP" -Value $status.IPV4Address 
-                $psobject | Add-Member -MemberType NoteProperty -Name "ResponseTime" -Value $status.ResponseTime 
-                $psobject | Add-Member -MemberType NoteProperty -Name "State" -Value "up" 
-                $psObject | Export-Csv $fname -Encoding UTF8 -Delimiter ";" -Append -NoTypeInformation 
-                #$outText = "$($psobject.Date); $($psobject.Host); $($psobject.IP); $($psobject.ResponseTime); $($psobject.State)" 
-                #$outText | Out-File -Encoding UTF8 -FilePath $fname -Append 
-                #$outText >> $fname  
-                Write-Host  $psObject  
-            } else { 
-                $status2 = Test-Connection –count 1 $pinghost -ErrorAction SilentlyContinue 
-                if ($status2.statuscode -eq 0) { 
-                    $psobject | Add-Member -MemberType NoteProperty -Name "IP" -Value $status2.IPV4Address 
-                    $psobject | Add-Member -MemberType NoteProperty -Name "ResponseTime" -Value $status2.ResponseTime 
-                    $psobject | Add-Member -MemberType NoteProperty -Name "State" -Value "up" 
-                    $psObject | Export-Csv $fname -Encoding UTF8 -Delimiter ";" -Append -NoTypeInformation 
-                    Write-Host $psobject  -ForegroundColor black -BackgroundColor green 
-                } else { 
-                    $psobject | Add-Member -MemberType NoteProperty -Name "IP" -Value ="n/a" 
-                    $psobject | Add-Member -MemberType NoteProperty -Name "ResponseTime" -Value "-100" 
-                    $psobject | Add-Member -MemberType NoteProperty -Name "State" -Value "down" 
-                    $psObject | Export-Csv $fname -Encoding UTF8 -Delimiter ";" -Append -NoTypeInformation 
-                    Write-Host $psobject -BackgroundColor Red 
-                } 
-            } 
-        } 
-    } 
-    Write-Host "wait another 5 seconds for for next check ..." 
-    Start-Sleep 5 
-}