% import json % import os % import time % import urllib % from datetime import datetime % from webui_lib import * % url = "http://localhost:" + slave_port + "/slave/state.json" % data = urllib.urlopen(url).read() % state = json.loads(data) Mesos Slave

Mesos Slave

% pid = state['pid'] # slave@ip:port % _, server = pid.split("@", 1) % ip, _ = server.split(":", 1) % format = "%a %b %d %Y %I:%M:%S %p " + time.strftime("%Z", time.gmtime()) % start_local = datetime.fromtimestamp(state['start_time']).strftime(format) % start_utc = datetime.utcfromtimestamp(state['start_time']).isoformat(' ')

Server: {{HOSTNAME}} ({{ip}})
Built: {{state['build_date']}} by {{state['build_user']}}
Started: {{start_local}} ({{start_utc}} UTC)
% if state['id'] == -1: ID: unassigned (not yet registered)
% else: ID: {{state['id']}}
% end CPUs: {{state['resources']['cpus']}}
MEM: {{format_mem(state['resources']['mem'])}}
Frameworks: {{len(state['frameworks'])}}

Log: % if log_dir != "": [last 100 lines] [full] % else: Logging to a file is not enabled, please set the 'log_dir' option. % end

Frameworks

% # TODO: Sort these by framework ID. % if len(state['frameworks']) > 0: % for framework in state['frameworks']: % # For now just sum up the tasks and resources across all executors. % tasks = 0 % cpus = 0 % mem = 0 % for executor in framework['executors']: % tasks += len(executor['tasks']) % cpus += executor['resources']['cpus'] % mem += executor['resources']['mem'] % end % end
ID Name Running Tasks CPUs MEM
{{framework['id']}} {{framework['name']}} {{tasks}} {{cpus}} {{format_mem(mem)}}
% else:

No frameworks are active on this slave.

% end