Exemple #1
0
    def format(self, details=False, stats=False, nodev=False, indent=''):
        """Return address as formatted text"""
        fmt = util.MyFormatter(self, indent)

        buf = fmt.format('{a|local!b}')

        if not nodev:
            buf += fmt.format(' {a|ifindex}')

        buf += fmt.format(' {a|scope}')

        if self.label:
            buf += fmt.format(' "{a|label}"')

        buf += fmt.format(' <{a|_flags}>')

        if details:
            buf += fmt.nl('\t{t|broadcast} {t|multicast}') \
                 + fmt.nl('\t{t|peer} {t|anycast}')

            if self.valid_lifetime:
                buf += fmt.nl('\t{s|valid-lifetime!k} '\
                       '{a|valid_lifetime}')

            if self.preferred_lifetime:
                buf += fmt.nl('\t{s|preferred-lifetime!k} '\
                       '{a|preferred_lifetime}')

        if stats and (self.create_time or self.last_update):
            buf += self.nl('\t{s|created!k} {a|create_time}'\
                   ' {s|last-updated!k} {a|last_update}')

        return buf
Exemple #2
0
	def brief(self):
		fmt = util.MyFormatter(self)

		ret = ' {s|default-class!k} {a|default_class}'

                if self.r2q:
                        ret += ' {s|r2q!k} {a|r2q}'

                return fmt.format(ret)
Exemple #3
0
        def brief(self):
		fmt = util.MyFormatter(self)

		ret = ' {t|prio} {t|rate}'

                if self.rate != self.ceil:
                        ret += ' {s|borrow-up-to!k} {a|ceil}'

                ret += ' {t|burst}'

                return fmt.format(ret)
Exemple #4
0
    def format(self,
               details=False,
               stats=False,
               nodev=False,
               noparent=False,
               indent=''):
        """Return class as formatted text"""
        fmt = util.MyFormatter(self, indent)

        buf = fmt.format(self.brief('class', nodev, noparent))

        if details:
            buf += fmt.nl('\t' + self.details())

        return buf
Exemple #5
0
    def format(self, details=False, stats=False, indent=''):
        """Return link as formatted text"""
        buf = "Src:" + str(self.src) + ", dst:" + str(self.dst)

        fmt = util.MyFormatter(self, indent)

        #{a|gw}
        buf = fmt.format('{a|ifindex} {a|dst} ')
        #          )
        # #'{a|_state} <{a|_flags}> {a|_brief}'

        # if details:
        #     buf += fmt.nl('\t{t|mtu} {t|txqlen} {t|weight} '\
        #               '{t|qdisc} {t|operstate}')
        #     buf += fmt.nl('\t{t|broadcast} {t|alias}')

        #     buf += self._foreach_af('details', fmt)

        #     buf += '\n\t%s%s%s%s\n' % (33 * ' ', util.title('RX'),
        #                    15 * ' ', util.title('TX'))

        return buf
