diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/commands/create.py b/datadog_checks_dev/datadog_checks/dev/tooling/commands/create.py index 3d68f260a2dbed..4154dec4b9b5ca 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/commands/create.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/commands/create.py @@ -101,11 +101,10 @@ def display_path_tree(path_tree): def create(ctx, name, integration_type, location, non_interactive, quiet, dry_run): """Create scaffolding for a new integration.""" repo_choice = ctx.obj['repo_choice'] - integration_name = normalize_package_name(name) root = resolve_path(location) if location else get_root() path_sep = os.path.sep - integration_dir = os.path.join(root, integration_name) + integration_dir = os.path.join(root, normalize_package_name(name)) if os.path.exists(integration_dir): abort('Path `{}` already exists!'.format(integration_dir)) @@ -116,7 +115,7 @@ def create(ctx, name, integration_type, location, non_interactive, quiet, dry_ru template_fields['email_packages'] = template_fields['email'] click.echo() - config = construct_template_fields(integration_name, repo_choice, **template_fields) + config = construct_template_fields(name, repo_choice, **template_fields) files = create_template_files(integration_type, root, config, read=not dry_run) file_paths = [file.file_path.replace('{}{}'.format(root, path_sep), '', 1) for file in files] diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/create.py b/datadog_checks_dev/datadog_checks/dev/tooling/create.py index 1d0b1464ef61a8..7901d3289ac21d 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/create.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/create.py @@ -2,9 +2,11 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) import os +import re from datetime import datetime from uuid import uuid4 +from .utils import normalize_package_name from ..utils import ( create_file, dir_exists, @@ -18,6 +20,7 @@ TEMPLATES_DIR = path_join(os.path.dirname(os.path.abspath(__file__)), 'templates') BINARY_EXTENSIONS = ('.png', ) +SIMPLE_NAME = r'^\w+$' def get_valid_templates(): @@ -25,7 +28,12 @@ def get_valid_templates(): def construct_template_fields(integration_name, repo_choice, **kwargs): - check_name_cap = integration_name if integration_name.count('_') else integration_name.capitalize() + normalized_integration_name = normalize_package_name(integration_name) + check_name_cap = ( + integration_name.capitalize() + if re.match(SIMPLE_NAME, integration_name) + else integration_name + ) if repo_choice == 'core': author = 'Datadog' @@ -56,8 +64,10 @@ def construct_template_fields(integration_name, repo_choice, **kwargs): config = { 'author': author, - 'check_class': '{}Check'.format(''.join(part.capitalize() for part in integration_name.split('_'))), - 'check_name': integration_name, + 'check_class': '{}Check'.format( + ''.join(part.capitalize() for part in normalized_integration_name.split('_')) + ), + 'check_name': normalized_integration_name, 'check_name_cap': check_name_cap, 'email': email, 'email_packages': email_packages, diff --git a/mycheck/CHANGELOG.md b/mycheck/CHANGELOG.md new file mode 100644 index 00000000000000..94c58a7fb5187f --- /dev/null +++ b/mycheck/CHANGELOG.md @@ -0,0 +1,2 @@ +# CHANGELOG - Mycheck + diff --git a/mycheck/MANIFEST.in b/mycheck/MANIFEST.in new file mode 100644 index 00000000000000..46f690a5c7885e --- /dev/null +++ b/mycheck/MANIFEST.in @@ -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__ diff --git a/mycheck/README.md b/mycheck/README.md new file mode 100644 index 00000000000000..91e070a7698a7a --- /dev/null +++ b/mycheck/README.md @@ -0,0 +1,49 @@ +# Agent Check: Mycheck + +## Overview + +This check monitors [Mycheck][1]. + +## Setup + +### Installation + +The Mycheck 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 `mycheck.d/conf.yaml` file, in the `conf.d/` folder at the root of your + Agent's configuration directory to start collecting your mycheck performance data. + See the [sample mycheck.d/conf.yaml][3] for all available configuration options. + +2. [Restart the Agent][4] + +### Validation + +[Run the Agent's `status` subcommand][5] and look for `mycheck` under the Checks section. + +## Data Collected + +### Metrics + +Mycheck does not include any metrics. + +### Service Checks + +Mycheck does not include any service checks. + +### Events + +Mycheck does not include any events. + +## Troubleshooting + +Need help? Contact [Datadog Support][6]. + +[1]: **LINK_TO_INTEGERATION_SITE** +[2]: https://app.datadoghq.com/account/settings#agent +[3]: https://github.com/DataDog/integrations-core/blob/master/mycheck/datadog_checks/mycheck/data/conf.yaml.example +[4]: https://docs.datadoghq.com/agent/faq/agent-commands/#start-stop-restart-the-agent +[5]: https://docs.datadoghq.com/agent/faq/agent-commands/#agent-status-and-information +[6]: https://docs.datadoghq.com/help/ diff --git a/mycheck/datadog_checks/__init__.py b/mycheck/datadog_checks/__init__.py new file mode 100644 index 00000000000000..c5254131af1f14 --- /dev/null +++ b/mycheck/datadog_checks/__init__.py @@ -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__) diff --git a/mycheck/datadog_checks/mycheck/__about__.py b/mycheck/datadog_checks/mycheck/__about__.py new file mode 100644 index 00000000000000..ea0058ae72eb78 --- /dev/null +++ b/mycheck/datadog_checks/mycheck/__about__.py @@ -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' diff --git a/mycheck/datadog_checks/mycheck/__init__.py b/mycheck/datadog_checks/mycheck/__init__.py new file mode 100644 index 00000000000000..92654a286ead47 --- /dev/null +++ b/mycheck/datadog_checks/mycheck/__init__.py @@ -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 .mycheck import MycheckCheck + +__all__ = [ + '__version__', + 'MycheckCheck' +] diff --git a/mycheck/datadog_checks/mycheck/data/conf.yaml.example b/mycheck/datadog_checks/mycheck/data/conf.yaml.example new file mode 100644 index 00000000000000..f1b3ea7ec2378d --- /dev/null +++ b/mycheck/datadog_checks/mycheck/data/conf.yaml.example @@ -0,0 +1,4 @@ +init_config: + +instances: + - {} diff --git a/mycheck/datadog_checks/mycheck/mycheck.py b/mycheck/datadog_checks/mycheck/mycheck.py new file mode 100644 index 00000000000000..a26357bc5a2b00 --- /dev/null +++ b/mycheck/datadog_checks/mycheck/mycheck.py @@ -0,0 +1,9 @@ +# (C) Datadog, Inc. 2018 +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) +from datadog_checks.checks import AgentCheck + + +class MycheckCheck(AgentCheck): + def check(self, instance): + pass diff --git a/mycheck/logos/avatars-bot.png b/mycheck/logos/avatars-bot.png new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/mycheck/logos/saas_logos-bot.png b/mycheck/logos/saas_logos-bot.png new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/mycheck/logos/saas_logos-small.png b/mycheck/logos/saas_logos-small.png new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/mycheck/manifest.json b/mycheck/manifest.json new file mode 100644 index 00000000000000..ad7cc38de0771a --- /dev/null +++ b/mycheck/manifest.json @@ -0,0 +1,23 @@ +{ + "display_name": "Mycheck", + "maintainer": "help@datadoghq.com", + "manifest_version": "1.0.0", + "name": "mycheck", + "metric_prefix": "mycheck.", + "metric_to_check": "", + "creates_events": false, + "short_description": "", + "guid": "9ea78f1c-c0dd-4dc0-8c49-13bd55e59057", + "support": "core", + "supported_os": [ + "linux", + "mac_os", + "windows" + ], + "public_title": "Datadog-Mycheck Integration", + "categories": [ + "" + ], + "type": "check", + "is_public": true +} diff --git a/mycheck/metadata.csv b/mycheck/metadata.csv new file mode 100644 index 00000000000000..ae0af074191ec7 --- /dev/null +++ b/mycheck/metadata.csv @@ -0,0 +1 @@ +metric_name,metric_type,interval,unit_name,per_unit_name,description,orientation,integration,short_name diff --git a/mycheck/requirements-dev.txt b/mycheck/requirements-dev.txt new file mode 100644 index 00000000000000..958b51d3293c5b --- /dev/null +++ b/mycheck/requirements-dev.txt @@ -0,0 +1 @@ +datadog-checks-dev diff --git a/mycheck/requirements.in b/mycheck/requirements.in new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/mycheck/requirements.txt b/mycheck/requirements.txt new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/mycheck/setup.py b/mycheck/setup.py new file mode 100644 index 00000000000000..c14670b7012075 --- /dev/null +++ b/mycheck/setup.py @@ -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', 'mycheck', '__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-mycheck', + version=ABOUT['__version__'], + description='The Mycheck check', + long_description=long_description, + long_description_content_type='text/markdown', + keywords='datadog agent mycheck 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', 'datadog_checks.mycheck'], + + # Run-time dependencies + install_requires=[CHECKS_BASE_REQ], + + # Extra files to ship with the wheel package + include_package_data=True, +) diff --git a/mycheck/tests/__init__.py b/mycheck/tests/__init__.py new file mode 100644 index 00000000000000..a383179a005ed4 --- /dev/null +++ b/mycheck/tests/__init__.py @@ -0,0 +1,3 @@ +# (C) Datadog, Inc. 2018 +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) diff --git a/mycheck/tests/conftest.py b/mycheck/tests/conftest.py new file mode 100644 index 00000000000000..1d35367e78e59b --- /dev/null +++ b/mycheck/tests/conftest.py @@ -0,0 +1,9 @@ +# (C) Datadog, Inc. 2018 +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) +import pytest + + +@pytest.fixture +def instance(): + return {} diff --git a/mycheck/tests/test_mycheck.py b/mycheck/tests/test_mycheck.py new file mode 100644 index 00000000000000..b6100ca8281125 --- /dev/null +++ b/mycheck/tests/test_mycheck.py @@ -0,0 +1,11 @@ +# (C) Datadog, Inc. 2018 +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) +from datadog_checks.mycheck import MycheckCheck + + +def test_check(aggregator, instance): + check = MycheckCheck('mycheck', {}, {}) + check.check(instance) + + aggregator.assert_all_metrics_covered() diff --git a/mycheck/tox.ini b/mycheck/tox.ini new file mode 100644 index 00000000000000..4d9760adf65017 --- /dev/null +++ b/mycheck/tox.ini @@ -0,0 +1,28 @@ +[tox] +minversion = 2.0 +skip_missing_interpreters = true +basepython = py27 +envlist = + {py27,py36}-mycheck + flake8 + +[testenv] +platform = linux|darwin|win32 +deps = + ../datadog_checks_base[deps] + -rrequirements-dev.txt +passenv = + DOCKER* + COMPOSE* +commands = + pip install --require-hashes -r requirements.txt + pytest -v + +[testenv:flake8] +skip_install = true +deps = flake8 +commands = flake8 . + +[flake8] +exclude = .eggs,.tox,build +max-line-length = 120