# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


import sys
import time
import re
from collectors.lib import utils
                    eth?\d+ |
                    em\d+_\d+/\d+ | em\d+_\d+ | em\d+ |
                    p\d+p\d+_\d+/\d+ | p\d+p\d+_\d+ | p\d+p\d+ |
                    (?:   # Start of 'predictable network interface names'
                        (?:en|sl|wl|ww)
                        (?:
                            b\d+ |           # BCMA bus
                            c[0-9a-f]+ |     # CCW bus group
                            o\d+(?:d\d+)? |  # On-board device
                            s\d+(?:f\d+)?(?:d\d+)? |  # Hotplug slots
                            x[0-9a-f]+ |     # Raw MAC address
                            p\d+s\d+(?:f\d+)?(?:d\d+)? | # PCI geographic loc
                            p\d+s\d+(?:f\d+)?(?:u\d+)*(?:c\d+)?(?:i\d+)? # USB
                         )
                    )
                ):(.*)''', line, re.VERBOSE)
            if not m:
                continue
            intf = m.group(1)
            stats = m.group(2).split(None)

            def direction(i):
                if i >= 8:
                    return "out"
                return "in"
            for i in range(16):
                print("proc.net.%s %d %s iface=%s direction=%s"
                      % (FIELDS[i], ts, stats[i], intf, direction(i)))

        sys.stdout.flush()

# Path: collectors/lib/utils.py
# PY3 = sys.version_info[0] > 2
# USER = "nobody"
# def drop_privileges(user=USER):
# def is_sockfile(path):
# def err(msg):
#     def is_numeric(value):
#     def is_numeric(value):


# Path: collectors/0/ifstat.py
import sys
import time
import re
from collectors.lib import utils

                    eth?\d+ |
                    em\d+_\d+/\d+ | em\d+_\d+ | em\d+ |
                    p\d+p\d+_\d+/\d+ | p\d+p\d+_\d+ | p\d+p\d+ |
                    (?:   # Start of 'predictable network interface names'
                        (?:en|sl|wl|ww)
                        (?:
                            b\d+ |           # BCMA bus
                            c[0-9a-f]+ |     # CCW bus group
                            o\d+(?:d\d+)? |  # On-board device
                            s\d+(?:f\d+)?(?:d\d+)? |  # Hotplug slots
                            x[0-9a-f]+ |     # Raw MAC address
                            p\d+s\d+(?:f\d+)?(?:d\d+)? | # PCI geographic loc
                            p\d+s\d+(?:f\d+)?(?:u\d+)*(?:c\d+)?(?:i\d+)? # USB
                         )
                    )
                ):(.*)''', line, re.VERBOSE)
            if not m:
                continue
            intf = m.group(1)
            stats = m.group(2).split(None)

            def direction(i):
                if i >= 8:
                    return "out"
                return "in"
            for i in range(16):
                print("proc.net.%s %d %s iface=%s direction=%s"
                      % (FIELDS[i], ts, stats[i], intf, direction(i)))

        sys.stdout.flush()

        time.sleep(interval)