Exemple #6
0
    def format(self, details=False, stats=False, indent=''):
        """Return link as formatted text"""
        fmt = util.MyFormatter(self, indent)

        buf = fmt.format('{a|ifindex} {a|name} {a|arptype} {a|address} '\
                         '{a|_state} <{a|_flags}> {a|_brief}')

        if details:
            buf += fmt.nl('\t{t|mtu} {t|txqlen} {t|weight} '\
                   '{t|qdisc} {t|operstate}')
            buf += fmt.nl('\t{t|broadcast} {t|alias}')

            buf += self._foreach_af('details', fmt)

        if stats:
            l = [['Packets', RX_PACKETS, TX_PACKETS],
                 ['Bytes', RX_BYTES, TX_BYTES],
                 ['Errors', RX_ERRORS, TX_ERRORS],
                 ['Dropped', RX_DROPPED, TX_DROPPED],
                 ['Compressed', RX_COMPRESSED, TX_COMPRESSED],
                 ['FIFO Errors', RX_FIFO_ERR, TX_FIFO_ERR],
                 ['Length Errors', RX_LEN_ERR, None],
                 ['Over Errors', RX_OVER_ERR, None],
                 ['CRC Errors', RX_CRC_ERR, None],
                 ['Frame Errors', RX_FRAME_ERR, None],
                 ['Missed Errors', RX_MISSED_ERR, None],
                 ['Abort Errors', None, TX_ABORT_ERR],
                 ['Carrier Errors', None, TX_CARRIER_ERR],
                 ['Heartbeat Errors', None, TX_HBEAT_ERR],
                 ['Window Errors', None, TX_WIN_ERR],
                 ['Collisions', None, COLLISIONS],
                 ['Multicast', None, MULTICAST], ['', None, None],
                 ['Ipv6:', None, None], ['Packets', IP6_INPKTS, IP6_OUTPKTS],
                 ['Bytes', IP6_INOCTETS, IP6_OUTOCTETS],
                 ['Discards', IP6_INDISCARDS, IP6_OUTDISCARDS],
                 ['Multicast Packets', IP6_INMCASTPKTS, IP6_OUTMCASTPKTS],
                 ['Multicast Bytes', IP6_INMCASTOCTETS, IP6_OUTMCASTOCTETS],
                 ['Broadcast Packets', IP6_INBCASTPKTS, IP6_OUTBCASTPKTS],
                 ['Broadcast Bytes', IP6_INBCASTOCTETS, IP6_OUTBCASTOCTETS],
                 ['Delivers', IP6_INDELIVERS, None],
                 ['Forwarded', None, IP6_OUTFORWDATAGRAMS],
                 ['No Routes', IP6_INNOROUTES, IP6_OUTNOROUTES],
                 ['Header Errors', IP6_INHDRERRORS, None],
                 ['Too Big Errors', IP6_INTOOBIGERRORS, None],
                 ['Address Errors', IP6_INADDRERRORS, None],
                 ['Unknown Protocol', IP6_INUNKNOWNPROTOS, None],
                 ['Truncated Packets', IP6_INTRUNCATEDPKTS, None],
                 ['Reasm Timeouts', IP6_REASMTIMEOUT, None],
                 ['Reasm Requests', IP6_REASMREQDS, None],
                 ['Reasm Failures', IP6_REASMFAILS, None],
                 ['Reasm OK', IP6_REASMOKS, None],
                 ['Frag Created', None, IP6_FRAGCREATES],
                 ['Frag Failures', None, IP6_FRAGFAILS],
                 ['Frag OK', None, IP6_FRAGOKS], ['', None, None],
                 ['ICMPv6:', None, None],
                 ['Messages', ICMP6_INMSGS, ICMP6_OUTMSGS],
                 ['Errors', ICMP6_INERRORS, ICMP6_OUTERRORS]]

            buf += '\n\t%s%s%s%s\n' % (33 * ' ', util.title('RX'), 15 * ' ',
                                       util.title('TX'))

            for row in l:
                row[0] = util.kw(row[0])
                row[1] = self.get_stat(row[1]) if row[1] else ''
                row[2] = self.get_stat(row[2]) if row[2] else ''
                buf += '\t{0:27} {1:>16} {2:>16}\n'.format(*row)

            buf += self._foreach_af('stats')

        return buf
Exemple #7
0
    def format(self,
               details=False,
               stats=False,
               nodev=False,
               noparent=False,
               indent=''):
        """Return qdisc as formatted text"""
        fmt = util.MyFormatter(self, indent)

        buf = fmt.format(self.brief('qdisc', nodev, noparent))

        if details:
            buf += fmt.nl('\t' + self.details())

        if stats:
            buf += self.stats(fmt)

