(self, netstat_output)
return metrics_by_interface
Return a mapping of network metrics by interface. For example:
            { interface:
                {'bytes_sent': 0,
                  'bytes_rcvd': 0,
                  'bytes_rcvd': 0,
                  ...
                }
            }
Return a mapping of network metrics by interface. For example:
            { interface:
                {'bytes_sent': 0,
                  'bytes_rcvd': 0,
                  'bytes_rcvd': 0,
                  ...
                }
            }
Return a mapping of network metrics by interface . For example : { interface : { bytes_sent : 0 bytes_rcvd : 0 bytes_rcvd : 0 ... } }
def _parse_solaris_netstat(self, netstat_output):
        """
        Return a mapping of network metrics by interface. For example:
            { interface:
                {'bytes_sent': 0,
                  'bytes_rcvd': 0,
                  'bytes_rcvd': 0,
                  ...
                }
            }
        """
        # Here's an example of the netstat output:
        #
        # link:0:net0:brdcstrcv   527336
        # link:0:net0:brdcstxmt   1595
        # link:0:net0:class       net
        # link:0:net0:collisions  0
        # link:0:net0:crtime      16359935.2637943
        # link:0:net0:ierrors     0
        # link:0:net0:ifspeed     10000000000
        # link:0:net0:ipackets    682834
        # link:0:net0:ipackets64  682834
        # link:0:net0:link_duplex 0
        # link:0:net0:link_state  1
        # link:0:net0:multircv    0
        # link:0:net0:multixmt    1595
        # link:0:net0:norcvbuf    0
        # link:0:net0:noxmtbuf    0
        # link:0:net0:obytes      12820668
        # link:0:net0:obytes64    12820668
        # link:0:net0:oerrors     0
        # link:0:net0:opackets    105445
        # link:0:net0:opackets64  105445
        # link:0:net0:rbytes      113983614
        # link:0:net0:rbytes64    113983614
        # link:0:net0:snaptime    16834735.1607669
        # link:0:net0:unknowns    0
        # link:0:net0:zonename    53aa9b7e-48ba-4152-a52b-a6368c3d9e7c
        # link:0:net1:brdcstrcv   4947620
        # link:0:net1:brdcstxmt   1594
        # link:0:net1:class       net
        # link:0:net1:collisions  0
        # link:0:net1:crtime      16359935.2839167
        # link:0:net1:ierrors     0
        # link:0:net1:ifspeed     10000000000
        # link:0:net1:ipackets    4947620
        # link:0:net1:ipackets64  4947620
        # link:0:net1:link_duplex 0
        # link:0:net1:link_state  1
        # link:0:net1:multircv    0
        # link:0:net1:multixmt    1594
        # link:0:net1:norcvbuf    0
        # link:0:net1:noxmtbuf    0
        # link:0:net1:obytes      73324
        # link:0:net1:obytes64    73324
        # link:0:net1:oerrors     0
        # link:0:net1:opackets    1594
        # link:0:net1:opackets64  1594
        # link:0:net1:rbytes      304384894
        # link:0:net1:rbytes64    304384894
        # link:0:net1:snaptime    16834735.1613302
        # link:0:net1:unknowns    0
        # link:0:net1:zonename    53aa9b7e-48ba-4152-a52b-a6368c3d9e7c

        # A mapping of solaris names -> datadog names
        metric_by_solaris_name = {
            'rbytes64': 'bytes_rcvd',
            'obytes64': 'bytes_sent',
            'ipackets64': 'packets_in.count',
            'ierrors': 'packets_in.error',
            'opackets64': 'packets_out.count',
            'oerrors': 'packets_out.error',
        }

        lines = [l for l in netstat_output.splitlines() if len(l) > 0]

        metrics_by_interface = {}

        for l in lines:
            # Parse the metric & interface.
            cols = l.split()
            link, n, iface, name = cols[0].split(":")
            assert link == "link"

            # Get the datadog metric name.
            ddname = metric_by_solaris_name.get(name, None)
            if ddname is None:
                continue

            # Add it to this interface's list of metrics.
            metrics = metrics_by_interface.get(iface, {})
            metrics[ddname] = self._parse_value(cols[1])
            metrics_by_interface[iface] = metrics

        return metrics_by_interface
def _parse_solaris_netstat ( self , netstat_output ) : # Here's an example of the netstat output: # # link:0:net0:brdcstrcv   527336 # link:0:net0:brdcstxmt   1595 # link:0:net0:class       net # link:0:net0:collisions  0 # link:0:net0:crtime      16359935.2637943 # link:0:net0:ierrors     0 # link:0:net0:ifspeed     10000000000 # link:0:net0:ipackets    682834 # link:0:net0:ipackets64  682834 # link:0:net0:link_duplex 0 # link:0:net0:link_state  1 # link:0:net0:multircv    0 # link:0:net0:multixmt    1595 # link:0:net0:norcvbuf    0 # link:0:net0:noxmtbuf    0 # link:0:net0:obytes      12820668 # link:0:net0:obytes64    12820668 # link:0:net0:oerrors     0 # link:0:net0:opackets    105445 # link:0:net0:opackets64  105445 # link:0:net0:rbytes      113983614 # link:0:net0:rbytes64    113983614 # link:0:net0:snaptime    16834735.1607669 # link:0:net0:unknowns    0 # link:0:net0:zonename    53aa9b7e-48ba-4152-a52b-a6368c3d9e7c # link:0:net1:brdcstrcv   4947620 # link:0:net1:brdcstxmt   1594 # link:0:net1:class       net # link:0:net1:collisions  0 # link:0:net1:crtime      16359935.2839167 # link:0:net1:ierrors     0 # link:0:net1:ifspeed     10000000000 # link:0:net1:ipackets    4947620 # link:0:net1:ipackets64  4947620 # link:0:net1:link_duplex 0 # link:0:net1:link_state  1 # link:0:net1:multircv    0 # link:0:net1:multixmt    1594 # link:0:net1:norcvbuf    0 # link:0:net1:noxmtbuf    0 # link:0:net1:obytes      73324 # link:0:net1:obytes64    73324 # link:0:net1:oerrors     0 # link:0:net1:opackets    1594 # link:0:net1:opackets64  1594 # link:0:net1:rbytes      304384894 # link:0:net1:rbytes64    304384894 # link:0:net1:snaptime    16834735.1613302 # link:0:net1:unknowns    0 # link:0:net1:zonename    53aa9b7e-48ba-4152-a52b-a6368c3d9e7c # A mapping of solaris names -> datadog names metric_by_solaris_name = { 'rbytes64' : 'bytes_rcvd' , 'obytes64' : 'bytes_sent' , 'ipackets64' : 'packets_in.count' , 'ierrors' : 'packets_in.error' , 'opackets64' : 'packets_out.count' , 'oerrors' : 'packets_out.error' , } lines = [ l for l in netstat_output . splitlines ( ) if len ( l ) > 0 ] metrics_by_interface = { } for l in lines : # Parse the metric & interface. cols = l . split ( ) link , n , iface , name = cols [ 0 ] . split ( ":" ) assert link == "link" # Get the datadog metric name. ddname = metric_by_solaris_name . get ( name , None ) if ddname is None : continue # Add it to this interface's list of metrics. metrics = metrics_by_interface . get ( iface , { } ) metrics [ ddname ] = self . _parse_value ( cols [ 1 ] ) metrics_by_interface [ iface ] = metrics return metrics_by_interface