Пример #1
0
def main():
    """Get status of various processes in TS"""
    processes = process_set()

    for process in processes:
        service_name, service_status = process
        if service_status:
            status_string = 'Running'
        else:
            status_string = 'Down'

        print(service_name, '|', status_string, file=sys.stderr)
Пример #2
0
def main():
    """Get status of various processes in TS"""
    processes = process_set()

    for process in processes:
        service_name, service_status = process
        if service_status:
            status_string = 'Running'
        else:
            status_string = 'Down'

        print(service_name, '|', status_string, file=sys.stderr)
Пример #3
0
def dashboard_fragments(request):
    """ Returns the dashboard sections as html in a json object"""
    time_span = request.GET.get("time_span", "24hours")
    now = datetime.datetime.now(pytz.UTC)

    DASHBOARD_TIME_SPANS = {
        "hour": now - datetime.timedelta(hours=1),
        "today": now.replace(hour=0, minute=0, second=0, microsecond=0),
        "24hours": now - datetime.timedelta(hours=24),
        "7days": now - datetime.timedelta(days=7),
        # Used for testing only. Do not expose to the UI.
        "__all__": datetime.datetime(year=1971, month=1, day=1),
    }
    if time_span not in DASHBOARD_TIME_SPANS:
        raise Http404("Time span %s not available!" % time_span)

    # runs section
    runs = get_runs_list(DASHBOARD_TIME_SPANS[time_span])
    runs_context = {
        # Runs Section
        "runs": {
            "time_span": time_span,
            "stages": DASHBOARD_STAGES,
            "runs": runs,
        },
    }

    # software update
    update_status = GlobalConfig.get().ts_update_status

    # services
    services_down = []
    for process, state in process_set():
        if not state:
            services_down.append(process)

    show_cluster = False
    nodes_down = []
    if Cruncher.objects.count() > 0:
        show_cluster = True
        nodes_down = Cruncher.objects.exclude(state='G').values_list('name',
                                                                     flat=True)

    # data management
    disk_usage = {}
    for fs in FileServer.objects.all().order_by('pk'):
        if os.path.exists(fs.filesPrefix):
            disk_usage[fs.filesPrefix] = fs.percentfull

    dm_active_jobs = DMFileStat.objects.filter(
        action_state__in=['AG', 'DG', 'EG', 'SA', 'SE', 'SD', 'IG'
                          ]).values_list('action_state', flat=True)

    # instruments
    rigs = Rig.objects.exclude(host_address='')
    num_rigs = len(rigs)
    if num_rigs > 1:
        pool = Pool(processes=min(num_rigs, 20))
        instruments = pool.map(get_instrument_info, rigs)
    else:
        instruments = [get_instrument_info(rig) for rig in rigs]

    instr_connected = sum(
        [instr['status'] == CONNECTED for instr in instruments])
    instr_offline = sum([instr['status'] == OFFLINE for instr in instruments])
    instr_alarm = sum([instr['status'] == ALARM for instr in instruments])

    summary_context = {
        # Summary Section
        "summary": {
            "ts_version": TS_version,
            "update_status": update_status,
            "instruments": {
                "connected": instr_connected,
                "offline": instr_offline,
                "alerts": instr_alarm,
            },
            "services": {
                "url": reverse("configure_services"),
                "number_services_down": len(services_down),
                "services_down": services_down,
                "show_cluster": True if show_cluster else False,
                "number_nodes_down": len(nodes_down) if show_cluster else "",
            },
            "data_management": {
                "url":
                reverse("datamanagement"),
                "disk_usage":
                disk_usage,
                "show_path":
                len(disk_usage) > 1,
                "dm_jobs": [
                    ("archive in progress",
                     sum([s == 'AG' for s in dm_active_jobs])),
                    ("export in progress",
                     sum([s == 'EG' for s in dm_active_jobs])),
                    ("delete in progress",
                     sum([s == 'DG' for s in dm_active_jobs])),
                    ("import in progress",
                     sum([s == 'IG' for s in dm_active_jobs])),
                    ("archive pending",
                     sum([s == 'SA' for s in dm_active_jobs])),
                    ("export pending", sum([s == 'SE'
                                            for s in dm_active_jobs])),
                    ("delete pending", sum([s == 'SD'
                                            for s in dm_active_jobs])),
                ]
            }
        },
    }

    instruments_context = {
        "instruments":
        sorted(instruments, key=lambda x: (x['status'], x['name'].lower()))
    }

    return HttpResponse(json.dumps({
        "summary":
        render_to_string("rundb/dashboard/fragments/summary.html",
                         summary_context),
        "runs":
        render_to_string("rundb/dashboard/fragments/runs.html", runs_context),
        "instruments":
        render_to_string("rundb/dashboard/fragments/instruments.html",
                         instruments_context)
    }),
                        content_type="application/json")
