mirror of https://github.com/nicolargo/glances
Job done for plugins IRQ, RAID, Folders and Port
parent
09281ae72e
commit
da5bb38d47
|
@ -99,25 +99,29 @@ class Plugin(GlancesPlugin):
|
|||
if not self.stats or self.is_disable():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
# Max size for the interface name
|
||||
name_max_width = max_width - 7
|
||||
|
||||
# Header
|
||||
msg = '{}'.format('FOLDERS')
|
||||
msg = '{:{width}}'.format('FOLDERS',
|
||||
width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
|
||||
# Data
|
||||
for i in self.stats:
|
||||
ret.append(self.curse_new_line())
|
||||
if len(i['path']) > 15:
|
||||
if len(i['path']) > name_max_width:
|
||||
# Cut path if it is too long
|
||||
path = '_' + i['path'][-15 + 1:]
|
||||
path = '_' + i['path'][-name_max_width + 1:]
|
||||
else:
|
||||
path = i['path']
|
||||
msg = '{:<16} '.format(path)
|
||||
msg = '{:{width}}'.format(path,
|
||||
width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
try:
|
||||
msg = '{:>6}'.format(self.auto_unit(i['size']))
|
||||
msg = '{:>9}'.format(self.auto_unit(i['size']))
|
||||
except (TypeError, ValueError):
|
||||
msg = '{:>6}'.format(i['size'])
|
||||
msg = '{:>9}'.format(i['size'])
|
||||
ret.append(self.curse_add_line(msg, self.get_alert(i)))
|
||||
|
||||
return ret
|
||||
|
|
|
@ -92,23 +92,22 @@ class Plugin(GlancesPlugin):
|
|||
if not LINUX or not self.stats or not self.args.enable_irq:
|
||||
return ret
|
||||
|
||||
if max_width is not None and max_width >= 23:
|
||||
irq_max_width = max_width - 14
|
||||
else:
|
||||
irq_max_width = 9
|
||||
# Max size for the interface name
|
||||
name_max_width = max_width - 7
|
||||
|
||||
# Build the string message
|
||||
# Header
|
||||
msg = '{:{width}}'.format('IRQ', width=irq_max_width)
|
||||
msg = '{:{width}}'.format('IRQ', width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
msg = '{:>14}'.format('Rate/s')
|
||||
msg = '{:>9}'.format('Rate/s')
|
||||
ret.append(self.curse_add_line(msg))
|
||||
|
||||
for i in self.stats:
|
||||
ret.append(self.curse_new_line())
|
||||
msg = '{:<15}'.format(i['irq_line'][:15])
|
||||
msg = '{:{width}}'.format(i['irq_line'][:name_max_width],
|
||||
width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
msg = '{:>8}'.format(str(i['irq_rate']))
|
||||
msg = '{:>9}'.format(str(i['irq_rate']))
|
||||
ret.append(self.curse_add_line(msg))
|
||||
|
||||
return ret
|
||||
|
|
|
@ -132,6 +132,9 @@ class Plugin(GlancesPlugin):
|
|||
if not self.stats or args.disable_ports:
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
name_max_width = max_width - 7
|
||||
|
||||
# Build the string message
|
||||
for p in self.stats:
|
||||
if 'host' in p:
|
||||
|
@ -147,13 +150,15 @@ class Plugin(GlancesPlugin):
|
|||
# Convert second to ms
|
||||
status = '{0:.0f}ms'.format(p['status'] * 1000.0)
|
||||
|
||||
msg = '{:14.14} '.format(p['description'])
|
||||
msg = '{:{width}}'.format(p['description'][0:name_max_width],
|
||||
width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
msg = '{:>8}'.format(status)
|
||||
msg = '{:>9}'.format(status)
|
||||
ret.append(self.curse_add_line(msg, self.get_ports_alert(p)))
|
||||
ret.append(self.curse_new_line())
|
||||
elif 'url' in p:
|
||||
msg = '{:14.14} '.format(p['description'])
|
||||
msg = '{:{width}}'.format(p['description'][0:name_max_width],
|
||||
width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
if isinstance(p['status'], numbers.Number):
|
||||
status = 'Code {}'.format(p['status'])
|
||||
|
@ -161,7 +166,7 @@ class Plugin(GlancesPlugin):
|
|||
status = 'Scanning'
|
||||
else:
|
||||
status = p['status']
|
||||
msg = '{:>8}'.format(status)
|
||||
msg = '{:>9}'.format(status)
|
||||
ret.append(self.curse_add_line(msg, self.get_web_alert(p)))
|
||||
ret.append(self.curse_new_line())
|
||||
|
||||
|
|
|
@ -60,6 +60,9 @@ class Plugin(GlancesPlugin):
|
|||
if self.input_method == 'local':
|
||||
# Update stats using the PyMDstat lib (https://github.com/nicolargo/pymdstat)
|
||||
try:
|
||||
# Just for test
|
||||
# mds = MdStat(path='~/dev/pymdstat/tests/mdstat.02')
|
||||
# Note: replace 02 by 02 ==> 09
|
||||
mds = MdStat()
|
||||
self.stats = mds.get_stats()['arrays']
|
||||
except Exception as e:
|
||||
|
@ -82,13 +85,16 @@ class Plugin(GlancesPlugin):
|
|||
if not self.stats:
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
# Max size for the interface name
|
||||
name_max_width = max_width - 12
|
||||
|
||||
# Header
|
||||
msg = '{:11}'.format('RAID disks')
|
||||
msg = '{:{width}}'.format('RAID disks',
|
||||
width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
msg = '{:>6}'.format('Used')
|
||||
msg = '{:>7}'.format('Used')
|
||||
ret.append(self.curse_add_line(msg))
|
||||
msg = '{:>6}'.format('Avail')
|
||||
msg = '{:>7}'.format('Avail')
|
||||
ret.append(self.curse_add_line(msg))
|
||||
# Data
|
||||
arrays = sorted(iterkeys(self.stats))
|
||||
|
@ -99,12 +105,15 @@ class Plugin(GlancesPlugin):
|
|||
status = self.raid_alert(self.stats[array]['status'], self.stats[array]['used'], self.stats[array]['available'])
|
||||
# Data: RAID type name | disk used | disk available
|
||||
array_type = self.stats[array]['type'].upper() if self.stats[array]['type'] is not None else 'UNKNOWN'
|
||||
msg = '{:<5}{:>6}'.format(array_type, array)
|
||||
# Build the full name = array type + array name
|
||||
full_name = '{} {}'.format(array_type, array)
|
||||
msg = '{:{width}}'.format(full_name,
|
||||
width=name_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
if self.stats[array]['status'] == 'active':
|
||||
msg = '{:>6}'.format(self.stats[array]['used'])
|
||||
msg = '{:>7}'.format(self.stats[array]['used'])
|
||||
ret.append(self.curse_add_line(msg, status))
|
||||
msg = '{:>6}'.format(self.stats[array]['available'])
|
||||
msg = '{:>7}'.format(self.stats[array]['available'])
|
||||
ret.append(self.curse_add_line(msg, status))
|
||||
elif self.stats[array]['status'] == 'inactive':
|
||||
ret.append(self.curse_new_line())
|
||||
|
|
|
@ -169,11 +169,7 @@ class Plugin(GlancesPlugin):
|
|||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
if max_width is not None and max_width >= 23:
|
||||
# Interface size name = max_width - space for encyption + quality
|
||||
ifname_max_width = max_width - 5
|
||||
else:
|
||||
ifname_max_width = 16
|
||||
ifname_max_width = max_width - 5
|
||||
|
||||
# Build the string message
|
||||
# Header
|
||||
|
@ -198,7 +194,8 @@ class Plugin(GlancesPlugin):
|
|||
if len(hotspotname) > ifname_max_width:
|
||||
hotspotname = '_' + hotspotname[-ifname_max_width + 1:]
|
||||
# Add the new hotspot to the message
|
||||
msg = '{:{width}}'.format(hotspotname, width=ifname_max_width)
|
||||
msg = '{:{width}}'.format(hotspotname,
|
||||
width=ifname_max_width)
|
||||
ret.append(self.curse_add_line(msg))
|
||||
msg = '{:>7}'.format(i['signal'], width=ifname_max_width)
|
||||
ret.append(self.curse_add_line(msg,
|
||||
|
|
Loading…
Reference in New Issue