Esempio n. 1
0
    def __init__(self, argv=(), env={}, debug=False):
        """Populate Munin Plugin with MuninGraph instances.
        
        @param argv:  List of command line arguments.
        @param env:   Dictionary of environment variables.
        @param debug: Print debugging messages if True. (Default: False)
        
        """
        MuninPlugin.__init__(self, argv, env, debug)

        self.envRegisterFilter('ifaces', '^[\w\d:]+$')

        self._ifaceInfo = NetIfaceInfo()
        self._ifaceStats = self._ifaceInfo.getIfStats()
        self._ifaceList = []
        for iface in list(self._ifaceStats):
            if iface not in [
                    'lo',
            ] and self.ifaceIncluded(iface):
                if max(self._ifaceStats[iface].values()) > 0:
                    self._ifaceList.append(iface)
        self._ifaceList.sort()

        for iface in self._ifaceList:
            if self.graphEnabled('netiface_traffic'):
                graph = MuninGraph(
                    'Network Interface - Traffic - %s' % iface,
                    'Network',
                    info='Traffic Stats for Network Interface %s in bps.' %
                    iface,
                    args='--base 1000 --lower-limit 0',
                    vlabel='bps in (-) / out (+) per second')
                graph.addField('rx',
                               'bps',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('tx',
                               'bps',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rx')
                self.appendGraph('netiface_traffic_%s' % iface, graph)

            if self.graphEnabled('netiface_errors'):
                graph = MuninGraph(
                    'Network Interface - Errors - %s' % iface,
                    'Network',
                    info='Error Stats for Network Interface %s in errors/sec.'
                    % iface,
                    args='--base 1000 --lower-limit 0',
                    vlabel='errors in (-) / out (+) per second')
                graph.addField('rxerrs',
                               'errors',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txerrs',
                               'errors',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxerrs',
                               info='Rx(-)/Tx(+) Errors per second.')
                graph.addField('rxframe',
                               'frm/crr',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txcarrier',
                               'frm/crr',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxframe',
                               info='Frame(-)/Carrier(+) Errors per second.')
                graph.addField('rxdrop',
                               'drop',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txdrop',
                               'drop',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxdrop',
                               info='Rx(-)/Tx(+) Dropped Packets per second.')
                graph.addField('rxfifo',
                               'fifo',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               graph=False)
                graph.addField('txfifo',
                               'fifo',
                               draw='LINE2',
                               type='DERIVE',
                               min=0,
                               negative='rxfifo',
                               info='Rx(-)/Tx(+) FIFO Errors per second.')
                self.appendGraph('netiface_errors_%s' % iface, graph)