Automation

 View Only
  • 1.  Test vmkping within a cluster

    Posted Jun 15, 2021 03:00 PM

    due to a random issue we need to check the vmkping for the entire cluster.

    I found the below script on the internet, and I would like to know if it's possible to reconfigure it to test ping on all interfaces and collect report

     

    $esxcli = Get-EsxCli -VMHost (Get-VMHost "testesxihost") -V2

    $params = $esxcli.network.diag.ping.CreateArgs()

    $params.host = '10.1.1.2'

    $params.interface = 'vmk0'

    $params.size = '1472' #use 1472 for 1500 MTU or 8972 for 9000 MTU (VMware uses these values on MTU pings on ESXi)

    $res = $esxcli.network.diag.ping.Invoke($params) $res.summary



  • 2.  RE: Test vmkping within a cluster

    Posted Jun 15, 2021 04:03 PM

    You could do something like this.
    I use the IP address of the my station, but you can change that to any IP address you want.

     

     



  • 3.  RE: Test vmkping within a cluster

    Posted Jun 15, 2021 05:34 PM

    Thank you LucD

    it's working fine except that it's pinging only vmk2 and not able to get a report.

    it's possible to ping all vmkernel or no?



  • 4.  RE: Test vmkping within a cluster

    Posted Jun 15, 2021 05:56 PM

    My bad, I misplaced the closing curly brace for the inner loop.
    The code above is corrected.



  • 5.  RE: Test vmkping within a cluster

    Posted Jun 15, 2021 06:17 PM

    No issue LucD, now it's much better  

    it's pinging all interfaces which is perfect, unfortunately I tried in multiple way to have the output in csv without success

    also I would like to know

    the received argement is empty, is that OK?

    the number that I fing in lost it's in percentage?

    The RoundtripAvg it's the MTU Size?



  • 6.  RE: Test vmkping within a cluster
    Best Answer

    Posted Jun 15, 2021 06:51 PM

    You can just pipe the result to Export-Csv.
    No, my Received value shows the number of packets that were received back.
    If there is an issue with the interface than you could see values different from 0.
    The RoundTripAvg is time in 10-6 x seconds, or 10-3 x milliseconds.



  • 7.  RE: Test vmkping within a cluster

    Posted Jun 15, 2021 07:06 PM

    then for sure there's something wrong in our network as the received packet is empty  



  • 8.  RE: Test vmkping within a cluster

    Posted Jun 15, 2021 07:11 PM

    Then you probably forgot the pipeline symbol (|) on the the second to last line



  • 9.  RE: Test vmkping within a cluster

    Posted Oct 03, 2023 02:05 PM

    Is there a way of incorporating the line below into a loop, so the script looks up all vsan IP's - Filters on vmk2 (for us) on the defaulttcpipstack and reports back all ping tests from each host

    $esxcli.vsan.cluster.unicastagent.list.invoke() | select 'IPAddress'

    So the output would be from a 4 node cluster, each host would ping the other three nodes based on the unicast address and formatted in a table so we could highlight if one host was having an issue.

    The original idea came from a VMware engineer who ran the below script locally via SSH on all hosts in a cluster to identify intermittent packet drops that vsan and vrops didn't pick up on.

    for i in `localcli vsan cluster unicastagent list | grep true | awk '{ print $4}'`; do echo "pinging $i 3 times"; echo; vmkping -I vmk2 $i -s 8972 -d -c 500 -i .005 ; echo; echo "**************************"; done | grep -C 1 packet

    many thanks



  • 10.  RE: Test vmkping within a cluster

    Posted Oct 03, 2023 07:31 PM

    It is better to open a new thread as it is easier for the others to find the script.

    You can use the following script. If you need more parameters to be passed to the vmkping, feel free to add it.

     

     

     

     

     

     



  • 11.  RE: Test vmkping within a cluster

    Posted Oct 04, 2023 07:51 AM

    Amazing thankyou.