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

View File

@ -32,4 +32,3 @@ It will read the contents of `config.yml` and begin its loop. You could also run
### Configuring ### 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}`. 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 import sys
from argparse import ArgumentParser from argparse import ArgumentParser
from datetime import datetime from datetime import datetime
from os import environ
from subprocess import CalledProcessError
from subprocess import call from subprocess import call
from subprocess import check_call from subprocess import check_call
from time import sleep from time import sleep
@ -36,10 +34,11 @@ class MinitorAlert(Exception):
class Monitor(object): class Monitor(object):
"""Primary configuration item for Minitor""" """Primary configuration item for Minitor"""
def __init__(self, config): def __init__(self, config):
"""Accepts a dictionary of configuration items to override defaults""" """Accepts a dictionary of configuration items to override defaults"""
settings = { settings = {
'alerts': [ 'log' ], 'alerts': ['log'],
'check_interval': 30, 'check_interval': 30,
'alert_after': 4, 'alert_after': 4,
'alert_every': -1, 'alert_every': -1,
@ -91,7 +90,7 @@ class Monitor(object):
"""Determines if this Monitor should run it's check command""" """Determines if this Monitor should run it's check command"""
if not self.last_check: if not self.last_check:
return True 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 return since_last_check >= self.check_interval
def check(self): def check(self):
@ -216,7 +215,7 @@ class Minitor(object):
'--config', '-c', '--config', '-c',
dest='config_path', dest='config_path',
default='config.yml', 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() return parser.parse_args()
@ -231,7 +230,8 @@ class Minitor(object):
try: try:
result = monitor.check() result = monitor.check()
if result is not None: if result is not None:
self.logger.info('%s: %s', self.logger.info(
'%s: %s',
monitor.name, monitor.name,
'SUCCESS' if result else 'FAILURE' 'SUCCESS' if result else 'FAILURE'
) )

View File

@ -1,7 +1,9 @@
from setuptools import setup, find_packages
from codecs import open from codecs import open
from os import path from os import path
from setuptools import find_packages
from setuptools import setup
here = path.abspath(path.dirname(__file__)) here = path.abspath(path.dirname(__file__))
# Get the long description from the README file # Get the long description from the README file
@ -14,7 +16,9 @@ setup(
description='A minimal monitoring tool', description='A minimal monitoring tool',
long_description=long_description, long_description=long_description,
url='https://git.iamthefij.com/iamthefij/minitor', 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='Ian Fijolek',
author_email='ian@iamthefij.com', author_email='ian@iamthefij.com',
classifiers=[ classifiers=[