#		if stats:
#			l = [['Packets', RX_PACKETS, TX_PACKETS],
#			     ['Bytes', RX_BYTES, TX_BYTES],
#			     ['Errors', RX_ERRORS, TX_ERRORS],
#			     ['Dropped', RX_DROPPED, TX_DROPPED],
#			     ['Compressed', RX_COMPRESSED, TX_COMPRESSED],
#			     ['FIFO Errors', RX_FIFO_ERR, TX_FIFO_ERR],
#			     ['Length Errors', RX_LEN_ERR, None],
#			     ['Over Errors', RX_OVER_ERR, None],
#			     ['CRC Errors', RX_CRC_ERR, None],
#			     ['Frame Errors', RX_FRAME_ERR, None],
#			     ['Missed Errors', RX_MISSED_ERR, None],
#			     ['Abort Errors', None, TX_ABORT_ERR],
#			     ['Carrier Errors', None, TX_CARRIER_ERR],
#			     ['Heartbeat Errors', None, TX_HBEAT_ERR],
#			     ['Window Errors', None, TX_WIN_ERR],
#			     ['Collisions', None, COLLISIONS],
#			     ['Multicast', None, MULTICAST],
#			     ['', None, None],
#			     ['Ipv6:', None, None],
#			     ['Packets', IP6_INPKTS, IP6_OUTPKTS],
#			     ['Bytes', IP6_INOCTETS, IP6_OUTOCTETS],
#			     ['Discards', IP6_INDISCARDS, IP6_OUTDISCARDS],
#			     ['Multicast Packets', IP6_INMCASTPKTS, IP6_OUTMCASTPKTS],
#			     ['Multicast Bytes', IP6_INMCASTOCTETS, IP6_OUTMCASTOCTETS],
#			     ['Broadcast Packets', IP6_INBCASTPKTS, IP6_OUTBCASTPKTS],
#			     ['Broadcast Bytes', IP6_INBCASTOCTETS, IP6_OUTBCASTOCTETS],
#			     ['Delivers', IP6_INDELIVERS, None],
#			     ['Forwarded', None, IP6_OUTFORWDATAGRAMS],
#			     ['No Routes', IP6_INNOROUTES, IP6_OUTNOROUTES],
#			     ['Header Errors', IP6_INHDRERRORS, None],
#			     ['Too Big Errors', IP6_INTOOBIGERRORS, None],
#			     ['Address Errors', IP6_INADDRERRORS, None],
#			     ['Unknown Protocol', IP6_INUNKNOWNPROTOS, None],
#			     ['Truncated Packets', IP6_INTRUNCATEDPKTS, None],
#			     ['Reasm Timeouts', IP6_REASMTIMEOUT, None],
#			     ['Reasm Requests', IP6_REASMREQDS, None],
#			     ['Reasm Failures', IP6_REASMFAILS, None],
#			     ['Reasm OK', IP6_REASMOKS, None],
#			     ['Frag Created', None, IP6_FRAGCREATES],
#			     ['Frag Failures', None, IP6_FRAGFAILS],
#			     ['Frag OK', None, IP6_FRAGOKS],
#			     ['', None, None],
#			     ['ICMPv6:', None, None],
#			     ['Messages', ICMP6_INMSGS, ICMP6_OUTMSGS],
#			     ['Errors', ICMP6_INERRORS, ICMP6_OUTERRORS]]
#
#			buf += '\n\t%s%s%s%s\n' % (33 * ' ', util.title('RX'),
#                        			   15 * ' ', util.title('TX'))
#
#			for row in l:
#				row[0] = util.kw(row[0])
#                                row[1] = self.get_stat(row[1]) if row[1] else ''
#                                row[2] = self.get_stat(row[2]) if row[2] else ''
#				buf += '\t{0:27} {1:>16} {2:>16}\n'.format(*row)

        return buf
Exemple #8
0
	def details(self):
		fmt = util.MyFormatter(self)

                return fmt.nl('\t{t|level} {t|quantum}')