Skip to content

Commit

Permalink
Add Hyper-V integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Nov 20, 2018
1 parent 65dc132 commit 97977bc
Show file tree
Hide file tree
Showing 22 changed files with 429 additions and 1 deletion.
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: '{branch}.{build}'
os: Default Azure
clone_depth: 3
build: off
test: off
Expand Down Expand Up @@ -46,7 +47,7 @@ install:

test_script:
# Only test any of these that have changed for pull requests
- ddev test%CHANGED_ONLY_FLAG% -c datadog_checks_base active_directory aspdotnet disk dotnetclr exchange_server iis pdh_check sqlserver win32_event_log windows_service wmi_check
- ddev test%CHANGED_ONLY_FLAG% -c datadog_checks_base active_directory aspdotnet disk dotnetclr exchange_server hyperv iis pdh_check sqlserver win32_event_log windows_service wmi_check

# Uncomment the following to enable RDP connection into the builder and debug a build
# on_finish:
Expand Down
2 changes: 2 additions & 0 deletions hyperv/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CHANGELOG - Hyper-V

11 changes: 11 additions & 0 deletions hyperv/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
graft datadog_checks
graft tests

include MANIFEST.in
include README.md
include requirements.in
include requirements.txt
include requirements-dev.txt
include manifest.json

global-exclude *.py[cod] __pycache__
49 changes: 49 additions & 0 deletions hyperv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Agent Check: Hyper-V

## Overview

This check monitors [Hyper-V][1].

## Setup

### Installation

The Hyperv check is included in the [Datadog Agent][2] package, so you do not
need to install anything else on your server.

### Configuration

1. Edit the `hyperv.d/conf.yaml` file, in the `conf.d/` folder at the root of your
Agent's configuration directory to start collecting your hyperv performance data.
See the [sample hyperv.d/conf.yaml][2] for all available configuration options.

2. [Restart the Agent][3]

### Validation

[Run the Agent's `status` subcommand][4] and look for `hyperv` under the Checks section.

## Data Collected

### Metrics

See [metadata.csv][5] for a list of metrics provided by this integration.

### Service Checks

Hyper-V does not include any service checks.

### Events

Hyper-V does not include any events.

## Troubleshooting

Need help? Contact [Datadog Support][6].

[1]: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/hyper-v-on-windows-server
[2]: https://github.com/DataDog/integrations-core/blob/master/hyperv/datadog_checks/hyperv/data/conf.yaml.example
[3]: https://docs.datadoghq.com/agent/faq/agent-commands/#start-stop-restart-the-agent
[4]: https://docs.datadoghq.com/agent/faq/agent-commands/#agent-status-and-information
[5]: https://github.com/DataDog/integrations-core/blob/master/hyperv/metadata.csv
[6]: https://docs.datadoghq.com/help/
4 changes: 4 additions & 0 deletions hyperv/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
4 changes: 4 additions & 0 deletions hyperv/datadog_checks/hyperv/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__version__ = '0.0.1'
10 changes: 10 additions & 0 deletions hyperv/datadog_checks/hyperv/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .__about__ import __version__
from .hyperv import HypervCheck

__all__ = [
'__version__',
'HypervCheck'
]
4 changes: 4 additions & 0 deletions hyperv/datadog_checks/hyperv/data/conf.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
init_config:

instances:
- {}
12 changes: 12 additions & 0 deletions hyperv/datadog_checks/hyperv/hyperv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from datadog_checks.base import PDHBaseCheck
from .metrics import DEFAULT_COUNTERS


class HypervCheck(PDHBaseCheck):
def __init__(self, name, init_config, agentConfig, instances=None):
super(HypervCheck, self).__init__(
name, init_config, agentConfig, instances=instances, counter_list=DEFAULT_COUNTERS
)
135 changes: 135 additions & 0 deletions hyperv/datadog_checks/hyperv/metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)


