本文整理匯總了Python中cloud.aws.CloudHost.get_cluster_stats方法的典型用法代碼示例。如果您正苦於以下問題:Python CloudHost.get_cluster_stats方法的具體用法?Python CloudHost.get_cluster_stats怎麽用?Python CloudHost.get_cluster_stats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cloud.aws.CloudHost
的用法示例。
在下文中一共展示了CloudHost.get_cluster_stats方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle_if_instance_info
# 需要導入模塊: from cloud.aws import CloudHost [as 別名]
# 或者: from cloud.aws.CloudHost import get_cluster_stats [as 別名]
def handle_if_instance_info(self, is_allowed):
stats = self.get_argument('instance_info', None)
if stats is None:
return False
if not is_allowed:
AdminHandler.log_error("Show instance info not allowed for user")
response = {'code': -1, 'data': 'You do not have permissions to view these stats'}
else:
try:
if stats == 'load':
stats = {}
# get cluster loads
average_load = CloudHost.get_cluster_average_stats('Load')
if None != average_load:
stats['Average Load'] = average_load;
machine_loads = CloudHost.get_cluster_stats('Load')
if None != machine_loads:
for n, v in machine_loads.iteritems():
stats['Instance ' + n] = v
response = {'code': 0, 'data': stats} if stats is not None else {'code': 1, 'data': {}}
except:
AdminHandler.log_error("exception while getting stats")
response = {'code': -1, 'data': 'error getting stats'}
self.write(response)
return True
示例2: handle_if_instance_info
# 需要導入模塊: from cloud.aws import CloudHost [as 別名]
# 或者: from cloud.aws.CloudHost import get_cluster_stats [as 別名]
def handle_if_instance_info(self, is_allowed):
stats = self.get_argument('instance_info', None)
if stats is None:
return False
if not is_allowed:
AdminHandler.log_error("Show instance info not allowed for user")
response = {'code': -1, 'data': 'You do not have permissions to view these stats'}
else:
try:
if stats == 'load':
result = {}
# get cluster loads
average_load = CloudHost.get_cluster_average_stats('Load')
if None != average_load:
result['Average Load'] = average_load;
machine_loads = CloudHost.get_cluster_stats('Load')
if None != machine_loads:
for n, v in machine_loads.iteritems():
result['Instance ' + n] = v
elif stats == 'sessions':
result = {}
if CloudHost.ENABLED['autoscale']:
instances = CloudHost.get_autoscaled_instances()
else:
instances = ['localhost']
for idx in range(0, len(instances)):
inst = instances[idx]
result[inst] = JBoxContainer.sync_session_status(inst)['data']
else:
raise Exception("unknown command %s" % (stats,))
response = {'code': 0, 'data': result}
except:
AdminHandler.log_error("exception while getting stats")
AdminHandler._get_logger().exception("exception while getting stats")
response = {'code': -1, 'data': 'error getting stats'}
self.write(response)
return True