示例#1
0
def send_metrics(hoststats):
    prefix = "hosts." + uuid()
    data = {}

    try:
        for dom in hoststats['storageDomains']:
            storage_prefix = prefix + '.storage.' + dom
            dom_info = hoststats['storageDomains'][dom]
            data[storage_prefix + '.delay'] = dom_info['delay']
            data[storage_prefix + '.last_check'] = dom_info['lastCheck']

        data[prefix + '.memory.available'] = hoststats['memAvailable']
        data[prefix + '.memory.committed'] = hoststats['memCommitted']
        data[prefix + '.memory.free_mb'] = hoststats['memFree']
        data[prefix + '.memory.usage_percent'] = hoststats['memUsed']
        data[prefix + '.memory.anon_huge_pages'] = hoststats['anonHugePages']

        data[prefix + '.swap.total_mb'] = hoststats['swapTotal']
        data[prefix + '.swap.free_mb'] = hoststats['swapFree']

        data[prefix + '.vms.active'] = hoststats['vmActive']
        data[prefix + '.vms.total'] = hoststats['vmCount']

        data[prefix + '.cpu.load'] = hoststats['cpuLoad']
        data[prefix + '.cpu.user'] = hoststats['cpuUser']
        data[prefix + '.cpu.sys'] = hoststats['cpuSys']
        data[prefix + '.cpu.idle'] = hoststats['cpuIdle']
        data[prefix + '.cpu.sys_vdsmd'] = hoststats['cpuSysVdsmd']
        data[prefix + '.cpu.user_vdsmd'] = hoststats['cpuUserVdsmd']

        if 'ksmPages' in hoststats:
            data[prefix + '.cpu.ksm_pages'] = hoststats['ksmPages']
            data[prefix + '.cpu.ksm_cpu_precent'] = hoststats['ksmCpu']

        if hoststats['haStats']['configured']:
            data[prefix + '.ha_score'] = hoststats['haScore']

        data[prefix + '.elapsed_time'] = hoststats['elapsedTime']

        if 'network' in hoststats:
            for interface in hoststats['network']:
                if_info = hoststats['network'][interface]
                net_prefix = prefix + '.network_interfaces.' + interface
                data[net_prefix + '.speed'] = if_info['speed']
                data[net_prefix + '.rx_rate'] = if_info['rxRate']
                data[net_prefix + '.tx_rate'] = if_info['txRate']
                data[net_prefix + '.rx_errors'] = if_info['rxErrors']
                data[net_prefix + '.tx_errors'] = if_info['txErrors']
                data[net_prefix + '.rx_dropped'] = if_info['rxDropped']
                data[net_prefix + '.tx_dropped'] = if_info['txDropped']
                data[net_prefix + '.rx'] = if_info['rx']
                data[net_prefix + '.tx'] = if_info['tx']

        metrics.send(data)
    except KeyError:
        logging.exception('Host metrics collection failed')
示例#2
0
文件: api.py 项目: EdDev/vdsm
def send_metrics(hoststats):
    prefix = "hosts"
    data = {}

    try:
        for dom in hoststats['storageDomains']:
            storage_prefix = prefix + '.storage.' + dom
            dom_info = hoststats['storageDomains'][dom]
            data[storage_prefix + '.delay'] = dom_info['delay']
            data[storage_prefix + '.last_check'] = dom_info['lastCheck']

        data[prefix + '.memory.available'] = hoststats['memAvailable']
        data[prefix + '.memory.committed'] = hoststats['memCommitted']
        data[prefix + '.memory.free_mb'] = hoststats['memFree']
        data[prefix + '.memory.usage_percent'] = hoststats['memUsed']
        data[prefix + '.memory.anon_huge_pages'] = hoststats['anonHugePages']

        data[prefix + '.swap.total_mb'] = hoststats['swapTotal']
        data[prefix + '.swap.free_mb'] = hoststats['swapFree']

        data[prefix + '.vms.active'] = hoststats['vmActive']
        data[prefix + '.vms.total'] = hoststats['vmCount']

        data[prefix + '.cpu.load'] = hoststats['cpuLoad']
        data[prefix + '.cpu.user'] = hoststats['cpuUser']
        data[prefix + '.cpu.sys'] = hoststats['cpuSys']
        data[prefix + '.cpu.idle'] = hoststats['cpuIdle']
        data[prefix + '.cpu.sys_vdsmd'] = hoststats['cpuSysVdsmd']
        data[prefix + '.cpu.user_vdsmd'] = hoststats['cpuUserVdsmd']

        if 'ksmPages' in hoststats:
            data[prefix + '.cpu.ksm_pages'] = hoststats['ksmPages']
            data[prefix + '.cpu.ksm_cpu_precent'] = hoststats['ksmCpu']

        if hoststats['haStats']['configured']:
            data[prefix + '.ha_score'] = hoststats['haScore']

        data[prefix + '.elapsed_time'] = hoststats['elapsedTime']

        if 'network' in hoststats:
            for interface in hoststats['network']:
                if_info = hoststats['network'][interface]
                net_prefix = prefix + '.nic.' + interface.replace('.', '_')
                data[net_prefix + '.speed'] = if_info['speed']
                data[net_prefix + '.rx_errors'] = if_info['rxErrors']
                data[net_prefix + '.tx_errors'] = if_info['txErrors']
                data[net_prefix + '.rx_dropped'] = if_info['rxDropped']
                data[net_prefix + '.tx_dropped'] = if_info['txDropped']
                data[net_prefix + '.rx'] = if_info['rx']
                data[net_prefix + '.tx'] = if_info['tx']

        metrics.send(data)
    except KeyError:
        logging.exception('Host metrics collection failed')
