Example #1
0
def pingServer(request, server='', requestId='', config='release'):
    if( request.method != 'GET' ):
        return

    try:
        if( server == '' ):
            print("LEPD serer is not specified!")
            return
        
        print("LEPD address: " + server)
        client = LepDClient(server=server, config=config)
        
        result = {}
        result['connected'] = client.ping()
        
        if (result['connected']):
            # get cpu count
            cpuMonitor = CPUMonitor(server=server, config=config)
            cpuCapacityData = cpuMonitor.getCapacity()
            result['cpuCoreCount'] = cpuCapacityData['data']['coresCount']
            
            memMonitor = MemoryMonitor(server=server, config=config)
            memoryCapacityData = memMonitor.getCapacity()
            result['memoryTotal'] = memoryCapacityData['data']['capacity']

        return JSONResponse(result)
    except Exception as ex:
        # print(ex)
        return HttpResponse(status=404)
Example #2
0
def pingServer(request, server='', requestId='', config='release'):
    if (request.method != 'GET'):
        return

    try:
        if (server == ''):
            print("LEPD serer is not specified!")
            return

        print("LEPD address: " + server)
        client = LepDClient(server=server, config=config)

        result = {}
        result['connected'] = client.ping()

        return JSONResponse(result)
    except Exception as ex:
        return HttpResponse(status=404)