I'm writing a python script with the psutil module that monitors some of the running specs of my web servers, for example cpu usage, memory usage and disk usage. One information I want to get from the script is all the ip addresses associated with my network interface cards.
This is how I do it:
import psutil
ifcs = psutil.net_if_addrs()
IPs = []
for ifc in ifcs:
for snic in ifcs[ifc]:
IPs.append(snic.address)
My question is, what is the snic object refering to in the real world? It seems that each physical network card has a few snics attached to it. If I only want to get the snics with the IPv4 address, as those were the ones in real usage, how do I do it?
Thank you.