示例#3
0
文件: api.py 项目: oVirt/vdsm
def send_metrics(hoststats):
    prefix = "hosts"
    data = {}

    try:
        for dom in hoststats['storageDomains']:
            storage_prefix = prefix + '.storage.' + dom
            dom_info = hoststats['storageDomains'][dom]
            data[storage_prefix + '.delay'] = dom_info['delay']
            data[storage_prefix + '.last_check'] = dom_info['lastCheck']

        metrics.send(data)
    except KeyError:
        logging.exception('Host metrics collection failed')
示例#4
0
def send_metrics(hoststats):
    prefix = "hosts"
    data = {}

    try:
        for dom in hoststats['storageDomains']:
            storage_prefix = prefix + '.storage.' + dom
            dom_info = hoststats['storageDomains'][dom]
            data[storage_prefix + '.delay'] = dom_info['delay']
            data[storage_prefix + '.last_check'] = dom_info['lastCheck']

        metrics.send(data)
    except KeyError:
        logging.exception('Host metrics collection failed')
示例#5
0
def send_metrics(vms_stats):
    data = {}
    try:
        for vm_uuid in vms_stats:
            stat = vms_stats[vm_uuid]
            prefix = "vms." + stat['vmName']
            data[prefix + '.cpu.user'] = stat['cpuUser']
            data[prefix + '.cpu.sys'] = stat['cpuSys']
            data[prefix + '.cpu.usage'] = stat['cpuUsage']

            if stat['balloonInfo']:
                data[prefix + '.balloon.max'] = \
                    stat['balloonInfo']['balloon_max']
                data[prefix + '.balloon.min'] = \
                    stat['balloonInfo']['balloon_min']
                data[prefix + '.balloon.target'] = \
                    stat['balloonInfo']['balloon_target']
                data[prefix + '.balloon.cur'] = \
                    stat['balloonInfo']['balloon_cur']

            if 'memoryStats' in stat:
                for k, v in six.iteritems(stat['memoryStats']):
                    data[prefix + '.mem.' + k] = v

            if 'disks' in stat:
                for disk in stat['disks']:
                    diskprefix = prefix + '.disk.' + disk
                    diskinfo = stat['disks'][disk]

                    data[diskprefix + '.read_latency'] = \
                        diskinfo['readLatency']
                    data[diskprefix + '.read_ops'] = \
                        diskinfo['readOps']
                    data[diskprefix + '.read_bytes'] = \
                        diskinfo['readBytes']
                    data[diskprefix + '.read_rate'] = \
                        diskinfo['readRate']

                    data[diskprefix + '.write_bytes'] = \
                        diskinfo['writtenBytes']
                    data[diskprefix + '.write_ops'] = \
                        diskinfo['writeOps']
                    data[diskprefix + '.write_latency'] = \
                        diskinfo['writeLatency']
                    data[diskprefix + '.write_rate'] = \
                        diskinfo['writeRate']

                    data[diskprefix + '.apparent_size'] = \
                        diskinfo['apparentsize']
                    data[diskprefix + '.flush_latency'] = \
                        diskinfo['flushLatency']
                    data[diskprefix + '.true_size'] = \
                        diskinfo['truesize']

            if 'network' in stat:
                for interface in stat['network']:
                    netprefix = prefix + '.nic.' + interface
                    if_info = stat['network'][interface]
                    data[netprefix + '.speed'] = if_info['speed']
                    data[netprefix + '.rx_bytes'] = if_info['rx']
                    data[netprefix + '.rx_errors'] = if_info['rxErrors']
                    data[netprefix + '.rx_dropped'] = if_info['rxDropped']

                    data[netprefix + '.tx_bytes'] = if_info['tx']
                    data[netprefix + '.tx_errors'] = if_info['txErrors']
                    data[netprefix + '.tx_dropped'] = if_info['txDropped']

        # Guest cpu-count,apps list, status, mac addr, client IP,
        # display type, kvm enabled, username, vcpu info, vm jobs,
        # displayinfo, hash, acpi, fqdn, vm uuid, pid,
        #
        # are all meta-data that should be published separately

        metrics.send(data)
    except KeyError:
        _log.exception('VM metrics collection failed')
