Run pre-commit to clean files

This commit is contained in:
IamTheFij 2018-04-09 12:08:42 -07:00
parent 5edc2410ea
commit fce47ba2c7
4 changed files with 20 additions and 17 deletions

16
LICENSE
View File

@ -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.

View File

@ -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}`.

View File

@ -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'
)

View File

@ -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=[