Пример #1
0
def getWindowsConfig():
    macs = ['-'.join(i['MACAddress'].split(':'))
                for i in utils.callWmic('NIC where AdapterTypeID=0 get MACAddress')]
    nics = utils.callWmic('NICconfig get MACAddress,DNSServerSearchOrder,IPAddress,DefaultIPGateway,IPSubnet')
    for nic in nics:
        if nic['MACAddress']:
            nic['MACAddress'] = '-'.join(nic['MACAddress'].split(':'))

        # for Windows 2003
        if nic['IPAddress'] == ['0.0.0.0']:
            nic['IPAddress'] = []
        if nic['IPSubnet'] == ['0.0.0.0']:
            nic['IPSubnet'] = []

    lan = sortInterfaces(macs)

    return lan
Пример #2
0
def getWindowsMemoryInfo():
    info = utils.callWmic('os get FreePhysicalMemory,TotalVisibleMemorySize')
    total = int(info[0]['TotalVisibleMemorySize'])
    free = int(info[0]['FreePhysicalMemory'])

    return {
        'total': total / 1024,
        'available': free / 1024,
        'used': (total - free) / 1024,
    }
Пример #3
0
def getWindowsMemoryInfo():
    info = utils.callWmic('os get FreePhysicalMemory,TotalVisibleMemorySize')
    total = int(info[0]['TotalVisibleMemorySize'])
    free = int(info[0]['FreePhysicalMemory'])

    return {
        'total': total / 1024,
        'available': free / 1024,
        'used': (total - free) / 1024,
    }
Пример #4
0
def getWindowsConfig():
    macs = [
        '-'.join(i['MACAddress'].split(':'))
        for i in utils.callWmic('NIC where AdapterTypeID=0 get MACAddress')
    ]
    nics = utils.callWmic(
        'NICconfig get MACAddress,DNSServerSearchOrder,IPAddress,DefaultIPGateway,IPSubnet'
    )
    for nic in nics:
        if nic['MACAddress']:
            nic['MACAddress'] = '-'.join(nic['MACAddress'].split(':'))

        # for Windows 2003
        if nic['IPAddress'] == ['0.0.0.0']:
            nic['IPAddress'] = []
        if nic['IPSubnet'] == ['0.0.0.0']:
            nic['IPSubnet'] = []

    lan = sortInterfaces(macs)

    return lan
Пример #5
0
def getWindowsDiskInfo():
    info = utils.callWmic('volume where DriveType=3 get Capacity,FreeSpace,Name')
    disks = []

    for disk in info:
        total = int(disk['Capacity']) / (1024 * 1024)
        free = int(disk['FreeSpace']) / (1024 * 1024)

        disks.append({
                'name': disk['Name'],
                'total': total,
                'used': total - free,
                'available': free,
        })

    return sorted(disks, key=lambda d: d['name'].lower())
Пример #6
0
def getWindowsDiskInfo():
    info = utils.callWmic(
        'volume where DriveType=3 get Capacity,FreeSpace,Name')
    disks = []

    for disk in info:
        total = int(disk['Capacity']) / (1024 * 1024)
        free = int(disk['FreeSpace']) / (1024 * 1024)

        disks.append({
            'name': disk['Name'],
            'total': total,
            'used': total - free,
            'available': free,
        })

    return sorted(disks, key=lambda d: d['name'].lower())
Пример #7
0
def getWindowsCpuInfo():
    info = utils.callWmic('cpu list')
    cpus = {}

    for cpu_info in info:
        sock_id = cpu_info['SocketDesignation']

        if sock_id in cpus:
            cpu = cpus[sock_id]
        else:
            cpu = cpus[sock_id] = {'used': None, 'core': []}

        cpu['core'].append(float(cpu_info['LoadPercentage']))

    for cpu in cpus.values():
        cpu['used'] = sum(cpu['core']) / len(cpu['core'])

    return cpus.values()
Пример #8
0
def getWindowsCpuInfo():
    info = utils.callWmic('cpu list')
    cpus = {}

    for cpu_info in info:
        sock_id = cpu_info['SocketDesignation']

        if sock_id in cpus:
            cpu = cpus[sock_id]
        else:
            cpu = cpus[sock_id] = {
                'used': None,
                'core': []
            }

        cpu['core'].append(float(cpu_info['LoadPercentage']))

    for cpu in cpus.values():
        cpu['used'] = sum(cpu['core']) / len(cpu['core'])

    return cpus.values()