def main():
    interval = COLLECTION_INTERVAL

    # Scalyr edit:
    network_interface_prefixes = str.split(NETWORK_INTERFACE_PREFIX, ',')
    for i in range(len(network_interface_prefixes)):
        network_interface_prefixes[i] = network_interface_prefixes[i].strip()

    f_netdev = open("/proc/net/dev", "r")

    # We just care about ethN interfaces.  We specifically
    # want to avoid bond interfaces, because interface
    # stats are still kept on the child interfaces when
    # you bond.  By skipping bond we avoid double counting.
    while True:
        # Scalyr edit to add in check for parent.  A ppid of 1 means our parent has died.
        if os.getppid() == 1:
            sys.exit(1)

        f_netdev.seek(0)
        ts = int(time.time())
        for line in f_netdev:
            # Scalyr edit
            for interface in network_interface_prefixes:
                m = re.match("\s+(%s\d+):(.*)" % interface, line)
                if m:
                    break
            if not m:
                continue
            stats = m.group(2).split(None)
            for i in range(8):
                if FIELDS[i]:
                    print ("proc.net.%s %d %s iface=%s direction=in"
                           % (FIELDS[i], ts, stats[i], m.group(1)))
                    print ("proc.net.%s %d %s iface=%s direction=out"
                           % (FIELDS[i], ts, stats[i+8], m.group(1)))

        sys.stdout.flush()
        time.sleep(interval)
ifstat main loop
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/third_party/tcollector/collectors/0/ifstat.py/main