Пример #4
0
def dashboard_fragments(request, skip_runs=False):
    """ Returns the dashboard sections as html in a json object"""
    time_span = request.GET.get("time_span", "24hours")
    now = datetime.datetime.now(pytz.UTC)

    DASHBOARD_TIME_SPANS = {
        "hour": now - datetime.timedelta(hours=1),
        "today": now.replace(hour=0, minute=0, second=0, microsecond=0),
        "24hours": now - datetime.timedelta(hours=24),
        "7days": now - datetime.timedelta(days=7),
        # Used for testing only. Do not expose to the UI.
        "__all__": datetime.datetime(year=1971, month=1, day=1),
    }
    if time_span not in DASHBOARD_TIME_SPANS:
        raise Http404("Time span %s not available!" % time_span)

    # runs section
    if skip_runs:
        runs_context = {
            # Runs Section
            "runs": {
                "time_span": time_span,
                "stages": DASHBOARD_STAGES,
                "runs": [],
                "error": "",
            }
        }
    else:
        try:
            runs = get_runs_list(DASHBOARD_TIME_SPANS[time_span])
            runs_error = None
        except Exception as err:
            runs = []
            runs_error = str(err)

        runs_context = {
            # Runs Section
            "runs": {
                "time_span": time_span,
                "stages": DASHBOARD_STAGES,
                "runs": runs,
                "error": runs_error,
            }
        }

    # software update
    update_status = GlobalConfig.get().ts_update_status

    # services
    services_down = []
    for process, state in process_set():
        if not state:
            services_down.append(process)

    show_cluster = False
    nodes_down = []
    if Cruncher.objects.count() > 0:
        show_cluster = True
        nodes_down = Cruncher.objects.exclude(state="G").values_list("name",
                                                                     flat=True)

    # storage status
    storage = get_storage_status()

    # data management
    disk_usage = get_disk_usage()
    dm_active_jobs = DMFileStat.objects.filter(
        action_state__in=["AG", "DG", "EG", "SA", "SE", "SD", "IG"
                          ]).values_list("action_state", flat=True)
    dm_errors = DMFileStat.objects.filter(action_state="E").count()

    # instruments
    rigs = Rig.objects.exclude(host_address="")
    num_rigs = len(rigs)
    if num_rigs > 1:
        with ManagedPool(processes=min(num_rigs, 50)) as pool:
            instruments = pool.map(get_instrument_info, rigs)
    else:
        instruments = [get_instrument_info(rig) for rig in rigs]

    instr_connected = sum(
        [instr["status"] == CONNECTED for instr in instruments])
    instr_offline = sum([instr["status"] == OFFLINE for instr in instruments])
    instr_alarm = sum([instr["status"] == ALARM for instr in instruments])

    summary_context = {
        # Summary Section
        "summary": {
            "ts_version": TS_version,
            "update_status": update_status,
            "instruments": {
                "connected": instr_connected,
                "offline": instr_offline,
                "alerts": instr_alarm,
            },
            "services": {
                "url": reverse("configure_services"),
                "number_services_down": len(services_down),
                "services_down": services_down,
                "show_cluster": True if show_cluster else False,
                "number_nodes_down": len(nodes_down) if show_cluster else "",
                "show_nas": storage["show_nas"],
                "nas_status": storage.get("nas_status", ""),
                "show_raid": storage["show_raid"],
                "raid_status": storage.get("raid_status", ""),
            },
            "data_management": {
                "url":
                reverse("datamanagement"),
                "disk_usage":
                disk_usage,
                "show_path":
                len(disk_usage) > 1,
                "dm_jobs": [
                    ("archive in progress",
                     sum([s == "AG" for s in dm_active_jobs])),
                    ("export in progress",
                     sum([s == "EG" for s in dm_active_jobs])),
                    ("delete in progress",
                     sum([s == "DG" for s in dm_active_jobs])),
                    ("import in progress",
                     sum([s == "IG" for s in dm_active_jobs])),
                    ("archive pending",
                     sum([s == "SA" for s in dm_active_jobs])),
                    ("export pending", sum([s == "SE"
                                            for s in dm_active_jobs])),
                    ("delete pending", sum([s == "SD"
                                            for s in dm_active_jobs])),
                ],
                "dm_errors":
                dm_errors,
            },
        }
    }

    instruments_context = {
        "instruments":
        sorted(instruments, key=lambda x: (x["status"], x["name"].lower()))
    }

    return HttpResponse(
        json.dumps({
            "summary":
            render_to_string("rundb/home/fragments/summary.html",
                             summary_context),
            "runs":
            render_to_string("rundb/home/fragments/runs.html", runs_context),
            "instruments":
            render_to_string("rundb/home/fragments/instruments.html",
                             instruments_context),
        }),
        content_type="application/json",
    )
