desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Update the AMP'
| def update(self, process_list):
| logger.debug('{}: Update stats using systemctl {}'.format(self.NAME, self.get('systemctl_cmd')))
try:
res = check_output(self.get('systemctl_cmd').split())
except OSError as e:
logger.debug('{}: Error while executing systemctl ({})'.format(self.NAME, e))
els... |
'Overwrite the getattr method in case of attribute is not found.
The goal is to dynamically generate the following methods:
- getPlugname(): return Plugname stat in JSON format
- getViewsPlugname(): return views of the Plugname stat in JSON format'
| def __getattr__(self, item):
| if item.startswith('getViews'):
plugname = item[len('getViews'):].lower()
plugin = self._plugins[plugname]
if hasattr(plugin, 'get_json_views'):
return getattr(plugin, 'get_json_views')
else:
raise AttributeError(item)
elif item.startswith('get'):
... |
'Wrapper to load: plugins and export modules.'
| def load_modules(self, args):
| self._plugins = collections.defaultdict(dict)
self.load_plugins(args=args)
self._exports = collections.defaultdict(dict)
self.load_exports(args=args)
sys.path = sys_path
|
'Load the plugin (script), init it and add to the _plugin dict'
| def _load_plugin(self, plugin_script, args=None, config=None):
| name = plugin_script[len(self.header):(-3)].lower()
try:
plugin = __import__(plugin_script[:(-3)])
if (name in ('help', 'amps', 'ports')):
self._plugins[name] = plugin.Plugin(args=args, config=config)
else:
self._plugins[name] = plugin.Plugin(args=args)
except... |
'Load all plugins in the \'plugins\' folder.'
| def load_plugins(self, args=None):
| for item in os.listdir(plugins_path):
if (item.startswith(self.header) and item.endswith('.py') and (item != (self.header + 'plugin.py'))):
self._load_plugin(os.path.basename(item), args=args, config=self.config)
logger.debug('Available plugins list: {}'.format(self.getAllPlugins())... |
'Load all export modules in the \'exports\' folder.'
| def load_exports(self, args=None):
| if (args is None):
return False
header = 'glances_'
args_var = vars(locals()['args'])
for item in os.listdir(exports_path):
export_name = os.path.basename(item)[len(header):(-3)].lower()
if (item.startswith(header) and item.endswith('.py') and (item != (header + 'export.py')) and... |
'Return the enable plugins list.
if enable is False, return the list of all the plugins'
| def getAllPlugins(self, enable=True):
| if enable:
return [p for p in self._plugins if self._plugins[p].is_enable()]
else:
return [p for p in self._plugins]
|
'Return the exports modules list.'
| def getExportList(self):
| return [e for e in self._exports]
|
'Load the stats limits (except the one in the exclude list).'
| def load_limits(self, config=None):
| for p in self._plugins:
self._plugins[p].load_limits(config)
|
'Wrapper method to update the stats.'
| def update(self):
| for p in self._plugins:
if self._plugins[p].is_disable():
continue
self._plugins[p].update()
self._plugins[p].update_stats_history()
self._plugins[p].update_views()
|
'Export all the stats.
Each export module is ran in a dedicated thread.'
| def export(self, input_stats=None):
| input_stats = (input_stats or {})
for e in self._exports:
logger.debug(('Export stats using the %s module' % e))
thread = threading.Thread(target=self._exports[e].update, args=(input_stats,))
thread.start()
|
'Return all the stats (list).'
| def getAll(self):
| return [self._plugins[p].get_raw() for p in self._plugins]
|
'Return all the stats (dict).'
| def getAllAsDict(self):
| return {p: self._plugins[p].get_raw() for p in self._plugins}
|
'Return all the stats to be exported (list).
Default behavor is to export all the stat'
| def getAllExports(self):
| return [self._plugins[p].get_export() for p in self._plugins]
|
'Return all the stats to be exported (list).
Default behavor is to export all the stat
if plugin_list is provided, only export stats of given plugin (list)'
| def getAllExportsAsDict(self, plugin_list=None):
| if (plugin_list is None):
plugin_list = self._plugins
return {p: self._plugins[p].get_export() for p in plugin_list}
|
'Return the plugins limits list.'
| def getAllLimits(self):
| return [self._plugins[p].limits for p in self._plugins]
|
'Return all the stats limits (dict).
Default behavor is to export all the limits
if plugin_list is provided, only export limits of given plugin (list)'
| def getAllLimitsAsDict(self, plugin_list=None):
| if (plugin_list is None):
plugin_list = self._plugins
return {p: self._plugins[p].limits for p in plugin_list}
|
'Return the plugins views.'
| def getAllViews(self):
| return [self._plugins[p].get_views() for p in self._plugins]
|
'Return all the stats views (dict).'
| def getAllViewsAsDict(self):
| return {p: self._plugins[p].get_views() for p in self._plugins}
|
'Return the plugin list.'
| def get_plugin_list(self):
| return self._plugins
|
'Return the plugin name.'
| def get_plugin(self, plugin_name):
| if (plugin_name in self._plugins):
return self._plugins[plugin_name]
else:
return None
|
'End of the Glances stats.'
| def end(self):
| for e in self._exports:
self._exports[e].exit()
for p in self._plugins:
self._plugins[p].exit()
|
'Return the filter given by the user (as a sting)'
| @property
def filter_input(self):
| return self._filter_input
|
'Return the current filter to be applied'
| @property
def filter(self):
| return self._filter
|
'Set the filter (as a sting) and compute the regular expression
A filter could be one of the following:
- python > Process name of cmd start with python
- .*python.* > Process name of cmd contain python
- username:nicolargo > Process of nicolargo user'
| @filter.setter
def filter(self, value):
| self._filter_input = value
if (value is None):
self._filter = None
self._filter_key = None
else:
new_filter = value.split(':')
if (len(new_filter) == 1):
self._filter = new_filter[0]
self._filter_key = None
else:
self._filter = new_... |
'Return the filter regular expression'
| @property
def filter_re(self):
| return self._filter_re
|
'key where the filter should be applied'
| @property
def filter_key(self):
| return self._filter_key
|
'Return True if the process item match the current filter
The proces item is a dict.'
| def is_filtered(self, process):
| if (self.filter is None):
return False
if (self.filter_key is None):
return (self._is_process_filtered(process, key='cmdline') and self._is_process_filtered(process, key='name'))
else:
return self._is_process_filtered(process)
|
'Return True if the process[key] should be filtered according to the current filter'
| def _is_process_filtered(self, process, key=None):
| if (key is None):
key = self.filter_key
try:
if isinstance(process[key], list):
value = ' '.join(process[key])
else:
value = process[key]
except KeyError:
return False
try:
return (self._filter_re.match(value) is None)
except Attribu... |
'Init the AMPs list.'
| def __init__(self, args, config):
| self.args = args
self.config = config
self.load_configs()
|
'Load the AMP configuration files.'
| def load_configs(self):
| if (self.config is None):
return False
if ('monitor' in self.config.sections()):
logger.warning('A deprecated [monitor] section exists in the Glances configuration file. You should use the new Applications Monitoring Process module instead... |
'Update the command result attributed.'
| def update(self):
| processlist = glances_processes.getalllist()
for (k, v) in iteritems(self.get()):
if (not v.enable()):
continue
try:
amps_list = [p for p in processlist for c in p['cmdline'] if (re.search(v.regex(), c) is not None)]
except TypeError:
continue
... |
'Return the AMPs list.'
| def getList(self):
| return listkeys(self.__amps_dict)
|
'Return the AMPs dict.'
| def get(self):
| return self.__amps_dict
|
'Set the AMPs dict.'
| def set(self, new_dict):
| self.__amps_dict = new_dict
|
'Init the attribute
name: Attribute name (string)
description: Attribute human reading description (string)
history_max_size: Maximum size of the history list (default is no limit)
History is stored as a list for tuple: [(date, value), ...]'
| def __init__(self, name, description='', history_max_size=None):
| self._name = name
self._description = description
self._value = None
self._history_max_size = history_max_size
self._history = []
|
'Set a value.
Value is a tuple: (<timestamp>, <new_value>)'
| @value.setter
def value(self, new_value):
| self._value = (datetime.now(), new_value)
self.history_add(self._value)
|
'Add a value in the history'
| def history_add(self, value):
| if ((self._history_max_size is None) or (self.history_len() < self._history_max_size)):
self._history.append(value)
else:
self._history = (self._history[1:] + [value])
|
'Return the history size (maximum nuber of value in the history)'
| def history_size(self):
| return len(self._history)
|
'Return the current history lenght'
| def history_len(self):
| return len(self._history)
|
'Return the value in position pos in the history.
Default is to return the latest value added to the history.'
| def history_value(self, pos=1):
| return self._history[(- pos)]
|
'Return the history of last nb items (0 for all) In ISO JSON format'
| def history_raw(self, nb=0):
| return self._history[(- nb):]
|
'Return the history of last nb items (0 for all) In ISO JSON format'
| def history_json(self, nb=0):
| return [(i[0].isoformat(), i[1]) for i in self._history[(- nb):]]
|
'Return the mean on the <nb> values in the history.'
| def history_mean(self, nb=5):
| (_, v) = zip(*self._history)
return (sum(v[(- nb):]) / float((v[(-1)] - v[(- nb)])))
|
'Init GlancesActions class.'
| def __init__(self, args=None):
| self.status = {}
if hasattr(args, 'time'):
self.start_timer = Timer((args.time * 2))
else:
self.start_timer = Timer(3)
|
'Get the stat_name criticity.'
| def get(self, stat_name):
| try:
return self.status[stat_name]
except KeyError:
return None
|
'Set the stat_name to criticity.'
| def set(self, stat_name, criticity):
| self.status[stat_name] = criticity
|
'Run the commands (in background).
- stats_name: plugin_name (+ header)
- criticity: criticity of the trigger
- commands: a list of command line with optional {{mustache}}
- If True, then repeat the action
- mustache_dict: Plugin stats (can be use within {{mustache}})
Return True if the commands have been ran.'
| def run(self, stat_name, criticity, commands, repeat, mustache_dict=None):
| if (((self.get(stat_name) == criticity) and (not repeat)) or (not self.start_timer.finished())):
return False
logger.debug('{} action {} for {} ({}) with stats {}'.format(('Repeat' if repeat else 'Run'), commands, stat_name, criticity, mustache_dict))
for cmd in commands:
... |
'Update the stats.'
| def update(self, input_stats=None):
| input_stats = (input_stats or {})
super(GlancesStatsServer, self).update()
self.all_stats = self._set_stats(input_stats)
|
'Set the stats to the input_stats one.'
| def _set_stats(self, input_stats):
| return {p: self._plugins[p].get_raw() for p in self._plugins if self._plugins[p].is_enable()}
|
'Return the stats as a list.'
| def getAll(self):
| return self.all_stats
|
'Init the logs class.'
| def __init__(self):
| self.logs_max = 10
self.logs_list = []
|
'Return the raw logs list.'
| def get(self):
| return self.logs_list
|
'Return the number of item in the logs list.'
| def len(self):
| return self.logs_list.__len__()
|
'Return the item position, if it exists.
An item exist in the list if:
* end is < 0
* item_type is matching
Return -1 if the item is not found.'
| def __itemexist__(self, item_type):
| for i in range(self.len()):
if ((self.logs_list[i][1] < 0) and (self.logs_list[i][3] == item_type)):
return i
return (-1)
|
'Return the process sort key'
| def get_process_sort_key(self, item_type):
| if item_type.startswith('MEM'):
ret = 'memory_percent'
elif item_type.startswith('CPU_IOWAIT'):
ret = 'io_counters'
else:
ret = 'cpu_percent'
return ret
|
'Define the process auto sort key from the alert type.'
| def set_process_sort(self, item_type):
| glances_processes.auto_sort = True
glances_processes.sort_key = self.get_process_sort_key(item_type)
|
'Reset the process auto sort key.'
| def reset_process_sort(self):
| glances_processes.auto_sort = True
glances_processes.sort_key = 'cpu_percent'
|
'Add a new item to the logs list.
If \'item\' is a \'new one\', add the new item at the beginning of
the logs list.
If \'item\' is not a \'new one\', update the existing item.
If event < peak_time the the alert is not setoff.'
| def add(self, item_state, item_type, item_value, proc_list=None, proc_desc='', peak_time=6):
| proc_list = (proc_list or glances_processes.getalllist())
item_index = self.__itemexist__(item_type)
if (item_index < 0):
self._create_item(item_state, item_type, item_value, proc_list, proc_desc, peak_time)
else:
self._update_item(item_index, item_state, item_type, item_value, proc_list... |
'Create a new item in the log list'
| def _create_item(self, item_state, item_type, item_value, proc_list, proc_desc, peak_time):
| if ((item_state == 'WARNING') or (item_state == 'CRITICAL')):
self.set_process_sort(item_type)
item = [time.mktime(datetime.now().timetuple()), (-1), item_state, item_type, item_value, item_value, item_value, item_value, 1, [], proc_desc, glances_processes.sort_key]
self.logs_list.insert(0, ... |
'Update a item in the log list'
| def _update_item(self, item_index, item_state, item_type, item_value, proc_list, proc_desc, peak_time):
| if ((item_state == 'OK') or (item_state == 'CAREFUL')):
self.reset_process_sort()
endtime = time.mktime(datetime.now().timetuple())
if ((endtime - self.logs_list[item_index][0]) > peak_time):
self.logs_list[item_index][1] = endtime
else:
self.logs_list.remove(... |
'Clean the logs list by deleting finished items.
By default, only delete WARNING message.
If critical = True, also delete CRITICAL message.'
| def clean(self, critical=False):
| clean_logs_list = []
while (self.len() > 0):
item = self.logs_list.pop()
if ((item[1] < 0) or ((not critical) and item[2].startswith('CRITICAL'))):
clean_logs_list.insert(0, item)
self.logs_list = clean_logs_list
return self.len()
|
'The function is called *every time* before test_*.'
| def setUp(self):
| print ('\n' + ('=' * 78))
|
'Update stats (mandatory step for all the stats).
The update is made twice (for rate computation).'
| def test_000_update(self):
| print 'INFO: [TEST_000] Test the stats update function'
try:
stats.update()
except Exception as e:
print ('ERROR: Stats update failed: %s' % e)
self.assertTrue(False)
time.sleep(1)
try:
stats.update()
except Exception as e:
pr... |
'Check mandatory plugins.'
| def test_001_plugins(self):
| plugins_to_check = ['system', 'cpu', 'load', 'mem', 'memswap', 'network', 'diskio', 'fs', 'irq']
print ('INFO: [TEST_001] Check the mandatory plugins list: %s' % ', '.join(plugins_to_check))
plugins_list = stats.getAllPlugins()
for plugin in plugins_to_check:
self.assertT... |
'Check SYSTEM plugin.'
| def test_002_system(self):
| stats_to_check = ['hostname', 'os_name']
print ('INFO: [TEST_002] Check SYSTEM stats: %s' % ', '.join(stats_to_check))
stats_grab = stats.get_plugin('system').get_raw()
for stat in stats_to_check:
self.assertTrue((stat in stats_grab), msg=('Cannot find key: %s' % stat)... |
'Check CPU plugin.'
| def test_003_cpu(self):
| stats_to_check = ['system', 'user', 'idle']
print ('INFO: [TEST_003] Check mandatory CPU stats: %s' % ', '.join(stats_to_check))
stats_grab = stats.get_plugin('cpu').get_raw()
for stat in stats_to_check:
self.assertTrue((stat in stats_grab), msg=('Cannot find key: %... |
'Check LOAD plugin.'
| @unittest.skipIf(WINDOWS, 'Load average not available on Windows')
def test_004_load(self):
| stats_to_check = ['cpucore', 'min1', 'min5', 'min15']
print ('INFO: [TEST_004] Check LOAD stats: %s' % ', '.join(stats_to_check))
stats_grab = stats.get_plugin('load').get_raw()
for stat in stats_to_check:
self.assertTrue((stat in stats_grab), msg=('Cannot find key: %s... |
'Check MEM plugin.'
| def test_005_mem(self):
| stats_to_check = ['available', 'used', 'free', 'total']
print ('INFO: [TEST_005] Check MEM stats: %s' % ', '.join(stats_to_check))
stats_grab = stats.get_plugin('mem').get_raw()
for stat in stats_to_check:
self.assertTrue((stat in stats_grab), msg=('Cannot find key: %s... |
'Check MEMSWAP plugin.'
| def test_006_swap(self):
| stats_to_check = ['used', 'free', 'total']
print ('INFO: [TEST_006] Check SWAP stats: %s' % ', '.join(stats_to_check))
stats_grab = stats.get_plugin('memswap').get_raw()
for stat in stats_to_check:
self.assertTrue((stat in stats_grab), msg=('Cannot find key: %s' % stat... |
'Check NETWORK plugin.'
| def test_007_network(self):
| print 'INFO: [TEST_007] Check NETWORK stats'
stats_grab = stats.get_plugin('network').get_raw()
self.assertTrue((type(stats_grab) is list), msg='Network stats is not a list')
print ('INFO: NETWORK stats: %s' % stats_grab)
|
'Check DISKIO plugin.'
| def test_008_diskio(self):
| print 'INFO: [TEST_008] Check DISKIO stats'
stats_grab = stats.get_plugin('diskio').get_raw()
self.assertTrue((type(stats_grab) is list), msg='DiskIO stats is not a list')
print ('INFO: diskio stats: %s' % stats_grab)
|
'Check File System plugin.'
| def test_009_fs(self):
| print 'INFO: [TEST_009] Check FS stats'
stats_grab = stats.get_plugin('fs').get_raw()
self.assertTrue((type(stats_grab) is list), msg='FileSystem stats is not a list')
print ('INFO: FS stats: %s' % stats_grab)
|
'Check Process plugin.'
| def test_010_processes(self):
| print 'INFO: [TEST_010] Check PROCESS stats'
stats_grab = stats.get_plugin('processcount').get_raw()
self.assertTrue((type(stats_grab) is dict), msg='Process count stats is not a dict')
print ('INFO: PROCESS count stats: %s' % stats_grab)
stats_grab = stats.... |
'Check File System plugin.'
| def test_011_folders(self):
| print 'INFO: [TEST_011] Check FOLDER stats'
stats_grab = stats.get_plugin('folders').get_raw()
self.assertTrue((type(stats_grab) is list), msg='Folders stats is not a list')
print ('INFO: Folders stats: %s' % stats_grab)
|
'Check IP plugin.'
| def test_012_ip(self):
| print 'INFO: [TEST_012] Check IP stats'
stats_grab = stats.get_plugin('ip').get_raw()
self.assertTrue((type(stats_grab) is dict), msg='IP stats is not a dict')
print ('INFO: IP stats: %s' % stats_grab)
|
'Check IRQ plugin.'
| @unittest.skipIf((not LINUX), 'IRQs available only on Linux')
def test_013_irq(self):
| print 'INFO: [TEST_013] Check IRQ stats'
stats_grab = stats.get_plugin('irq').get_raw()
self.assertTrue((type(stats_grab) is list), msg='IRQ stats is not a list')
print ('INFO: IRQ stats: %s' % stats_grab)
|
'Check GPU plugin.'
| @unittest.skipIf((not LINUX), 'GPU available only on Linux')
def test_013_gpu(self):
| print 'INFO: [TEST_014] Check GPU stats'
stats_grab = stats.get_plugin('gpu').get_raw()
self.assertTrue((type(stats_grab) is list), msg='GPU stats is not a list')
print ('INFO: GPU stats: %s' % stats_grab)
|
'Test thresholds classes'
| @unittest.skipIf(PY3, True)
@unittest.skipIf(PY_PYPY, True)
def test_094_thresholds(self):
| print 'INFO: [TEST_094] Thresholds'
ok = GlancesThresholdOk()
careful = GlancesThresholdCareful()
warning = GlancesThresholdWarning()
critical = GlancesThresholdCritical()
self.assertTrue((ok < careful))
self.assertTrue((careful < warning))
self.assertTrue((warning < critical))
... |
'Test mandatories methods'
| def test_095_methods(self):
| print 'INFO: [TEST_095] Mandatories methods'
mandatories_methods = ['reset', 'update']
plugins_list = stats.getAllPlugins()
for plugin in plugins_list:
for method in mandatories_methods:
self.assertTrue(hasattr(stats.get_plugin(plugin), method), msg='{} has no metho... |
'Test get_views method'
| def test_096_views(self):
| print 'INFO: [TEST_096] Test views'
plugins_list = stats.getAllPlugins()
for plugin in plugins_list:
stats_grab = stats.get_plugin(plugin).get_raw()
views_grab = stats.get_plugin(plugin).get_views()
self.assertTrue((type(views_grab) is dict), msg='{} view is not ... |
'Test GlancesAttribute classe'
| def test_097_attribute(self):
| print 'INFO: [TEST_097] Test attribute'
from glances.attribute import GlancesAttribute
a = GlancesAttribute('a', description='ad', history_max_size=3)
self.assertEqual(a.name, 'a')
self.assertEqual(a.description, 'ad')
a.description = 'adn'
self.assertEqual(a.description, 'adn')
... |
'Test GlancesHistory classe'
| def test_098_history(self):
| print 'INFO: [TEST_098] Test history'
from glances.history import GlancesHistory
h = GlancesHistory()
h.add('a', 1)
h.add('a', 2)
h.add('a', 3)
h.add('b', 10)
h.add('b', 20)
h.add('b', 30)
self.assertEqual(len(h.get()), 2)
self.assertEqual(len(h.get()['a']), 3)
h... |
'Test quick look plugin.
> bar.min_value
0
> bar.max_value
100
> bar.percent = -1
> bar.percent
0
> bar.percent = 101
> bar.percent
100'
| def test_099_output_bars_must_be_between_0_and_100_percent(self):
| print 'INFO: [TEST_099] Test progress bar'
bar = Bar(size=1)
bar.percent = (-1)
self.assertLessEqual(bar.percent, bar.min_value)
bar.percent = 101
self.assertGreaterEqual(bar.percent, bar.max_value)
|
'Free all the stats'
| def test_999_the_end(self):
| print 'INFO: [TEST_999] Free the stats'
stats.end()
self.assertTrue(True)
|
'The function is called *every time* before test_*.'
| def setUp(self):
| print ('\n' + ('=' * 78))
|
'Start the Glances Web Server.'
| def test_000_start_server(self):
| global pid
print 'INFO: [TEST_000] Start the Glances Web Server'
cmdline = ('python -m glances -w -p %s' % SERVER_PORT)
print ('Run the Glances Web Server on port %s' % SERVER_PORT)
args = shlex.split(cmdline)
pid = subprocess.Popen(args)
... |
'All.'
| def test_001_all(self):
| method = 'all'
print 'INFO: [TEST_001] Get all stats'
print ('HTTP RESTful request: %s/%s' % (URL, method))
req = requests.get(('%s/%s' % (URL, method)))
self.assertTrue(req.ok)
|
'Plugins list.'
| def test_002_pluginslist(self):
| method = 'pluginslist'
print 'INFO: [TEST_002] Plugins list'
print ('HTTP RESTful request: %s/%s' % (URL, method))
req = requests.get(('%s/%s' % (URL, method)))
self.assertTrue(req.ok)
self.assertIsInstance(req.json(), list)
self.assertIn('cpu', req.json())
|
'Plugins.'
| def test_003_plugins(self):
| method = 'pluginslist'
print 'INFO: [TEST_003] Plugins'
plist = requests.get(('%s/%s' % (URL, method)))
for p in plist.json():
print ('HTTP RESTful request: %s/%s' % (URL, p))
req = requests.get(('%s/%s' % (URL, p)))
self.assertTrue(req.ok)
if (p in ('uptim... |
'Items.'
| def test_004_items(self):
| method = 'cpu'
print 'INFO: [TEST_004] Items for the CPU method'
ilist = requests.get(('%s/%s' % (URL, method)))
for i in ilist.json():
print ('HTTP RESTful request: %s/%s/%s' % (URL, method, i))
req = requests.get(('%s/%s/%s' % (URL, method, i)))
self.... |
'Values.'
| def test_005_values(self):
| method = 'processlist'
print 'INFO: [TEST_005] Item=Value for the PROCESSLIST method'
print ('%s/%s/pid/0' % (URL, method))
req = requests.get(('%s/%s/pid/0' % (URL, method)))
self.assertTrue(req.ok)
self.assertIsInstance(req.json(), dict)
|
'All limits.'
| def test_006_all_limits(self):
| method = 'all/limits'
print 'INFO: [TEST_006] Get all limits'
print ('HTTP RESTful request: %s/%s' % (URL, method))
req = requests.get(('%s/%s' % (URL, method)))
self.assertTrue(req.ok)
self.assertIsInstance(req.json(), dict)
|
'All views.'
| def test_007_all_views(self):
| method = 'all/views'
print 'INFO: [TEST_007] Get all views'
print ('HTTP RESTful request: %s/%s' % (URL, method))
req = requests.get(('%s/%s' % (URL, method)))
self.assertTrue(req.ok)
self.assertIsInstance(req.json(), dict)
|
'Plugins limits.'
| def test_008_plugins_limits(self):
| method = 'pluginslist'
print 'INFO: [TEST_008] Plugins limits'
plist = requests.get(('%s/%s' % (URL, method)))
for p in plist.json():
print ('HTTP RESTful request: %s/%s/limits' % (URL, p))
req = requests.get(('%s/%s/limits' % (URL, p)))
self.assertTrue(req.ok)
... |
'Plugins views.'
| def test_009_plugins_views(self):
| method = 'pluginslist'
print 'INFO: [TEST_009] Plugins views'
plist = requests.get(('%s/%s' % (URL, method)))
for p in plist.json():
print ('HTTP RESTful request: %s/%s/views' % (URL, p))
req = requests.get(('%s/%s/views' % (URL, p)))
self.assertTrue(req.ok)
... |
'History.'
| def test_010_history(self):
| method = 'history'
print 'INFO: [TEST_010] History'
print ('HTTP RESTful request: %s/cpu/%s' % (URL, method))
req = requests.get(('%s/cpu/%s' % (URL, method)))
self.assertIsInstance(req.json(), dict)
self.assertIsInstance(req.json()['user'], list)
self.assertTrue((len(req.json... |
'Stop the Glances Web Server.'
| def test_999_stop_server(self):
| print 'INFO: [TEST_999] Stop the Glances Web Server'
print 'Stop the Glances Web Server'
pid.terminate()
time.sleep(1)
self.assertTrue(True)
|
'The function is called *every time* before test_*.'
| def setUp(self):
| print ('\n' + ('=' * 78))
|
'Start the Glances Web Server.'
| def test_000_start_server(self):
| global pid
print 'INFO: [TEST_000] Start the Glances Web Server'
cmdline = ('python -m glances -s -p %s' % SERVER_PORT)
print ('Run the Glances Server on port %s' % SERVER_PORT)
args = shlex.split(cmdline)
pid = subprocess.Popen(args)
print ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.