# [object, instance of counter, counter name, metric name, metric type]
#
# This set is (mostly) from the Microsoft recommended counters to monitor Hyper-V:
# https://docs.microsoft.com/en-us/windows-server/administration/performance-tuning/role/hyper-v-server
# https://blogs.technet.microsoft.com/neales/2016/10/24/hyper-v-performance-cpu
# TODO: Investigate additional recommended counters from:
# https://blogs.technet.microsoft.com/chrisavis/2013/03/25/performance-management-monitoring-cpu-resources
DEFAULT_COUNTERS = [
# Memory
[
'Hyper-V Dynamic Memory Balancer',
None,
'Available Memory',
'hyperv.dynamic_memory_balancer.available_memory',
'gauge'
],
[
'Hyper-V Dynamic Memory Balancer',
None,
'Average Pressure',
'hyperv.dynamic_memory_balancer.average_pressure',
'gauge'
],

# Network
[
'Hyper-V Virtual Network Adapter',
None,
'Bytes/sec',
'hyperv.virtual_network_adapter.bytes_per_sec',
'gauge'
],

# Processor
[
'Hyper-V Hypervisor Logical Processor',
None,
'% Guest Run Time',
'hyperv.hypervisor_logical_processor.guest_run_time',
'gauge'
],
[
'Hyper-V Hypervisor Logical Processor',
None,
'% Hypervisor Run Time',
'hyperv.hypervisor_logical_processor.hypervisor_run_time',
'gauge'
],
[
'Hyper-V Hypervisor Logical Processor',
None,
'% Idle Time',
'hyperv.hypervisor_logical_processor.idle_time',
'gauge'
],
[
'Hyper-V Hypervisor Logical Processor',
None,
'% Total Run Time',
'hyperv.hypervisor_logical_processor.total_run_time',
'gauge'
],
[
'Hyper-V Hypervisor Logical Processor',
None,
'Context Switches/sec',
'hyperv.hypervisor_logical_processor.context_switches_per_sec',
'gauge'
],

[
'Hyper-V Hypervisor Root Virtual Processor',
None,
'% Guest Run Time',
'hyperv.hypervisor_root_virtual_processor.guest_run_time',
'gauge'
],
[
'Hyper-V Hypervisor Root Virtual Processor',
None,
'% Hypervisor Run Time',
'hyperv.hypervisor_root_virtual_processor.hypervisor_run_time',
'gauge'
],
[
'Hyper-V Hypervisor Root Virtual Processor',
None,
'% Total Run Time',
'hyperv.hypervisor_root_virtual_processor.total_run_time',
'gauge'
],

[
'Hyper-V Hypervisor Virtual Processor',
None,
'% Guest Run Time',
'hyperv.hypervisor_virtual_processor.guest_run_time',
'gauge'
],
[
'Hyper-V Hypervisor Virtual Processor',
None,
'% Hypervisor Run Time',
'hyperv.hypervisor_virtual_processor.hypervisor_run_time',
'gauge'
],
[
'Hyper-V Hypervisor Virtual Processor',
None,
'% Total Run Time',
'hyperv.hypervisor_virtual_processor.total_run_time',
'gauge'
],

# Storage
[
'Hyper-V VM Vid Partition',
None,
'Physical Pages Allocated',
'hyperv.vm_vid_partition.physical_pages_allocated',
'gauge'
],
[
'Hyper-V VM Vid Partition',
None,
'Remote Physical Pages',
'hyperv.vm_vid_partition.remote_physical_pages',
'gauge'
],
]
19 changes: 19 additions & 0 deletions hyperv/logos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Logos

The logos folder should contain three images with filenames and sizes that exactly match the following specifications. Underneath each specification is a list of places where the images may appear in the web app.

#### `saas_logos-bot.png` (200 × 128)

- Integration tile images at `/account/settings`
- Description heading at `/account/settings#integrations/hyperv`
- Integration monitor tiles and search bar results images at `/monitors#create/integration`

#### `saas_logos-small.png` (120 × 60)

- Integration dashboards list images at `/dash/list`
- Some integration dashboards/screenboards at `/dash/integration/hyperv`

#### `avatars-bot.png` (128 × 128)

