diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..45516c77db0b44ea6b385804af52295117ddf5cf --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +stages: + - test_live + - schedule + +test_live: + stage: test_live + tags: + - live + script: + - PowerShell .\ipconnectivitychecker.ps1 + when: always + + +ipChecker_live: + stage: schedule + variables: + ErrorActionPreference: stop + tags: + - live + script: + - PowerShell .\ipconnectivitychecker.ps1 + only: + - schedules \ No newline at end of file diff --git a/README.md b/README.md index 8b137891791fe96927ad78e64b0aad7bded08bdc..134081ebe118fe1a4af21deb9c39ceb59fdc8366 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ +# IP Connectivity Checker +This script checks the ip connectivity in connection with onboarded universities using their own rds. +## Usage +* The script runs as a daily scheduled gitlab job. It passes the pipelinie only if all ip connections are checked "ok". +* The logs can be seen in the pipeline logs. +* Users can set up merge requests for correcting/updating IP addresses. diff --git a/ipconnectivitychecker.ps1 b/ipconnectivitychecker.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..fc2500d032a7beb472da11a21e4f22fbc66f8b6e --- /dev/null +++ b/ipconnectivitychecker.ps1 @@ -0,0 +1,62 @@ +function testport([string]$srv,$p,$timeout=2000){ + $ErrorActionPreference = "SilentlyContinue" + $tcpclient = new-Object system.Net.Sockets.TcpClient + $iar = $tcpclient.BeginConnect($srv,$port,$null,$null) + $wait = $iar.AsyncWaitHandle.WaitOne($timeout,$false) + if(!$wait) + { + $tcpclient.Close() + $global:pipelineFails=$true + Return "Connection Timeout at " + (Get-Date).ToString() + } + else + { + $error.Clear() + $tcpclient.EndConnect($iar) | out-Null + if(!$?){ + $global:pipelineFails=$true + Return $error[0] + (Get-Date).ToString() + } + $tcpclient.Close() + } + Return "ok" +} + +$global:pipelineFails=$false +echo "********************************" +echo " Checking IP connectivity " +echo "********************************" +echo "=== UDE Management ===" +$ips = @("132.252.182.129","132.252.182.130", "132.252.182.131", "132.252.182.132", "132.252.182.133", "132.252.182.134", "132.252.182.135", "132.252.182.136", "132.252.182.137", "132.252.182.138", "132.252.182.139","132.252.182.140","134.91.199.65","134.91.199.66","134.91.199.67","134.91.199.68","134.91.199.69","134.91.199.70","134.91.199.71","134.91.199.72","134.91.199.73","134.91.199.74","134.91.199.75","134.91.199.76") +$port ="4443"; +foreach($ip in $ips){ + echo "$($ip):$port $(testport $ip -p $port)"; +} + +echo "=== UDE Data ===" +$ips = @("132.252.182.1", "132.252.182.2","132.252.182.3","132.252.182.4","132.252.182.5", "132.252.182.6","132.252.182.7","132.252.182.8","132.252.182.9", "132.252.182.10","132.252.182.11","132.252.182.12","134.91.199.1", "134.91.199.2","134.91.199.3", "134.91.199.4","134.91.199.5","134.91.199.6","134.91.199.7","134.91.199.8","134.91.199.9","134.91.199.10","134.91.199.11","134.91.199.12") +$port ="9021"; +foreach($ip in $ips){ + echo "$($ip):$port $(testport $ip -p $port)"; +} + + +echo "=== TUDO Management ===" +$ips = @("129.217.149.130","129.217.149.131", "129.217.149.132","129.217.149.133","129.217.149.134","129.217.149.135", "129.217.149.136","129.217.149.137", "129.217.149.138", "129.217.149.160", "129.217.149.161", "129.217.149.162","129.217.149.163", "129.217.149.164", "129.217.149.165", "129.217.149.166", "129.217.149.167", "129.217.149.168") +$port ="4443"; +foreach($ip in $ips){ + echo "$($ip):$port $(testport $ip -p $port)"; +} + +echo "=== TUDO Data ===" +$ips = @("129.217.149.2", "129.217.149.3","129.217.149.4","129.217.149.5","129.217.149.6","129.217.149.7","129.217.149.8", "129.217.149.9", "129.217.149.10","129.217.149.32","129.217.149.33","129.217.149.34","129.217.149.35","129.217.149.36","129.217.149.37","129.217.149.38","129.217.149.39","129.217.149.40") +$port ="9021"; +foreach($ip in $ips){ + echo "$($ip):$port $(testport $ip -p $port)"; +} + +if($pipelineFails) { + echo "IP connectivity check fails at least once" + $Host.SetShouldExit(-1) + Exit -1 +}