Use the following command to capture PTP-related information from the worker node VM:

vm_ptp_info.sh

Sample output:

#!/bin/bash
# Copyright (c) 2023 VMware, Inc. All rights reserved.
 
# Check if interface and timeout value are provided as arguments
if [ $# -ne 2 ]; then
  echo "Usage: $0 <interface> <timeout in seconds>"
  exit 1
fi
 
interface=$1
timeout=$2
 
# Create a directory to store output files
outdir="ptp_logs_$(date +%Y%m%d_%H%M%S)"
mkdir $outdir
cd $outdir
 
# Output file name
output_file="ptp_info_$hostname_$(date +%Y-%m-%d_%H-%M-%S).txt"
 
 
echo -e "\n============================================================" >> "$output_file"
# Display information about the iavf driver module,
echo "$(date +"%Y-%m-%d %T") - Displaying information about the iavf driver module..." >> "$output_file"
sudo modinfo iavf >> "$output_file"
 
echo -e "\n============================================================" >> "$output_file"
# Retrieve system Uptime information
echo "$(date +"%Y-%m-%d %T") - Retrieving system Uptime..." >> "$output_file"
sudo uptime >> "$output_file"
 
echo -e "\n============================================================" >> "$output_file"
# Retrieve the current time value of the PHC device at /dev/ptp0
echo "$(date +"%Y-%m-%d %T") - Retrieving the current time value of the PHC device..." >> "$output_file"
devices=$(sudo find /dev -name 'ptp*')
# Check if any devices are found
if [ -n "$devices" ]; then
    echo "Devices starting with 'ptp' found:" >> "$output_file"
    echo "$devices" >> "$output_file"
 
    # Iterate over the list of devices and execute the command
    for device in $devices; do
        echo "Executing phc_ctl $device get:" >> "$output_file"
        phc_ctl "$device" get >> "$output_file"
        echo "-------------------------------------" >> "$output_file"
    done
else
    echo "No devices starting with 'ptp' found." >> "$output_file"
fi
 
echo -e "\n============================================================" >> "$output_file"
# Retrieve the current vmware-tools timesync setting
echo "$(date +"%Y-%m-%d %T") - Retrieving the current vmware-tools timesync setting..." >> "$output_file"
sudo sudo vmware-toolbox-cmd timesync status >> "$output_file"
 
echo -e "\n============================================================" >> "$output_file"
# Display the PTP hardware clock characteristics for the specified network interface
echo "$(date +"%Y-%m-%d %T") - Displaying the PTP hardware clock characteristics..." >> "$output_file"
sudo ethtool -T "$interface" >> "$output_file"
 
echo -e "\n============================================================" >> "$output_file"
# Capture ptp4l service status
echo "$(date +"%Y-%m-%d %T") - Displaying ptp4l service status..." >> "$output_file"
sudo systemctl status ptp4l >> "$output_file"
 
echo -e "\n============================================================" >> "$output_file"
# Capture phc2sys service status
echo "$(date +"%Y-%m-%d %T") - Displaying phc2sys service status..." >> "$output_file"
sudo systemctl status phc2sys >> "$output_file"
 
echo -e "\n============================================================" >> "$output_file"
# Capture journalctl logs for ptp4l service since boot
filename="ptp4l_journalctl_logs_$(date +%Y%m%d_%H%M%S).txt"
echo "$(date +"%Y-%m-%d %T") - Capturing ptp4l journalctl logs in $filename" >> "$output_file"
sudo journalctl -u ptp4l.service --boot >> $filename
 
echo -e "\n============================================================" >> "$output_file"
# Capture journalctl logs for phc2sys service since boot
filename="phc2sys_journalctl_logs_$(date +%Y%m%d_%H%M%S).txt"
echo "$(date +"%Y-%m-%d %T") - Capturing phc2sys journalctl logs in $filename" >> "$output_file"
sudo journalctl -u phc2sys.service --boot >> $filename
 
echo -e "\n============================================================" >> "$output_file"
# Run tcpdump for the specified timeout period to capture network traffic on the specified interface
tcpdump_file="tcpdump_${interface}_$(date +%Y-%m-%d_%H-%M-%S).pcap"
echo "$(date +"%Y-%m-%d %T") - Running tcpdump to capture network traffic on $interface interface for $timeout seconds..." >> "$output_file"
sudo timeout "$timeout"s tcpdump -i "$interface" ether proto 0x88f7 -w "$tcpdump_file"
echo "$(date +"%Y-%m-%d %T") - Completed tcpdump capture." >> "$output_file"
 
echo -e "\n============================================================" >> "$output_file"
# Create a tar file of the output directory
tar_file="ptp_logs_$(date +%Y-%m-%d_%H-%M-%S).tar.gz"
echo -e "Creating tar file $tar_file of the artifacts collected"
cd ..
sudo tar -czvf $tar_file $outdir
 
# Remove the output directory
rm -rf $outdir