示例#6
0
文件: vmstats.py 项目: igoihman/vdsm
def send_metrics(vms_stats):
    data = {}
    try:
        for vm_uuid in vms_stats:
            prefix = "vms." + vm_uuid
            stat = vms_stats[vm_uuid]
            data[prefix + '.cpu.user'] = stat['cpuUser']
            data[prefix + '.cpu.sys'] = stat['cpuSys']
            data[prefix + '.cpu.usage'] = stat['cpuUsage']

            data[prefix + '.balloon.max'] = \
                stat['balloonInfo']['balloon_max']
            data[prefix + '.balloon.min'] = \
                stat['balloonInfo']['balloon_min']
            data[prefix + '.balloon.target'] = \
                stat['balloonInfo']['balloon_target']
            data[prefix + '.balloon.cur'] = \
                stat['balloonInfo']['balloon_cur']

            if 'disks' in stat:
                for disk in stat['disks']:
                    diskprefix = prefix + '.vm_disk.' + disk
                    diskinfo = stat['disks'][disk]

                    data[diskprefix + '.read.latency'] = \
                        diskinfo['readLatency']
                    data[diskprefix + '.read.ops'] = \
                        diskinfo['readOps']
                    data[diskprefix + '.read.bytes'] = \
                        diskinfo['readBytes']
                    data[diskprefix + '.read.rate'] = \
                        diskinfo['readRate']

                    data[diskprefix + '.write.bytes'] = \
                        diskinfo['writtenBytes']
                    data[diskprefix + '.write.ops'] = \
                        diskinfo['writeOps']
                    data[diskprefix + '.write.latency'] = \
                        diskinfo['writeLatency']
                    data[diskprefix + '.write.rate'] = \
                        diskinfo['writeRate']

                    data[diskprefix + '.apparent_size'] = \
                        diskinfo['apparentsize']
                    data[diskprefix + '.flush_latency'] = \
                        diskinfo['flushLatency']
                    data[diskprefix + '.true_size'] = \
                        diskinfo['truesize']

            if 'network' in stat:
                for interface in stat['network']:
                    netprefix = prefix + '.network_interfaces.' + interface
                    if_info = stat['network'][interface]
                    data[netprefix + '.speed'] = if_info['speed']
                    data[netprefix + '.rx.bytes'] = if_info['rx']
                    data[netprefix + '.rx.errors'] = if_info['rxErrors']
                    data[netprefix + '.rx.dropped'] = if_info['rxDropped']

                    data[netprefix + '.tx.bytes'] = if_info['tx']
                    data[netprefix + '.tx.errors'] = if_info['txErrors']
                    data[netprefix + '.tx.dropped'] = if_info['txDropped']

        # Guest cpu-count,apps list, status, mac addr, client IP,
        # display type, kvm enabled, username, vcpu info, vm jobs,
        # displayinfo, hash, acpi, fqdn, vm uuid, pid, vNodeRuntimeInfo,
        #
        # are all meta-data that should be published separately

        metrics.send(data)
    except KeyError:
        logging.exception('VM metrics collection failed')
