多个IP ping

时间:2018-10-24 06:53:17

标签: vb.net

CREATE OR REPLACE FUNCTION LAST_BUSINESS_DAY(today IN TIMESTAMP DEFAULT SYSTIMESTAMP) RETURN TIMESTAMP AS 
    return_date_after TIMESTAMP := TRUNC(today);
    next_run_date TIMESTAMP;
BEGIN

    LOOP
        DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING('FREQ=DAILY;INTERVAL=1;EXCLUDE=FEDERAL_HOLIDAYS,WEEKEND', NULL, return_date_after, next_run_date);
        EXIT WHEN next_run_date >= LAST_DAY(TRUNC(today));
        return_date_after := next_run_date;
    END LOOP;

    RETURN return_date_after;   
END LAST_BUSINESS_DAY;

是否可以ping通IP地址阵列并显示在线和离线的数量?

2 个答案:

答案 0 :(得分:0)

是的,可以通过将所需的IP地址放入阵列并循环遍历该阵列,然后测试每个IP来完成。

代码(未经测试,但应该可以帮助您):

Dim list As New List(Of String)
list.Add("192.168.20.251")
list.Add("192.168.233.1")
list.Add("192.168.0.199")
list.Add("192.168.2.55")


For Each item As String In list
    If My.Computer.Network.Ping(item) Then Console.WriteLine("IP FOUND " + item) Else Console.WriteLine("IP NOT FOUND " + item) End If
Next

答案 1 :(得分:0)

让我们考虑ListOfIPsList(Of String)或已经填充的字符串数组。

我不清楚您是否只想知道在线IP和离线IP的数量。 这是解决这两个问题的解决方案:显示哪个是ON / OFF,然后对它们进行计数。

Dim IpIsOn as Integer = 0
Dim IpIsOff as Integer = 0

For Each ip as String in ListOfIPs
    If My.Computer.Network.Ping(ip) Then
         Console.WriteLine(ip & " is online")
         IpIsOn = IpIsOn + 1
    Else
         Console.WriteLine(ip & " is offline")
         IpIsOff = IpIsOff + 1
    End If
Next

Console.WriteLine("A total of " & IpIsOn & " IP are online, while " & IpIsOff & " are offline.")