Run pre-commit to clean files
This commit is contained in:
parent
5edc2410ea
commit
fce47ba2c7
16
LICENSE
16
LICENSE
@ -1,5 +1,5 @@
|
|||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
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]
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (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 not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
@ -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}`.
|
||||||
|
|
||||||
|
@ -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'
|
||||||
)
|
)
|
||||||
|
8
setup.py
8
setup.py
@ -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=[
|
||||||
|
Loading…
Reference in New Issue
Block a user