示例#7
0
def report_stats(vms_stats):
    report = {}
    try:
        for vm_uuid in vms_stats:
            prefix = "vms." + vm_uuid
            stat = vms_stats[vm_uuid]
            report[prefix + '.cpu.user'] = stat['cpuUser']
            report[prefix + '.cpu.sys'] = stat['cpuSys']
            report[prefix + '.cpu.usage'] = stat['cpuUsage']

            report[prefix + '.balloon.max'] = \
                stat['balloonInfo']['balloon_max']
            report[prefix + '.balloon.min'] = \
                stat['balloonInfo']['balloon_min']
            report[prefix + '.balloon.target'] = \
                stat['balloonInfo']['balloon_target']
            report[prefix + '.balloon.cur'] = \
                stat['balloonInfo']['balloon_cur']

            if 'disks' in stat:
                for disk in stat['disks']:
                    diskprefix = prefix + '.vm_disk.' + disk
                    diskinfo = stat['disks'][disk]

                    report[diskprefix + '.read.latency'] = \
                        diskinfo['readLatency']
                    report[diskprefix + '.read.ops'] = \
                        diskinfo['readOps']
                    report[diskprefix + '.read.bytes'] = \
                        diskinfo['readBytes']
                    report[diskprefix + '.read.rate'] = \
                        diskinfo['readRate']

                    report[diskprefix + '.write.bytes'] = \
                        diskinfo['writtenBytes']
                    report[diskprefix + '.write.ops'] = \
                        diskinfo['writeOps']
                    report[diskprefix + '.write.latency'] = \
                        diskinfo['writeLatency']
                    report[diskprefix + '.write.rate'] = \
                        diskinfo['writeRate']

                    report[diskprefix + '.apparent_size'] = \
                        diskinfo['apparentsize']
                    report[diskprefix + '.flush_latency'] = \
                        diskinfo['flushLatency']
                    report[diskprefix + '.true_size'] = \
                        diskinfo['truesize']

            if 'network' in stat:
                for interface in stat['network']:
                    netprefix = prefix + '.network_interfaces.' + interface
                    if_info = stat['network'][interface]
                    report[netprefix + '.speed'] = if_info['speed']
                    report[netprefix + '.rx.bytes'] = if_info['rx']
                    report[netprefix + '.rx.errors'] = if_info['rxErrors']
                    report[netprefix + '.rx.dropped'] = if_info['rxDropped']

                    report[netprefix + '.tx.bytes'] = if_info['tx']
                    report[netprefix + '.tx.errors'] = if_info['txErrors']
                    report[netprefix + '.tx.dropped'] = if_info['txDropped']

        # Guest cpu-count,apps list, status, mac addr, client IP,
        # display type, kvm enabled, username, vcpu info, vm jobs,
        # displayinfo, hash, acpi, fqdn, vm uuid, pid, vNodeRuntimeInfo,
        #
        # are all meta-data that should be published separately

        metrics.send(report)
    except KeyError:
        logging.exception('Report vm stats failed')
示例#8
0
def send_metrics(vms_stats):
    data = {}
    try:
        for vm_uuid in vms_stats:
            stat = vms_stats[vm_uuid]
            prefix = "vms." + stat['vmName']
            data[prefix + '.cpu.user'] = stat['cpuUser']
            data[prefix + '.cpu.sys'] = stat['cpuSys']
            data[prefix + '.cpu.usage'] = stat['cpuUsage']

            if stat['balloonInfo']:
                data[prefix + '.balloon.max'] = \
                    stat['balloonInfo']['balloon_max']
                data[prefix + '.balloon.min'] = \
                    stat['balloonInfo']['balloon_min']
                data[prefix + '.balloon.target'] = \
                    stat['balloonInfo']['balloon_target']
                data[prefix + '.balloon.cur'] = \
                    stat['balloonInfo']['balloon_cur']

            if 'disks' in stat:
                for disk in stat['disks']:
                    diskprefix = prefix + '.disk.' + disk
                    diskinfo = stat['disks'][disk]

                    data[diskprefix + '.read_latency'] = \
                        diskinfo['readLatency']
                    data[diskprefix + '.read_ops'] = \
                        diskinfo['readOps']
                    data[diskprefix + '.read_bytes'] = \
                        diskinfo['readBytes']
                    data[diskprefix + '.read_rate'] = \
                        diskinfo['readRate']

                    data[diskprefix + '.write_bytes'] = \
                        diskinfo['writtenBytes']
                    data[diskprefix + '.write_ops'] = \
                        diskinfo['writeOps']
                    data[diskprefix + '.write_latency'] = \
                        diskinfo['writeLatency']
                    data[diskprefix + '.write_rate'] = \
                        diskinfo['writeRate']

                    data[diskprefix + '.apparent_size'] = \
                        diskinfo['apparentsize']
                    data[diskprefix + '.flush_latency'] = \
                        diskinfo['flushLatency']
                    data[diskprefix + '.true_size'] = \
                        diskinfo['truesize']

            if 'network' in stat:
                for interface in stat['network']:
                    netprefix = prefix + '.nic.' + interface
                    if_info = stat['network'][interface]
                    data[netprefix + '.speed'] = if_info['speed']
                    data[netprefix + '.rx_bytes'] = if_info['rx']
                    data[netprefix + '.rx_errors'] = if_info['rxErrors']
                    data[netprefix + '.rx_dropped'] = if_info['rxDropped']

                    data[netprefix + '.tx_bytes'] = if_info['tx']
                    data[netprefix + '.tx_errors'] = if_info['txErrors']
                    data[netprefix + '.tx_dropped'] = if_info['txDropped']

        # Guest cpu-count,apps list, status, mac addr, client IP,
        # display type, kvm enabled, username, vcpu info, vm jobs,
        # displayinfo, hash, acpi, fqdn, vm uuid, pid, vNodeRuntimeInfo,
        #
        # are all meta-data that should be published separately

        metrics.send(data)
    except KeyError:
        logging.exception('VM metrics collection failed')