mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-21 08:11:39 +03:00
Add network
This commit is contained in:
parent
dad4d2846d
commit
1865384954
@ -49,7 +49,7 @@ class GlancesStdoutFieldsDescription(object):
|
|||||||
print('Restfull/API plugins documentation')
|
print('Restfull/API plugins documentation')
|
||||||
print('==================================')
|
print('==================================')
|
||||||
print('')
|
print('')
|
||||||
print('The Glanes Restfull/API server could be ran using the following command line:')
|
print('The Glances Restfull/API server could be ran using the following command line:')
|
||||||
print('')
|
print('')
|
||||||
print('.. code-block:: bash')
|
print('.. code-block:: bash')
|
||||||
print('')
|
print('')
|
||||||
@ -70,7 +70,12 @@ class GlancesStdoutFieldsDescription(object):
|
|||||||
print('.. code-block:: json')
|
print('.. code-block:: json')
|
||||||
print('')
|
print('')
|
||||||
print(' # curl http://localhost:61208/api/3/{}'.format(plugin))
|
print(' # curl http://localhost:61208/api/3/{}'.format(plugin))
|
||||||
print(' ' + pformat(stats._plugins[plugin].get_export()).replace('\n', '\n '))
|
stat = stats._plugins[plugin].get_export()
|
||||||
|
if isinstance(stat, list) and len(stat) > 1:
|
||||||
|
# Only display two first items
|
||||||
|
print(' ' + pformat(stat[0:2]).replace('\n', '\n '))
|
||||||
|
else:
|
||||||
|
print(' ' + pformat(stat).replace('\n', '\n '))
|
||||||
print('')
|
print('')
|
||||||
else:
|
else:
|
||||||
logger.error('No fields_description variable defined for plugin {}'.format(plugin))
|
logger.error('No fields_description variable defined for plugin {}'.format(plugin))
|
||||||
|
@ -29,6 +29,36 @@ from glances.logger import logger
|
|||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
|
# {'interface_name': 'mpqemubr0-dummy',
|
||||||
|
# 'alias': None,
|
||||||
|
# 'time_since_update': 2.081636428833008,
|
||||||
|
# 'cumulative_rx': 0,
|
||||||
|
# 'rx': 0, 'cumulative_tx': 0, 'tx': 0, 'cumulative_cx': 0, 'cx': 0,
|
||||||
|
# 'is_up': False,
|
||||||
|
# 'speed': 0,
|
||||||
|
# 'key': 'interface_name'}
|
||||||
|
# Fields description
|
||||||
|
fields_description = {
|
||||||
|
'interface_name': {'description': 'Interface name.',
|
||||||
|
'unit': 'string'},
|
||||||
|
'alias': {'description': 'Interface alias name (optional).',
|
||||||
|
'unit': 'string'},
|
||||||
|
'rx': {'description': 'The received/input rate (in bit per second).',
|
||||||
|
'unit': 'bps'},
|
||||||
|
'tx': {'description': 'The sent/output rate (in bit per second).',
|
||||||
|
'unit': 'bps'},
|
||||||
|
'cumulative_rx': {'description': 'The number of bytes received through the interface (cumulative).',
|
||||||
|
'unit': 'bytes'},
|
||||||
|
'cumulative_tx': {'description': 'The number of bytes sent through the interface (cumulative).',
|
||||||
|
'unit': 'bytes'},
|
||||||
|
'speed': {'description': 'Maximum interface speed (in bit per second). Can return 0 on some operating-system.',
|
||||||
|
'unit': 'bps'},
|
||||||
|
'is_up': {'description': 'Is the interface up ?',
|
||||||
|
'unit': 'bool'},
|
||||||
|
'time_since_update': {'description': 'Number of seconds since last update.',
|
||||||
|
'unit': 'seconds'},
|
||||||
|
}
|
||||||
|
|
||||||
# SNMP OID
|
# SNMP OID
|
||||||
# http://www.net-snmp.org/docs/mibs/interfaces.html
|
# http://www.net-snmp.org/docs/mibs/interfaces.html
|
||||||
# Dict key = interface_name
|
# Dict key = interface_name
|
||||||
@ -56,6 +86,7 @@ class Plugin(GlancesPlugin):
|
|||||||
super(Plugin, self).__init__(args=args,
|
super(Plugin, self).__init__(args=args,
|
||||||
config=config,
|
config=config,
|
||||||
items_history_list=items_history_list,
|
items_history_list=items_history_list,
|
||||||
|
fields_description=fields_description,
|
||||||
stats_init_value=[])
|
stats_init_value=[])
|
||||||
|
|
||||||
# We want to display the stat in the curse interface
|
# We want to display the stat in the curse interface
|
||||||
|
Loading…
Reference in New Issue
Block a user