diff --git a/glances/outputs/glances_stdout_fields.py b/glances/outputs/glances_stdout_fields.py index 9afe7db51ea835cdd7890ae3cc9c8a5b204d743c..b61d89da9ef92065300fa9e9bec05bb2ba1ecf10 100644 --- a/glances/outputs/glances_stdout_fields.py +++ b/glances/outputs/glances_stdout_fields.py @@ -49,7 +49,7 @@ class GlancesStdoutFieldsDescription(object): print('Restfull/API plugins documentation') 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('.. code-block:: bash') print('') @@ -70,7 +70,12 @@ class GlancesStdoutFieldsDescription(object): print('.. code-block:: json') print('') 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('') else: logger.error('No fields_description variable defined for plugin {}'.format(plugin)) diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py index cde30510c81f9cb3c32a040a1d5b9e4425c37ea2..46d19261e6dffc6ba138bfe2eacc1e9cef65721f 100644 --- a/glances/plugins/glances_network.py +++ b/glances/plugins/glances_network.py @@ -29,6 +29,36 @@ from glances.logger import logger 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 # http://www.net-snmp.org/docs/mibs/interfaces.html # Dict key = interface_name @@ -56,6 +86,7 @@ class Plugin(GlancesPlugin): super(Plugin, self).__init__(args=args, config=config, items_history_list=items_history_list, + fields_description=fields_description, stats_init_value=[]) # We want to display the stat in the curse interface