Ejemplo n.º 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
Ejemplo n.º 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,
    }
Ejemplo n.º 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,
    }
Ejemplo n.º 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
Ejemplo n.º 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())
Ejemplo n.º 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())
Ejemplo n.º 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()
Ejemplo n.º 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()