- Event stream at `/event/stream`
- Notification icons at `/report/monitor`
24 changes: 24 additions & 0 deletions hyperv/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"display_name": "Hyper-V",
"maintainer": "help@datadoghq.com",
"manifest_version": "1.0.0",
"name": "hyperv",
"metric_prefix": "hyperv.",
"metric_to_check": "hyperv.hypervisor_logical_processor.total_run_time",
"creates_events": false,
"short_description": "Monitor Microsoft's Hyper-V virtualization technology.",
"guid": "412a75c1-b752-4b20-b046-4195dfaaf6ec",
"support": "core",
"supported_os": [
"windows"
],
"public_title": "Datadog-Hyper-V Integration",
"categories": [
"azure",
"cloud",
"monitoring",
"os & system"
],
"type": "check",
"is_public": false
}
17 changes: 17 additions & 0 deletions hyperv/metadata.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
metric_name,metric_type,interval,unit_name,per_unit_name,description,orientation,integration,short_name
hyperv.dynamic_memory_balancer.available_memory ,gauge,,byte,,The amount of memory left on the node.,1,hyperv,
hyperv.dynamic_memory_balancer.average_pressure ,gauge,,percent,,This counter represents the average pressure in the VM.,-1,hyperv,
hyperv.hypervisor_logical_processor.guest_run_time ,gauge,,percent,,The percentage of time spent by the processor in guest code.,0,hyperv,
hyperv.hypervisor_logical_processor.hypervisor_run_time ,gauge,,percent,,The percentage of time spent by the processor in hypervisor code.,0,hyperv,
hyperv.hypervisor_logical_processor.idle_time ,gauge,,percent,,The percentage of time spent by the processor in an idle state.,0,hyperv,
hyperv.hypervisor_logical_processor.total_run_time ,gauge,,percent,,The percentage of time spent by the processor in guest and hypervisor code.,0,hyperv,
hyperv.hypervisor_logical_processor.context_switches_per_sec ,gauge,,operation,,The combined rate at which all processors on the computer are switched from one thread to another.,0,hyperv,
hyperv.hypervisor_root_virtual_processor.guest_run_time ,gauge,,percent,,The percentage of time spent by the virtual processor in guest code.,0,hyperv,
hyperv.hypervisor_root_virtual_processor.hypervisor_run_time ,gauge,,percent,,The percentage of time spent by the virtual processor in hypervisor code.,0,hyperv,
hyperv.hypervisor_root_virtual_processor.total_run_time ,gauge,,percent,,The percentage of time spent by the virtual processor in guest and hypervisor code.,0,hyperv,
hyperv.hypervisor_virtual_processor.guest_run_time ,gauge,,percent,,The percentage of time spent by the virtual processor in guest code.,0,hyperv,
hyperv.hypervisor_virtual_processor.hypervisor_run_time ,gauge,,percent,,The percentage of time spent by the virtual processor in hypervisor code.,0,hyperv,
hyperv.hypervisor_virtual_processor.total_run_time ,gauge,,percent,,The percentage of time spent by the virtual processor in guest and hypervisor code.,0,hyperv,
hyperv.virtual_network_adapter.bytes_per_sec ,gauge,,byte,,The rate at which bytes are sent and received over each network adapter.,0,hyperv,
hyperv.vm_vid_partition.physical_pages_allocated ,gauge,,block,,The number of physical pages allocated.,0,hyperv,
hyperv.vm_vid_partition.remote_physical_pages ,gauge,,block,,The number of physical pages not allocated from the preferred NUMA node.,0,hyperv,
1 change: 1 addition & 0 deletions hyperv/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e ../datadog_checks_dev
Empty file added hyperv/requirements.in
Empty file.
Empty file added hyperv/requirements.txt
Empty file.
62 changes: 62 additions & 0 deletions hyperv/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from codecs import open # To use a consistent encoding
from os import path

from setuptools import setup

HERE = path.dirname(path.abspath(__file__))

# Get version info
ABOUT = {}
with open(path.join(HERE, 'datadog_checks', 'hyperv', '__about__.py')) as f:
exec(f.read(), ABOUT)

# Get the long description from the README file
with open(path.join(HERE, 'README.md'), encoding='utf-8') as f:
long_description = f.read()


CHECKS_BASE_REQ = 'datadog-checks-base'


setup(
name='datadog-hyperv',
version=ABOUT['__version__'],
description='The Hyper-V check',
long_description=long_description,
long_description_content_type='text/markdown',
keywords='datadog agent hyperv check',

# The project's main homepage.
url='https://github.com/DataDog/integrations-core',

# Author details
author='Datadog',
author_email='packages@datadoghq.com',

# License
license='BSD-3-Clause',

# See https://pypi.org/classifiers
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Topic :: System :: Monitoring',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],

# The package we're going to ship
packages=['datadog_checks.hyperv'],

# Run-time dependencies
install_requires=[CHECKS_BASE_REQ],

# Extra files to ship with the wheel package
include_package_data=True,
)
3 changes: 3 additions & 0 deletions hyperv/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
Loading

0 comments on commit 97977bc

Please sign in to comment.