Most Valued User Remco Posted August 28, 2015 Most Valued User #1 Share Posted August 28, 2015 Sometimes, you want to know from the Swyxserver script if a specific IP address is "Alive" to take certain call routings. You can check for example if a specific Router, IP-Phone or DECT Master is still in the network.We do this sometimes with customers with multiple locations after a " normal" delivery of the call fails that should have worked...Anyway, here is a solution that you can use:Put the following function in the Start-Rule Block en use the evaluation block to call it like IsIPorHostAlive("8.8.8.8") Returns --> True/False Make sure that the SwyxService account (used to run the Swyxware services) is added to the local administrators group before you run this script. If you do this, restart the Swyxservices after adding the user to the local administrators, or the script will not work! Function IsIPorHostAlive(strHost) 'Function to check if a device is in the network 'Use fixed IP addresses of Routers, SwyxPhones etc. to check for availability! 'Script by Remco Eikhout - Swyx Master Teacher 'wwww.intratel.nl 'Intratel BV - NLH-Net BV 'OZMO Cloud telephony On Error Resume Next PBXScript.OutputTrace "IsIPORHostAlive | Check " & strHost Dim oPing, oRetStatus, bReturn Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address='" & strHost & "'") PBXScript.OutputTrace "Waarde ping " & oPing PBXScript.OutputTrace "Error " & Err If Err<>0 Then For Each oRetStatus In oPing If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then bReturn = False PBXScript.OutputTrace "IsIPORHostAlive | Warn* - Ping failed, try again! (Status code is " & oRetStatus.StatusCode & ")" PBXScript.Sleep(500) 'Second try... If IsNull(oRetStatus.StatusCode) Or oRetStatus.StatusCode <> 0 Then bReturn = False PBXScript.OutputTrace "IsIPORHostAlive | Err* - Ping failed, status code is " & oRetStatus.StatusCode Else bReturn = True End If Else bReturn = True PBXScript.OutputTrace "IsIPORHostAlive | Bytes = " & vbTab & oRetStatus.BufferSize PBXScript.OutputTrace "IsIPORHostAlive | Time (ms) = " & vbTab & oRetStatus.ResponseTime PBXScript.OutputTrace "IsIPORHostAlive | TTL (s) = " & vbTab & oRetStatus.ResponseTimeToLive End If Set oRetStatus = Nothing Next Else bReturn =False 'Fail Save !! End If Set oPing = Nothing IsIPORHostAlive = bReturn End Function Link to comment Share on other sites More sharing options...
Tom Wellige Posted August 29, 2015 #2 Share Posted August 29, 2015 Hi Remco, thanks for posting! This surely is a useful function. Just one hint to make sure everyone is aware of it: In order to make your function work you have to add the SwyxServer service to the group of local administrators. This gives every call routing script, regardless of what user full administrative privileges on that machine. There are a lot of things I can imagine I don't want to be done on a Swyx Server via a few lines of VBScript placed by some user in his call routing. To overcome this situation it is a MUST that all users get their right to open the GSE revoked! Leave this right only to those users you really trust. The Call Routing Manager and the Rule Wizard are totally safe. Just the GSE with it's ability to inject any VBScript code into the call routing is dangerous in this case. BTW: this is the reason, why the Swyx services are all running under their own user (Swyx Service Account). In this case the GSE is safe, as you can't to anything from within the call routing script which doesn't need to get approved by an admin before (e.g. by configuring file access privileges). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.