From a2f9f12c62f75a3698caf00f7b8af8a77871d40e Mon Sep 17 00:00:00 2001 From: Dave Pedu Date: Sun, 6 Dec 2015 22:41:51 -0800 Subject: [PATCH] add python module scripts --- .gitignore | 5 ++++- bin/pymonitor | 6 ++++++ pymonitor/daemon.py | 8 +++++--- setup.py | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 bin/pymonitor create mode 100755 setup.py diff --git a/.gitignore b/.gitignore index 8808731..c93797d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ *.pyc __pycache__ -examples/config.test.json \ No newline at end of file +examples/config.test.json +build +dist +pymonitor.egg-info diff --git a/bin/pymonitor b/bin/pymonitor new file mode 100644 index 0000000..70c95f5 --- /dev/null +++ b/bin/pymonitor @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +from pymonitor import daemon + +if __name__ == "__main__": + daemon.run_cli() diff --git a/pymonitor/daemon.py b/pymonitor/daemon.py index 68df9f9..4ea291c 100755 --- a/pymonitor/daemon.py +++ b/pymonitor/daemon.py @@ -66,7 +66,7 @@ class Backend: self.sysinfo = {} self.update_sys_info() - logger.info("running on %(hostname)s (%(ipaddr)s)" % self.sysinfo) + self.logger.info("running on %(hostname)s (%(ipaddr)s)" % self.sysinfo) def connect(self): self.logger.info("final mapping %s" % self.mapping) @@ -194,7 +194,7 @@ class MonitorThread(Thread): self.logger.info("cancelling scheduler") self.alive=False -if __name__ == '__main__': +def run_cli(): from optparse import OptionParser logging.basicConfig(level=logging.DEBUG, format="%(asctime)-15s %(levelname)-8s %(name)s@%(filename)s:%(lineno)d %(message)s") logger = logging.getLogger("init") @@ -221,4 +221,6 @@ if __name__ == '__main__': except KeyboardInterrupt: print("") daemon.shutdown() - + +if __name__ == '__main__': + run_cli() diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..b0d039e --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +from setuptools import setup + +__version__ = "0.0.1" + +setup(name='pymonitor', + version=__version__, + description='python daemon for logging system metrics to elasticsearch db', + url='http://gitlab.xmopx.net/dave/python-esmonitor', + author='dpedu', + author_email='dave@davepedu.com', + packages=['pymonitor', 'pymonitor.builtins', 'pymonitor.monitors'], + scripts=['bin/pymonitor'], + zip_safe=False)