Пример #5
0
def dashboard_fragments(request, skip_runs=False):
    """ Returns the dashboard sections as html in a json object"""
    time_span = request.GET.get("time_span", "24hours")
    now = datetime.datetime.now(pytz.UTC)

    DASHBOARD_TIME_SPANS = {
        "hour": now - datetime.timedelta(hours=1),
        "today": now.replace(hour=0, minute=0, second=0, microsecond=0),
        "24hours": now - datetime.timedelta(hours=24),
        "7days": now - datetime.timedelta(days=7),
        # Used for testing only. Do not expose to the UI.
        "__all__": datetime.datetime(year=1971, month=1, day=1),
    }
    if time_span not in DASHBOARD_TIME_SPANS:
        raise Http404("Time span %s not available!" % time_span)

    # runs section
    if skip_runs:
        runs_context = {
            # Runs Section
            "runs": {
                "time_span": time_span,
                "stages": DASHBOARD_STAGES,
                "runs": [],
                "error": ""
            },
        }
    else:
        try:
            runs = get_runs_list(DASHBOARD_TIME_SPANS[time_span])
            runs_error = None
        except Exception as err:
            runs = []
            runs_error = str(err)

        runs_context = {
            # Runs Section
            "runs": {
                "time_span": time_span,
                "stages": DASHBOARD_STAGES,
                "runs": runs,
                "error": runs_error
            },
        }

    # software update
    update_status = GlobalConfig.get().ts_update_status

    # services
    services_down = []
    for process, state in process_set():
        if not state:
            services_down.append(process)

    show_cluster = False
    nodes_down = []
    if Cruncher.objects.count() > 0:
        show_cluster = True
        nodes_down = Cruncher.objects.exclude(state='G').values_list('name', flat=True)

    # storage status
    storage = get_storage_status()

    # data management
    disk_usage = get_disk_usage()

    dm_active_jobs = DMFileStat.objects.filter(action_state__in=['AG', 'DG', 'EG', 'SA', 'SE', 'SD', 'IG']).values_list(
        'action_state', flat=True)

    # instruments
    rigs = Rig.objects.exclude(host_address='')
    num_rigs = len(rigs)
    if num_rigs > 1:
        pool = Pool(processes=min(num_rigs, 50))
        instruments = pool.map(get_instrument_info, rigs)
    else:
        instruments = [get_instrument_info(rig) for rig in rigs]

    instr_connected = sum([instr['status'] == CONNECTED for instr in instruments])
    instr_offline = sum([instr['status'] == OFFLINE for instr in instruments])
    instr_alarm = sum([instr['status'] == ALARM for instr in instruments])

    summary_context = {
        # Summary Section
        "summary": {
            "ts_version": TS_version,
            "update_status": update_status,
            "instruments": {
                "connected": instr_connected,
                "offline": instr_offline,
                "alerts": instr_alarm,
            },
            "services": {
                "url": reverse("configure_services"),
                "number_services_down": len(services_down),
                "services_down": services_down,
                "show_cluster": True if show_cluster else False,
                "number_nodes_down": len(nodes_down) if show_cluster else "",
                "show_nas": storage['show_nas'],
                "nas_status": storage.get('nas_status', ''),
                "show_raid": storage['show_raid'],
                "raid_status": storage.get('raid_status', ''),
            },
            "data_management": {
                "url": reverse("datamanagement"),
                "disk_usage": disk_usage,
                "show_path": len(disk_usage) > 1,
                "dm_jobs": [
                    ("archive in progress", sum([s == 'AG' for s in dm_active_jobs])),
                    ("export in progress", sum([s == 'EG' for s in dm_active_jobs])),
                    ("delete in progress", sum([s == 'DG' for s in dm_active_jobs])),
                    ("import in progress", sum([s == 'IG' for s in dm_active_jobs])),
                    ("archive pending", sum([s == 'SA' for s in dm_active_jobs])),
                    ("export pending", sum([s == 'SE' for s in dm_active_jobs])),
                    ("delete pending", sum([s == 'SD' for s in dm_active_jobs])),
                ]
            }
        },
    }

    instruments_context = {
        "instruments": sorted(instruments, key=lambda x: (x['status'], x['name'].lower()))
    }

    return HttpResponse(json.dumps({
        "summary": render_to_string("rundb/home/fragments/summary.html", summary_context),
        "runs": render_to_string("rundb/home/fragments/runs.html", runs_context),
        "instruments": render_to_string("rundb/home/fragments/instruments.html", instruments_context)
    }), content_type="application/json")
Пример #6
0
#!/usr/bin/python
# Copyright (C) 2013, 2014 Ion Torrent Systems, Inc. All Rights Reserved

from __future__ import print_function
import sys
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'iondb.settings'

from iondb.rundb.configure.views import process_set

processes = process_set()

for process in processes:
	serviceName, serviceStatus = process
	if serviceStatus:
		statusString = 'Running'
	else:
		statusString = 'Down'

	print(serviceName, '|', statusString, file=sys.stderr)
	
Пример #7
0
#!/usr/bin/python
# Copyright (C) 2013, 2014 Ion Torrent Systems, Inc. All Rights Reserved

from __future__ import print_function
import sys
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'iondb.settings'

from iondb.rundb.configure.views import process_set

processes = process_set()

for process in processes:
    serviceName, serviceStatus = process
    if serviceStatus:
        statusString = 'Running'
    else:
        statusString = 'Down'

    print(serviceName, '|', statusString, file=sys.stderr)