# Function to find IRQ number for a given network interface
find_irq_number() {
local iface=$1
grep -i “$iface-0” /proc/interrupts | awk ‘{print $1}’ | sed ‘s/://’
}
# Main diagnostics function with enhanced debug output
system_diagnostics() {
echo “=========================================”
echo “System Diagnostics and Maintenance Script”
echo “=========================================”
# Print current date and time
echo “Current Date and Time: $(date)”
# Output current IRQ bindings to CPUs for each network interface
echo “Current IRQ Bindings to CPUs for Network Interfaces:”
for iface in $(ip -o link show | awk -F’: ‘ ‘{print $2}’); do
irq_num=$(find_irq_number “$iface”)
echo “Interface: $iface, IRQ Number: ${irq_num:-Not found}”
if [ -n “$irq_num” ]; then
affinity=$(cat /proc/irq/$irq_num/smp_affinity_list 2>/dev/null)
if [ -n “$affinity” ]; then
echo “Interface $iface (IRQ $irq_num) is bound to CPU(s): $affinity”
else
echo “Interface $iface (IRQ $irq_num) has no affinity set or smp_affinity_list not accessible.”
fi
else
echo “No IRQ binding found for interface $iface.”
fi
done
echo “=========================================”
# Display highest CPUs on each socket for each NUMA node
echo “Highest CPUs on sockets for each NUMA node:”
lscpu -e=cpu,node,socket | sort -t’,’ -k2,2n -k3,3n -u | awk ‘{print “Socket “$3”, Node “$2”: CPU “$1}’
echo “=========================================”
}
# Call the diagnostics function
system_diagnostics