Skip to content

Commit

Permalink
Fixed: few bugs after refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Strizhechenko committed May 18, 2022
1 parent 90c7ab8 commit f30e06c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion netutils_linux_monitoring/base_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __repr_table__(self, table):
def default_init(self, topology=None):
BaseTop.__init__(self)
self.topology = topology
self.color = Color(self.topology)
# self.color = Color(self.topology, self.options.color)

def default_post_optparse(self):
if not self.topology:
Expand Down
13 changes: 7 additions & 6 deletions netutils_linux_monitoring/network_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,22 @@ def __repr_cpu(self):
'total', 'dropped', 'time_squeeze', 'cpu_collision', 'received_rps',
]
fields = [self.color.bright(word) for word in fields]
rows = self.__repr_cpu_make_rows(irqtop, network_output, softirq_top, softnet_stat_top)
rows = self.__repr_cpu_make_rows(irqtop, network_output, softirq_top)
table = make_table(fields, ['l'] + ['r'] * (len(fields) - 1), rows)
return self.color.wrap_header('Load per cpu:') + str(table)

def __repr_cpu_make_rows(self, irqtop, network_output, softirq_top, softnet_stat_top):
def __repr_cpu_make_rows(self, irqtop, network_output, softirq_top):
return [
[
self.color.wrap('CPU{0}'.format(stat.cpu), self.color.colorize_cpu(stat.cpu)),
irqtop.colorize_irq_per_cpu(irq),
softirq_top.colorize_net_rx(net_rx),
softirq_top.colorize_net_tx(net_tx),
softnet_stat_top.colorize_total(stat.total),
softnet_stat_top.colorize_dropped(stat.dropped),
softnet_stat_top.colorize_time_squeeze(stat.time_squeeze),
softnet_stat_top.colorize_cpu_collision(stat.cpu_collision),
# Теперь я вспомнил зачем там были семантичные функции, чтобы не было дублирования
self.color.colorize(stat.total, 300000, 900000),
self.color.colorize(stat.dropped, 1, 1),
self.color.colorize(stat.time_squeeze, 1, 300),
self.color.colorize(stat.cpu_collision, 1, 1000),
stat.received_rps
]
for irq, net_rx, net_tx, stat in network_output
Expand Down

0 comments on commit f30e06c

Please sign in to comment.