From fce47ba2c783033c93991bdc2483fed6f55a30c8 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Mon, 9 Apr 2018 12:08:42 -0700 Subject: [PATCH] Run pre-commit to clean files --- LICENSE | 16 ++++++++-------- README.md | 1 - minitor/main.py | 12 ++++++------ setup.py | 8 ++++++-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/LICENSE b/LICENSE index dbfab25..f8a1b2a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ -Apache License -Version 2.0, January 2004 +Apache License +Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -59,14 +59,14 @@ To apply the Apache License to your work, attach the following boilerplate notic Copyright [yyyy] [name of copyright owner] -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. diff --git a/README.md b/README.md index 5ae27b4..2de05b4 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,3 @@ It will read the contents of `config.yml` and begin its loop. You could also run ### Configuring In this repo, you can explore the `sample-config.yml` file for an example, but the general structure is as follows. It should be noted that environment variable interpolation happens on load of the YAML file. Also, when alerts are executed, they will be passed through Python's format function with arguments for some attributes of the Monitor. Currently this is limited to `{monitor_name}`. - diff --git a/minitor/main.py b/minitor/main.py index 2298fab..5d6f265 100644 --- a/minitor/main.py +++ b/minitor/main.py @@ -2,8 +2,6 @@ import logging import sys from argparse import ArgumentParser from datetime import datetime -from os import environ -from subprocess import CalledProcessError from subprocess import call from subprocess import check_call from time import sleep @@ -36,10 +34,11 @@ class MinitorAlert(Exception): class Monitor(object): """Primary configuration item for Minitor""" + def __init__(self, config): """Accepts a dictionary of configuration items to override defaults""" settings = { - 'alerts': [ 'log' ], + 'alerts': ['log'], 'check_interval': 30, 'alert_after': 4, 'alert_every': -1, @@ -91,7 +90,7 @@ class Monitor(object): """Determines if this Monitor should run it's check command""" if not self.last_check: return True - since_last_check = (datetime.now()-self.last_check).total_seconds() + since_last_check = (datetime.now() - self.last_check).total_seconds() return since_last_check >= self.check_interval def check(self): @@ -216,7 +215,7 @@ class Minitor(object): '--config', '-c', dest='config_path', default='config.yml', - help='Path to the config YAML file to use' + help='Path to the config YAML file to use', ) return parser.parse_args() @@ -231,7 +230,8 @@ class Minitor(object): try: result = monitor.check() if result is not None: - self.logger.info('%s: %s', + self.logger.info( + '%s: %s', monitor.name, 'SUCCESS' if result else 'FAILURE' ) diff --git a/setup.py b/setup.py index 4107933..7a1138a 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,9 @@ -from setuptools import setup, find_packages from codecs import open from os import path +from setuptools import find_packages +from setuptools import setup + here = path.abspath(path.dirname(__file__)) # Get the long description from the README file @@ -14,7 +16,9 @@ setup( description='A minimal monitoring tool', long_description=long_description, url='https://git.iamthefij.com/iamthefij/minitor', - download_url='https://git.iamthefij.com/iamthefij/minitor/archive/master.tar.gz', + download_url=( + 'https://git.iamthefij.com/iamthefij/minitor/archive/master.tar.gz' + ), author='Ian Fijolek', author_email='ian@iamthefij.com', classifiers=[